Class: StackMaster::Config
- Inherits:
-
Object
- Object
- StackMaster::Config
- Defined in:
- lib/stack_master/config.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#region_aliases ⇒ Object
Returns the value of attribute region_aliases.
-
#region_defaults ⇒ Object
Returns the value of attribute region_defaults.
-
#stack_defaults ⇒ Object
Returns the value of attribute stack_defaults.
-
#stacks ⇒ Object
Returns the value of attribute stacks.
Class Method Summary collapse
Instance Method Summary collapse
- #find_stack(region, stack_name) ⇒ Object
-
#initialize(config, base_dir) ⇒ Config
constructor
A new instance of Config.
- #unalias_region(region) ⇒ Object
Constructor Details
#initialize(config, base_dir) ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stack_master/config.rb', line 18 def initialize(config, base_dir) @config = config @base_dir = base_dir @stack_defaults = config.fetch('stack_defaults', {}) @region_aliases = Utils.underscore_keys_to_hyphen(config.fetch('region_aliases', {})) @region_to_aliases = @region_aliases.inject({}) do |hash, (key, value)| hash[value] ||= [] hash[value] << key hash end @region_defaults = normalise_region_defaults(config.fetch('region_defaults', {})) @stacks = [] load_config end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
12 13 14 |
# File 'lib/stack_master/config.rb', line 12 def base_dir @base_dir end |
#region_aliases ⇒ Object
Returns the value of attribute region_aliases.
12 13 14 |
# File 'lib/stack_master/config.rb', line 12 def region_aliases @region_aliases end |
#region_defaults ⇒ Object
Returns the value of attribute region_defaults.
12 13 14 |
# File 'lib/stack_master/config.rb', line 12 def region_defaults @region_defaults end |
#stack_defaults ⇒ Object
Returns the value of attribute stack_defaults.
12 13 14 |
# File 'lib/stack_master/config.rb', line 12 def stack_defaults @stack_defaults end |
#stacks ⇒ Object
Returns the value of attribute stacks.
12 13 14 |
# File 'lib/stack_master/config.rb', line 12 def stacks @stacks end |
Class Method Details
.load!(config_file = 'stack_master.yml') ⇒ Object
6 7 8 9 10 |
# File 'lib/stack_master/config.rb', line 6 def self.load!(config_file = 'stack_master.yml') config = YAML.load(File.read(config_file)) base_dir = File.dirname(File.(config_file)) new(config, base_dir) end |
Instance Method Details
#find_stack(region, stack_name) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/stack_master/config.rb', line 33 def find_stack(region, stack_name) @stacks.find do |s| (s.region == region || s.region == region.gsub('_', '-')) && (s.stack_name == stack_name || s.stack_name == stack_name.gsub('_', '-')) end end |
#unalias_region(region) ⇒ Object
40 41 42 |
# File 'lib/stack_master/config.rb', line 40 def unalias_region(region) @region_aliases.fetch(region) { region } end |