Class: Forger::Setting

Inherits:
Object
  • Object
show all
Defined in:
lib/forger/setting.rb

Constant Summary collapse

@@data =

data contains the settings.yml config. The order or precedence for settings is the project lono/settings.yml and then the ~/.lono/settings.yml.

nil

Instance Method Summary collapse

Constructor Details

#initialize(check_project = true) ⇒ Setting

Returns a new instance of Setting.



5
6
7
# File 'lib/forger/setting.rb', line 5

def initialize(check_project=true)
  @check_project = check_project
end

Instance Method Details

#dataObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/forger/setting.rb', line 12

def data
  return @@data if @@data

  if @check_project && !File.exist?(project_settings_path)
    puts "ERROR: No settings file at #{project_settings_path}.  Are you sure you are in a forger project?".color(:red)
    exit 1
  end

  all_envs = load_file(project_settings_path)
  all_envs = merge_base(all_envs)
  @@data = all_envs[Forger.env] || all_envs["base"] || {}
  @@data
end