Class: Bard::Backup
- Inherits:
-
Object
show all
- Defined in:
- lib/bard/backup.rb,
lib/bard/backup/s3_dir.rb,
lib/bard/backup/deleter.rb,
lib/bard/backup/version.rb,
lib/bard/backup/local_backhoe.rb,
lib/bard/backup/cached_local_backhoe.rb
Defined Under Namespace
Classes: CachedLocalBackhoe, Deleter, LocalBackhoe, S3Dir
Constant Summary
collapse
- VERSION =
"0.8.0"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ Backup
Returns a new instance of Backup.
15
16
17
|
# File 'lib/bard/backup.rb', line 15
def initialize config
@config = config
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
18
19
20
|
# File 'lib/bard/backup.rb', line 18
def config
@config
end
|
Class Method Details
.call(configs) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/bard/backup.rb', line 8
def self.call configs
configs = [configs] if configs.is_a?(Hash)
configs.each do |config|
new(config).call
end
end
|
Instance Method Details
#access_key ⇒ Object
42
43
44
|
# File 'lib/bard/backup.rb', line 42
def access_key
config[:access_key_id] || config[:access_key]
end
|
#call ⇒ Object
20
21
22
23
|
# File 'lib/bard/backup.rb', line 20
def call
strategy.call(s3_dir, now)
Deleter.new(s3_dir, now).call
end
|
#endpoint ⇒ Object
58
59
60
|
# File 'lib/bard/backup.rb', line 58
def endpoint
config.fetch(:endpoint, "https://s3.#{region}.amazonaws.com")
end
|
#now ⇒ Object
54
55
56
|
# File 'lib/bard/backup.rb', line 54
def now
@now ||= config.fetch(:now, Time.now.utc)
end
|
#path ⇒ Object
38
39
40
|
# File 'lib/bard/backup.rb', line 38
def path
config.fetch(:path)
end
|
#region ⇒ Object
50
51
52
|
# File 'lib/bard/backup.rb', line 50
def region
config.fetch(:region, "us-west-2")
end
|
#s3_dir ⇒ Object
25
26
27
|
# File 'lib/bard/backup.rb', line 25
def s3_dir
@s3_dir ||= S3Dir.new(endpoint:, path:, access_key:, secret_key:, region:)
end
|
#secret_key ⇒ Object
46
47
48
|
# File 'lib/bard/backup.rb', line 46
def secret_key
config[:secret_access_key] || config[:secret_key]
end
|
#strategy ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/bard/backup.rb', line 29
def strategy
return @strategy if @strategy
@strategy = config.fetch(:strategy, LocalBackhoe)
if @strategy.is_a?(String)
@strategy = Bard::Backup.const_get(@strategy)
end
@strategy
end
|