Class: S3Backup::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_backup/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.aws_access_key_idObject

Returns the value of attribute aws_access_key_id.



17
18
19
# File 'lib/s3_backup/config.rb', line 17

def aws_access_key_id
  @aws_access_key_id
end

.aws_regionObject

Returns the value of attribute aws_region.



20
21
22
# File 'lib/s3_backup/config.rb', line 20

def aws_region
  @aws_region
end

.aws_secret_access_keyObject

Returns the value of attribute aws_secret_access_key.



18
19
20
# File 'lib/s3_backup/config.rb', line 18

def aws_secret_access_key
  @aws_secret_access_key
end

.bucketObject

Returns the value of attribute bucket.



19
20
21
# File 'lib/s3_backup/config.rb', line 19

def bucket
  @bucket
end

.pg_hostObject

Returns the value of attribute pg_host.



13
14
15
# File 'lib/s3_backup/config.rb', line 13

def pg_host
  @pg_host
end

.pg_passwordObject

Returns the value of attribute pg_password.



15
16
17
# File 'lib/s3_backup/config.rb', line 15

def pg_password
  @pg_password
end

.pg_userObject

Returns the value of attribute pg_user.



14
15
16
# File 'lib/s3_backup/config.rb', line 14

def pg_user
  @pg_user
end

.redis_dump_pathObject

Returns the value of attribute redis_dump_path.



16
17
18
# File 'lib/s3_backup/config.rb', line 16

def redis_dump_path
  @redis_dump_path
end

.s3_keepObject

Returns the value of attribute s3_keep.



23
24
25
# File 'lib/s3_backup/config.rb', line 23

def s3_keep
  @s3_keep
end

.s3_pg_pathObject

Returns the value of attribute s3_pg_path.



21
22
23
# File 'lib/s3_backup/config.rb', line 21

def s3_pg_path
  @s3_pg_path
end

.s3_redis_pathObject

Returns the value of attribute s3_redis_path.



22
23
24
# File 'lib/s3_backup/config.rb', line 22

def s3_redis_path
  @s3_redis_path
end

.tablesObject

Returns the value of attribute tables.



24
25
26
# File 'lib/s3_backup/config.rb', line 24

def tables
  @tables
end

Class Method Details

.config(*args) ⇒ Object



56
57
58
59
60
# File 'lib/s3_backup/config.rb', line 56

def config(*args)
  args.inject(@configuration) do |hash, key|
    (hash.is_a?(Hash) && hash[key]) || nil
  end
end

.load!(file_path) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/s3_backup/config.rb', line 26

def load!(file_path)
  template       = ERB.new File.new(file_path).read
  @configuration = YAML.load(template.result(binding))

  self.pg_host     = config('pg_database', 'host')
  self.pg_user     = config('pg_database', 'user')
  self.pg_password = config('pg_database', 'password')

  self.redis_dump_path = config('redis', 'dump_path')

  self.aws_access_key_id     = config('s3', 'aws_access_key_id')
  self.aws_secret_access_key = config('s3', 'aws_secret_access_key')
  self.bucket                = config('s3', 'bucket')
  self.aws_region            = config('s3', 'aws_region')
  self.s3_keep               = config('s3', 'keep')
  self.s3_pg_path            = config('s3', 'pg_path')
  self.s3_redis_path         = config('s3', 'redis_path')

  self.tables = config('tables') || {}

  true
end

.requires!(*args) ⇒ Object



49
50
51
52
53
54
# File 'lib/s3_backup/config.rb', line 49

def requires!(*args)
  args.each do |argv|
    raise "Configuration missing: #{argv}" unless Config.send(argv)
  end
  true
end