class PXCBackup::Repo

Attributes

path[R]

Public Class Methods

new(path, options = {}) click to toggle source
# File lib/pxcbackup/repo.rb, line 9
def initialize(path, options = {})
  @path = path
  @which = PathResolver.new(options)
end

Public Instance Methods

backups() click to toggle source
# 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) click to toggle source
# File lib/pxcbackup/repo.rb, line 25
def delete(backup)
  verify(backup)
  File.delete(backup.path)
end
stream_command(backup) click to toggle source
# File lib/pxcbackup/repo.rb, line 30
def stream_command(backup)
  verify(backup)
  "#{@which.cat.shellescape} #{backup.path.shellescape}"
end

Private Instance Methods

verify(backup) click to toggle source
# File lib/pxcbackup/repo.rb, line 37
def verify(backup)
  raise 'backup does not belong to this repo' if backup.repo != self
end