Class: Yle::AWS::Role::Config
- Inherits:
-
Struct
- Object
- Struct
- Yle::AWS::Role::Config
- Defined in:
- lib/yle/aws/role/config.rb
Overview
rubocop:disable Metrics/BlockLength
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
7 8 9 |
# File 'lib/yle/aws/role/config.rb', line 7 def accounts @accounts end |
#defaults ⇒ Object
Returns the value of attribute defaults
7 8 9 |
# File 'lib/yle/aws/role/config.rb', line 7 def defaults @defaults end |
Class Method Details
.default_config ⇒ Object
12 13 14 |
# File 'lib/yle/aws/role/config.rb', line 12 def self.default_config @default_config ||= Config.new({}, {}) end |
.default_config=(config) ⇒ Object
16 17 18 |
# File 'lib/yle/aws/role/config.rb', line 16 def self.default_config=(config) @default_config = default_config.merge(config) end |
.default_path ⇒ Object
8 9 10 |
# File 'lib/yle/aws/role/config.rb', line 8 def self.default_path ENV.fetch('ASU_CONFIG') { File.join(Dir.home, '.aws', 'asu.yaml') } end |
.load(paths = nil) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/yle/aws/role/config.rb', line 20 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
27 28 29 30 31 32 |
# File 'lib/yle/aws/role/config.rb', line 27 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 |