Class: PXCBackup::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/pxcbackup/repo.rb

Direct Known Subclasses

RemoteRepo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Repo

Returns a new instance of Repo.



9
10
11
12
# File 'lib/pxcbackup/repo.rb', line 9

def initialize(path, options = {})
  @path = path
  @which = PathResolver.new(options)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/pxcbackup/repo.rb', line 7

def path
  @path
end

Instance Method Details

#backupsObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/pxcbackup/repo.rb', line 14

def backups
  backups = []
  Dir.foreach(@path) do |file|
    path = File.join(@path, file)
    next unless File.file?(path)
    next unless Backup.regexp.match(path)
    backups << Backup.new(self, path)
  end
  backups.sort
end

#delete(backup) ⇒ Object



25
26
27
28
# File 'lib/pxcbackup/repo.rb', line 25

def delete(backup)
  verify(backup)
  system("#{@which.rm.shellescape} #{backup.path.shellescape}")
end

#stream_command(backup) ⇒ Object



30
31
32
33
# File 'lib/pxcbackup/repo.rb', line 30

def stream_command(backup)
  verify(backup)
  "#{@which.cat.shellescape} #{backup.path.shellescape}"
end