Class: Backup::Connection::Dropbox

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter = false) ⇒ Dropbox

Returns a new instance of Dropbox.



9
10
11
12
13
14
15
16
17
18
# File 'lib/backup/connection/dropbox.rb', line 9

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/dropbox.rb', line 7

def adapter
  @adapter
end

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#final_fileObject

Returns the value of attribute final_file.



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

def final_file
  @final_file
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#procedureObject

Returns the value of attribute procedure.



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

def procedure
  @procedure
end

#secret_access_keyObject

Returns the value of attribute secret_access_key.



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

def secret_access_key
  @secret_access_key
end

#tmp_pathObject

Returns the value of attribute tmp_path.



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

def tmp_path
  @tmp_path
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#connectObject



36
37
38
# File 'lib/backup/connection/dropbox.rb', line 36

def connect
  session
end

#sessionObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/backup/connection/dropbox.rb', line 25

def session
  @session ||= ::Dropbox::Session.new(api_key, secret_access_key)
  unless @session.authorized?
    @session.authorizing_user = username
    @session.authorizing_password = password
    @session.authorize!
  end

  @session
end

#static_initialize(procedure) ⇒ Object



20
21
22
23
# File 'lib/backup/connection/dropbox.rb', line 20

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

#storeObject



44
45
46
47
# File 'lib/backup/connection/dropbox.rb', line 44

def store
  path_to_file = File.join(tmp_path, final_file)
  session.upload(path_to_file, path, :mode => :dropbox)
end