Class: Config
- Inherits:
-
Object
- Object
- Config
- Defined in:
- lib/core/config.rb
Constant Summary collapse
- CONFIG_FILE_LOCATIION =
".controlplane/controlplane.yml"
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#app_dir ⇒ Object
readonly
Returns the value of attribute app_dir.
-
#apps ⇒ Object
readonly
Returns the value of attribute apps.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#org ⇒ Object
readonly
Returns the value of attribute org.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #app_cpln_dir ⇒ Object
-
#initialize(args, options) ⇒ Config
constructor
A new instance of Config.
- #script_path ⇒ Object
Constructor Details
#initialize(args, options) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/core/config.rb', line 11 def initialize(args, ) @args = args = @org = [:org] @app = [:app] load_app_config @apps = config[:apps] pick_current_config if app if current end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/core/config.rb', line 4 def app @app end |
#app_dir ⇒ Object (readonly)
Returns the value of attribute app_dir.
4 5 6 |
# File 'lib/core/config.rb', line 4 def app_dir @app_dir end |
#apps ⇒ Object (readonly)
Returns the value of attribute apps.
4 5 6 |
# File 'lib/core/config.rb', line 4 def apps @apps end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/core/config.rb', line 4 def args @args end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/core/config.rb', line 4 def config @config end |
#current ⇒ Object (readonly)
Returns the value of attribute current.
4 5 6 |
# File 'lib/core/config.rb', line 4 def current @current end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/core/config.rb', line 4 def end |
#org ⇒ Object (readonly)
Returns the value of attribute org.
4 5 6 |
# File 'lib/core/config.rb', line 4 def org @org end |
Instance Method Details
#[](key) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/core/config.rb', line 25 def [](key) ensure_current_config! old_key = old_option_keys[key] if current.key?(key) current.fetch(key) elsif old_key && current.key?(old_key) current.fetch(old_key) else raise "Can't find option '#{key}' for app '#{app}' in 'controlplane.yml'." end end |
#app_cpln_dir ⇒ Object
42 43 44 |
# File 'lib/core/config.rb', line 42 def app_cpln_dir "#{app_dir}/.controlplane" end |
#script_path ⇒ Object
38 39 40 |
# File 'lib/core/config.rb', line 38 def script_path Pathname.new(__dir__).parent.parent end |