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
51 52 53 |
# File 'lib/devkitkat/config.rb', line 51 def application devkitkat_yml.fetch('application', DEFAULT_APPLICATION_NAME) end |
#environment_type ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/devkitkat/config.rb', line 39 def environment_type if devkitkat_yml.key?('image') 'docker' else 'local' end end |
#image ⇒ Object
47 48 49 |
# File 'lib/devkitkat/config.rb', line 47 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 36 37 |
# 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 services = find_comma_separated_services(target) services elsif service = find_service(target) [service] else raise_error(target) end services = services - exclude if exclude services end |
#service_hash(name) ⇒ Object
59 60 61 |
# File 'lib/devkitkat/config.rb', line 59 def service_hash(name) devkitkat_yml.dig('services', name) || {} end |
#variables ⇒ Object
55 56 57 |
# File 'lib/devkitkat/config.rb', line 55 def variables devkitkat_yml.fetch('variables', {}) end |