Class: Lono::Setting
- Inherits:
-
Object
- Object
- Lono::Setting
- Defined in:
- lib/lono/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
- #data ⇒ Object
-
#initialize(check_lono_project = true) ⇒ Setting
constructor
A new instance of Setting.
- #lookup_project_settings_path ⇒ Object
Constructor Details
#initialize(check_lono_project = true) ⇒ Setting
Returns a new instance of Setting.
5 6 7 |
# File 'lib/lono/setting.rb', line 5 def initialize(check_lono_project=true) @check_lono_project = check_lono_project end |
Instance Method Details
#data ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lono/setting.rb', line 12 def data return @@data if @@data project_settings_path = lookup_project_settings_path # project based settings files project = load_file(project_settings_path) user_file = "#{ENV['HOME']}/.lono/settings.yml" user = load_file(user_file) default_file = File.("../default/settings.yml", __FILE__) default = load_file(default_file) all_envs = default.deep_merge(user.deep_merge(project)) all_envs = merge_base(all_envs) @@data = all_envs[Lono.env] || all_envs["base"] || {} end |
#lookup_project_settings_path ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/lono/setting.rb', line 31 def lookup_project_settings_path standalone_path = "#{Lono.root}/config/settings.yml" multimode_path = "#{Lono.root}/configs/settings.yml" parent_multimode_path = "#{Lono.root}/../../configs/settings.yml" settings_path = if File.exist?(standalone_path) standalone_path elsif File.exist?(multimode_path) multimode_path elsif File.exist?(parent_multimode_path) parent_multimode_path end if @check_lono_project && !settings_path puts "ERROR: No lono settings file found. Are you sure you are in a project with lono setup?".color(:red) exit 1 end settings_path end |