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]- DEFAULT_APPLICATION_NAME =
'devkitkat'- DEFAULT_IMAGE =
'registry.gitlab.com/dosuken123/thin-gdk/thin-gdk-monolith:master'
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_type ⇒ Object
- #image ⇒ 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.
10 11 12 13 |
# File 'lib/devkitkat/config.rb', line 10 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.
8 9 10 |
# File 'lib/devkitkat/config.rb', line 8 def devkitkat_yml @devkitkat_yml end |
#kit_root ⇒ Object (readonly)
Returns the value of attribute kit_root.
8 9 10 |
# File 'lib/devkitkat/config.rb', line 8 def kit_root @kit_root end |
Instance Method Details
#all_services ⇒ Object
15 16 17 |
# File 'lib/devkitkat/config.rb', line 15 def all_services services + HIDDEN_SERVICES end |
#application ⇒ Object
49 50 51 |
# File 'lib/devkitkat/config.rb', line 49 def application devkitkat_yml.fetch('application', DEFAULT_APPLICATION_NAME) end |
#environment_type ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/devkitkat/config.rb', line 37 def environment_type if devkitkat_yml.key?('image') 'docker' else 'local' end end |
#image ⇒ Object
45 46 47 |
# File 'lib/devkitkat/config.rb', line 45 def image devkitkat_yml.fetch('image', DEFAULT_IMAGE) end |
#resolve!(target, exclude: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/devkitkat/config.rb', line 19 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
57 58 59 |
# File 'lib/devkitkat/config.rb', line 57 def service_hash(name) devkitkat_yml.dig('services', name) || {} end |
#variables ⇒ Object
53 54 55 |
# File 'lib/devkitkat/config.rb', line 53 def variables devkitkat_yml.fetch('variables', {}) end |