Class: Devkitkat::Config
- Inherits:
-
Object
- Object
- Devkitkat::Config
- Defined in:
- lib/devkitkat/config.rb
Constant Summary collapse
- DEVKITKAT_FILE_NAME =
'.devkitkat.yml'- HIDDEN_SERVICES =
%w[system]
Instance Attribute Summary collapse
-
#devkitkat_yml ⇒ Object
readonly
Returns the value of attribute devkitkat_yml.
-
#kit_root ⇒ Object
readonly
Returns the value of attribute kit_root.
Instance Method Summary collapse
- #all_services ⇒ Object
- #application ⇒ Object
- #environment_image ⇒ Object
- #environment_type ⇒ Object
-
#initialize(kit_root) ⇒ Config
constructor
A new instance of Config.
- #resolve!(target, exclude: nil) ⇒ Object
- #service_hash(name) ⇒ Object
- #variables ⇒ Object
Constructor Details
#initialize(kit_root) ⇒ Config
Returns a new instance of Config.
8 9 10 11 |
# File 'lib/devkitkat/config.rb', line 8 def initialize(kit_root) @kit_root = kit_root @devkitkat_yml = load_config end |
Instance Attribute Details
#devkitkat_yml ⇒ Object (readonly)
Returns the value of attribute devkitkat_yml.
6 7 8 |
# File 'lib/devkitkat/config.rb', line 6 def devkitkat_yml @devkitkat_yml end |
#kit_root ⇒ Object (readonly)
Returns the value of attribute kit_root.
6 7 8 |
# File 'lib/devkitkat/config.rb', line 6 def kit_root @kit_root end |
Instance Method Details
#all_services ⇒ Object
13 14 15 |
# File 'lib/devkitkat/config.rb', line 13 def all_services services + HIDDEN_SERVICES end |
#application ⇒ Object
43 44 45 |
# File 'lib/devkitkat/config.rb', line 43 def application devkitkat_yml.fetch('application', '') end |
#environment_image ⇒ Object
39 40 41 |
# File 'lib/devkitkat/config.rb', line 39 def environment_image devkitkat_yml.dig('environment', 'image') end |
#environment_type ⇒ Object
35 36 37 |
# File 'lib/devkitkat/config.rb', line 35 def environment_type devkitkat_yml.dig('environment', 'type') || 'local' end |
#resolve!(target, exclude: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/devkitkat/config.rb', line 17 def resolve!(target, exclude: nil) services = if target.nil? || target == 'system' %w[system] elsif target == 'all' all_services elsif group = find_group(target) services_for_group(group) elsif service = find_service(target) [service] else raise ArgumentError, "The target name #{target} couldn't be resolved" end services = services - exclude if exclude services end |
#service_hash(name) ⇒ Object
51 52 53 |
# File 'lib/devkitkat/config.rb', line 51 def service_hash(name) devkitkat_yml.dig('services', name) || {} end |
#variables ⇒ Object
47 48 49 |
# File 'lib/devkitkat/config.rb', line 47 def variables devkitkat_yml.fetch('variables', {}) end |