Class: RackCloudBackupDriver

Inherits:
CloudBackup::Driver show all
Defined in:
lib/drivers/rack_cloud_backup_driver.rb

Instance Method Summary collapse

Methods inherited from CloudBackup::Driver

#add_file, #list

Constructor Details

#initialize(credentials) ⇒ RackCloudBackupDriver

Returns a new instance of RackCloudBackupDriver.



5
6
7
8
9
10
# File 'lib/drivers/rack_cloud_backup_driver.rb', line 5

def initialize credentials
  @id = credentials[:id]
  @key = credentials[:key]
  @identificator = credentials[:bucket]
  @cf = CloudFiles::Connection.new(@id, @key)
end

Instance Method Details

#initiateObject



12
13
14
# File 'lib/drivers/rack_cloud_backup_driver.rb', line 12

def initiate
  @bucket = get_or_create_bucket
end

#list_by_dateObject

TODO: parse metadata



17
18
19
# File 'lib/drivers/rack_cloud_backup_driver.rb', line 17

def list_by_date
  @bucket.objects
end

#remove(name) ⇒ Object



21
22
23
# File 'lib/drivers/rack_cloud_backup_driver.rb', line 21

def remove name
  @bucket.delete_object name
end

#terminateObject



33
34
35
# File 'lib/drivers/rack_cloud_backup_driver.rb', line 33

def terminate
  @cf, @bucket = nil
end

#uploadObject

TODO: set metadata to objects



26
27
28
29
30
31
# File 'lib/drivers/rack_cloud_backup_driver.rb', line 26

def upload
  list.each do |file|
    object = @bucket.create_object File.basename(file)
    object.write File.read(file)
  end
end