Class: Poke::GroupConfig
- Inherits:
-
Object
- Object
- Poke::GroupConfig
- Defined in:
- lib/poke/group_config.rb
Defined Under Namespace
Classes: InvalidEnv
Class Method Summary collapse
Instance Method Summary collapse
- #default_env ⇒ Object
- #default_env=(value) ⇒ Object
- #envs ⇒ Object
-
#initialize(values = {}) ⇒ GroupConfig
constructor
A new instance of GroupConfig.
- #save_to(path) ⇒ Object
- #valid_env?(env) ⇒ Boolean
- #variables(env) ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ GroupConfig
Returns a new instance of GroupConfig.
13 14 15 |
# File 'lib/poke/group_config.rb', line 13 def initialize(values = {}) @values = values end |
Class Method Details
.from_path(path) ⇒ Object
9 10 11 |
# File 'lib/poke/group_config.rb', line 9 def self.from_path(path) new(JSON.parse(File.read(path))) end |
Instance Method Details
#default_env ⇒ Object
25 26 27 |
# File 'lib/poke/group_config.rb', line 25 def default_env @values.fetch('default_env', @values['envs'].keys.first) end |
#default_env=(value) ⇒ Object
29 30 31 32 33 |
# File 'lib/poke/group_config.rb', line 29 def default_env=(value) raise InvalidEnv unless valid_env?(value) @values['default_env'] = value end |
#envs ⇒ Object
35 36 37 |
# File 'lib/poke/group_config.rb', line 35 def envs @values['envs'].keys end |
#save_to(path) ⇒ Object
17 18 19 |
# File 'lib/poke/group_config.rb', line 17 def save_to(path) File.write(path, @values.to_json) end |
#valid_env?(env) ⇒ Boolean
21 22 23 |
# File 'lib/poke/group_config.rb', line 21 def valid_env?(env) @values['envs'].key?(env) end |
#variables(env) ⇒ Object
39 40 41 |
# File 'lib/poke/group_config.rb', line 39 def variables(env) @values['envs'][env] end |