Class: Backup::Storage::Everbox

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/storage/everbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, storage_id = nil, &block) ⇒ Everbox

Returns a new instance of Everbox.



10
11
12
13
14
15
16
# File 'lib/backup/storage/everbox.rb', line 10

def initialize(model, storage_id = nil, &block)
  super(model, storage_id)

  @path ||= 'backups'

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/backup/storage/everbox.rb', line 8

def path
  @path
end

#secretObject

Returns the value of attribute secret.



7
8
9
# File 'lib/backup/storage/everbox.rb', line 7

def secret
  @secret
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/backup/storage/everbox.rb', line 7

def token
  @token
end

Instance Method Details

#remove!(pkg) ⇒ Object



18
19
20
21
22
23
# File 'lib/backup/storage/everbox.rb', line 18

def remove!(pkg)
  remote_path = remote_path_for(pkg)
  Logger.message "#{storage_name} started removing " +
        "'#{ remote_path }'."
  connection.session.delete(remote_path)
end

#transfer!Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/backup/storage/everbox.rb', line 25

def transfer!
  remote_path = remote_path_for(@package)

  files_to_transfer_for(@package) do |local_file, remote_file|
    Logger.message "#{storage_name} started transferring " +
        "'#{ local_file }'."
    connection.session.upload(
      File.join(local_path, local_file),
      File.join(remote_path, remote_file),
      :mode => :dropbox
      )


    #File.open(File.join(local_path, local_file), 'r') do |file|
    #  connection.put_object(
    #    bucket, File.join(remote_path, remote_file), file
    #  )
    #end
  end
end