Class: Config

Inherits:
Object
  • Object
show all
Defined in:
lib/core/config.rb

Constant Summary collapse

CONFIG_FILE_LOCATIION =
".controlplane/controlplane.yml"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
17
18
19
# File 'lib/core/config.rb', line 11

def initialize(args, options)
  @args = args
  @options = options
  @org = options[:org]
  @app = options[:app]

  load_app_config
  load_apps
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



4
5
6
# File 'lib/core/config.rb', line 4

def app
  @app
end

#app_dirObject (readonly)

Returns the value of attribute app_dir.



4
5
6
# File 'lib/core/config.rb', line 4

def app_dir
  @app_dir
end

#appsObject (readonly)

Returns the value of attribute apps.



4
5
6
# File 'lib/core/config.rb', line 4

def apps
  @apps
end

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/core/config.rb', line 4

def args
  @args
end

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/core/config.rb', line 4

def config
  @config
end

#currentObject (readonly)

Returns the value of attribute current.



4
5
6
# File 'lib/core/config.rb', line 4

def current
  @current
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/core/config.rb', line 4

def options
  @options
end

#orgObject (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



21
22
23
24
25
26
27
# File 'lib/core/config.rb', line 21

def [](key)
  ensure_current_config!

  raise "Can't find option '#{key}' for app '#{app}' in 'controlplane.yml'." unless current.key?(key)

  current.fetch(key)
end

#app_cpln_dirObject



33
34
35
# File 'lib/core/config.rb', line 33

def app_cpln_dir
  "#{app_dir}/.controlplane"
end

#script_pathObject



29
30
31
# File 'lib/core/config.rb', line 29

def script_path
  Pathname.new(__dir__).parent.parent
end