Class: Backup::Connection::CloudFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/backup/connection/cloudfiles.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter = false) ⇒ CloudFiles

Initializes the Cloud Files connection, setting the values using the Cloud Files adapter



11
12
13
14
15
16
17
18
19
# File 'lib/backup/connection/cloudfiles.rb', line 11

def initialize(adapter = false)
  if adapter
    self.adapter            = adapter
    self.procedure          = adapter.procedure
    self.final_file         = adapter.final_file
    self.tmp_path           = adapter.tmp_path.gsub('\ ', ' ')
    load_storage_configuration_attributes
  end
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def adapter
  @adapter
end

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def api_key
  @api_key
end

#cf_containerObject

Returns the value of attribute cf_container.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def cf_container
  @cf_container
end

#final_fileObject

Returns the value of attribute final_file.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def final_file
  @final_file
end

#procedureObject

Returns the value of attribute procedure.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def procedure
  @procedure
end

#tmp_pathObject

Returns the value of attribute tmp_path.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def tmp_path
  @tmp_path
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/backup/connection/cloudfiles.rb', line 7

def username
  @username
end

Instance Method Details

#connectObject

Establishes a connection with Rackspace Cloud Files using the credentials provided by the user



29
30
31
# File 'lib/backup/connection/cloudfiles.rb', line 29

def connect
  connection
end

#connectionObject

Wrapper for the Connection object



34
35
36
# File 'lib/backup/connection/cloudfiles.rb', line 34

def connection
  ::CloudFiles::Connection.new(username, api_key)
end

#containerObject

Wrapper for the Container object



39
40
41
# File 'lib/backup/connection/cloudfiles.rb', line 39

def container
  connection.container(cf_container)
end

#destroy(file, c) ⇒ Object

Destroys file from a bucket on Amazon S3



51
52
53
54
# File 'lib/backup/connection/cloudfiles.rb', line 51

def destroy(file, c)
  c = connection.container(c)
  c.delete_object(file)
end

#static_initialize(procedure) ⇒ Object

Sets values from a procedure, rather than from the adapter object



22
23
24
25
# File 'lib/backup/connection/cloudfiles.rb', line 22

def static_initialize(procedure)
  self.procedure = procedure
  load_storage_configuration_attributes(true)
end

#storeObject

Initializes the file transfer to Rackspace Cloud Files This can only run after a connection has been made using the #connect method



45
46
47
48
# File 'lib/backup/connection/cloudfiles.rb', line 45

def store
  object = container.create_object(final_file)
  object.write(open(File.join(tmp_path, final_file)))
end