Class: Snapshoter::Config
- Inherits:
-
Object
- Object
- Snapshoter::Config
- Defined in:
- lib/snapshoter/config.rb
Instance Attribute Summary collapse
-
#aws_private_key ⇒ Object
readonly
Returns the value of attribute aws_private_key.
-
#aws_public_key ⇒ Object
readonly
Returns the value of attribute aws_public_key.
-
#volumes ⇒ Object
readonly
Returns the value of attribute volumes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ Config
constructor
A new instance of Config.
- #logger ⇒ Object
Constructor Details
#initialize(config) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/snapshoter/config.rb', line 11 def initialize(config) @aws_public_key = config.delete('aws_public_key') @aws_private_key = config.delete('aws_private_key') @log_file = config.delete('log_file') @log_level = config.delete('log_level') @volumes = [] config.keys.each do |volume_id| = config[volume_id] if .is_a? Hash begin @volumes << Snapshoter::Volume.new(volume_id, config[volume_id]) rescue Snapshoter::VolumeInvalid => e raise ConfigError.new(e.) end config.delete(volume_id) end end if config.any? raise ConfigError.new("Invalid config option(s) #{config.keys.map{|k| "'#{k}'"}.join(',')}") end end |
Instance Attribute Details
#aws_private_key ⇒ Object (readonly)
Returns the value of attribute aws_private_key.
9 10 11 |
# File 'lib/snapshoter/config.rb', line 9 def aws_private_key @aws_private_key end |
#aws_public_key ⇒ Object (readonly)
Returns the value of attribute aws_public_key.
9 10 11 |
# File 'lib/snapshoter/config.rb', line 9 def aws_public_key @aws_public_key end |
#volumes ⇒ Object (readonly)
Returns the value of attribute volumes.
9 10 11 |
# File 'lib/snapshoter/config.rb', line 9 def volumes @volumes end |
Class Method Details
Instance Method Details
#logger ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/snapshoter/config.rb', line 36 def logger @logger ||= begin logger = Logger.new(@log_file || STDOUT) logger.level = case @log_level when 'warn' Logger::WARN when 'error' Logger::ERROR when 'FATAL' Logger::FATAL when 'debug' Logger::DEBUG else Logger::INFO end logger end end |