Class: Yle::AWS::Role::Config
- Inherits:
-
Struct
- Object
- Struct
- Yle::AWS::Role::Config
- Defined in:
- lib/yle/aws/role/config.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
Returns the value of attribute accounts.
-
#defaults ⇒ Object
Returns the value of attribute defaults.
Class Method Summary collapse
- .default_config ⇒ Object
- .default_config=(config) ⇒ Object
- .default_path ⇒ Object
- .load(paths = nil) ⇒ Object
- .load_yaml(path) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#accounts ⇒ Object
Returns the value of attribute accounts
6 7 8 |
# File 'lib/yle/aws/role/config.rb', line 6 def accounts @accounts end |
#defaults ⇒ Object
Returns the value of attribute defaults
6 7 8 |
# File 'lib/yle/aws/role/config.rb', line 6 def defaults @defaults end |
Class Method Details
.default_config ⇒ Object
11 12 13 |
# File 'lib/yle/aws/role/config.rb', line 11 def self.default_config @default_config ||= Config.new({}, {}) end |
.default_config=(config) ⇒ Object
15 16 17 |
# File 'lib/yle/aws/role/config.rb', line 15 def self.default_config=(config) @default_config = default_config.merge(config) end |
.default_path ⇒ Object
7 8 9 |
# File 'lib/yle/aws/role/config.rb', line 7 def self.default_path ENV.fetch('ASU_CONFIG') { File.join(Dir.home, '.aws', 'asu.yaml') } end |
.load(paths = nil) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/yle/aws/role/config.rb', line 19 def self.load(paths = nil) paths = Array(paths).push(default_path) paths.inject(default_config) do |config, path| config.merge(load_yaml(path)) end end |
.load_yaml(path) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/yle/aws/role/config.rb', line 26 def self.load_yaml(path) (path && File.exist?(path) && YAML.load_file(path)) || {} rescue StandardError STDERR.puts("WARN: Failed to load or parse configuration from '#{path}'") {} end |
Instance Method Details
#merge(config) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/yle/aws/role/config.rb', line 33 def merge(config) config ||= {} Config.new( accounts.merge(config['accounts'] || {}), defaults.merge(config['defaults'] || {}) ) end |