Class: Backup::Connection::CloudFiles
- Inherits:
-
Object
- Object
- Backup::Connection::CloudFiles
- Defined in:
- lib/backup/connection/cloudfiles.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#cf_container ⇒ Object
Returns the value of attribute cf_container.
-
#final_file ⇒ Object
Returns the value of attribute final_file.
-
#procedure ⇒ Object
Returns the value of attribute procedure.
-
#tmp_path ⇒ Object
Returns the value of attribute tmp_path.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#connect ⇒ Object
Establishes a connection with Rackspace Cloud Files using the credentials provided by the user.
-
#connection ⇒ Object
Wrapper for the Connection object.
-
#container ⇒ Object
Wrapper for the Container object.
-
#destroy(file, c) ⇒ Object
Destroys file from a bucket on Amazon S3.
-
#initialize(adapter = false) ⇒ CloudFiles
constructor
Initializes the Cloud Files connection, setting the values using the Cloud Files adapter.
-
#static_initialize(procedure) ⇒ Object
Sets values from a procedure, rather than from the adapter object.
-
#store ⇒ Object
Initializes the file transfer to Rackspace Cloud Files This can only run after a connection has been made using the #connect method.
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
#adapter ⇒ Object
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/backup/connection/cloudfiles.rb', line 7 def adapter @adapter end |
#api_key ⇒ Object
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_container ⇒ Object
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_file ⇒ Object
Returns the value of attribute final_file.
7 8 9 |
# File 'lib/backup/connection/cloudfiles.rb', line 7 def final_file @final_file end |
#procedure ⇒ Object
Returns the value of attribute procedure.
7 8 9 |
# File 'lib/backup/connection/cloudfiles.rb', line 7 def procedure @procedure end |
#tmp_path ⇒ Object
Returns the value of attribute tmp_path.
7 8 9 |
# File 'lib/backup/connection/cloudfiles.rb', line 7 def tmp_path @tmp_path end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/backup/connection/cloudfiles.rb', line 7 def username @username end |
Instance Method Details
#connect ⇒ Object
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 |
#connection ⇒ Object
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 |
#container ⇒ Object
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 |
#store ⇒ Object
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 |