Class: Backup::Configuration::Base

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Defined in:
lib/backup/configuration/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

generate_attributes

Constructor Details

#initialize(trigger) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# File 'lib/backup/configuration/base.rb', line 9

def initialize(trigger)
  @trigger = trigger
  @adapter_configuration = Backup::Configuration::Adapter.new
  @storage_configuration = Backup::Configuration::Storage.new
  @compressor = :gzip
end

Instance Attribute Details

#adapter_nameObject

Returns the value of attribute adapter_name.



7
8
9
# File 'lib/backup/configuration/base.rb', line 7

def adapter_name
  @adapter_name
end

#storage_nameObject

Returns the value of attribute storage_name.



7
8
9
# File 'lib/backup/configuration/base.rb', line 7

def storage_name
  @storage_name
end

#triggerObject

Returns the value of attribute trigger.



7
8
9
# File 'lib/backup/configuration/base.rb', line 7

def trigger
  @trigger
end

Instance Method Details

#adapter(adapter, &block) ⇒ Object



16
17
18
19
# File 'lib/backup/configuration/base.rb', line 16

def adapter(adapter, &block)
  @adapter_name = adapter
  @adapter_configuration.instance_eval &block
end

#compressor(compressor) ⇒ Object



26
27
28
# File 'lib/backup/configuration/base.rb', line 26

def compressor(compressor)
  @compressor = compressor
end

#compressor_classObject



52
53
54
55
56
57
# File 'lib/backup/configuration/base.rb', line 52

def compressor_class
  case @compressor.to_sym
    when :gzip       then Backup::Compressors::Gzip
    when :seven_zip  then Backup::Compressors::SevenZip 
  end
end

#get_adapter_configurationObject



68
69
70
# File 'lib/backup/configuration/base.rb', line 68

def get_adapter_configuration
  @adapter_configuration
end

#get_storage_configurationObject



72
73
74
# File 'lib/backup/configuration/base.rb', line 72

def get_storage_configuration
  @storage_configuration
end

#initialize_recordObject



64
65
66
# File 'lib/backup/configuration/base.rb', line 64

def initialize_record
  record_class.new
end

#initialize_storage(adapter) ⇒ Object

Initializes the storing process depending on the store settings



60
61
62
# File 'lib/backup/configuration/base.rb', line 60

def initialize_storage(adapter)
  storage_class.new(adapter)
end

#record_classObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/backup/configuration/base.rb', line 41

def record_class
  case @storage_name.to_sym
    when :cloudfiles then Backup::Record::CloudFiles
    when :s3         then Backup::Record::S3
    when :scp        then Backup::Record::SCP
    when :ftp        then Backup::Record::FTP
    when :sftp       then Backup::Record::SFTP
    when :local      then Backup::Record::Local
  end        
end

#storage(storage, &block) ⇒ Object



21
22
23
24
# File 'lib/backup/configuration/base.rb', line 21

def storage(storage, &block)
  @storage_name = storage
  @storage_configuration.instance_eval &block
end

#storage_classObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/backup/configuration/base.rb', line 30

def storage_class
  case @storage_name.to_sym
    when :cloudfiles then Backup::Storage::CloudFiles
    when :s3         then Backup::Storage::S3
    when :scp        then Backup::Storage::SCP
    when :ftp        then Backup::Storage::FTP
    when :sftp       then Backup::Storage::SFTP
    when :local      then Backup::Storage::Local
  end
end