Module: Backup

Defined in:
lib/backup.rb,
lib/backup/jar.rb,
lib/backup/file_item.rb,
lib/backup/timestamp.rb,
lib/backup/file_item/base.rb,
lib/backup/file_item/cloud.rb,
lib/backup/file_item/local.rb

Defined Under Namespace

Modules: FileItem Classes: Instance, Jar, Timestamp

Class Method Summary collapse

Class Method Details

.aes(command, key, data) ⇒ Object



107
108
109
110
111
# File 'lib/backup.rb', line 107

def self.aes(command, key, data)
  aes = OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(command)
  aes.key = key
  aes.update(data) << aes.final
end

.decrypt_data(key, data) ⇒ Object



117
118
119
# File 'lib/backup.rb', line 117

def self.decrypt_data(key, data)
  Backup::aes(:decrypt, key, data)
end

.encrypt_data(key, data) ⇒ Object



113
114
115
# File 'lib/backup.rb', line 113

def self.encrypt_data(key, data)
  Backup::aes(:encrypt, key, data) unless data.empty?
end

.fetch_versions_of_backup(path) ⇒ Object



101
102
103
104
105
# File 'lib/backup.rb', line 101

def self.fetch_versions_of_backup(path)
  Dir["#{path}/*"].map do |backup|
    backup.match(/[0-9]{12}$/)[0] if backup.match(/[0-9]{12}$/)
  end.compact.sort
end