Class: Ufo::Setting
- Inherits:
-
Object
- Object
- Ufo::Setting
- Defined in:
- lib/ufo/setting.rb
Instance Method Summary collapse
-
#data ⇒ Object
data contains the settings.yml config.
-
#initialize(check_ufo_project = true) ⇒ Setting
constructor
A new instance of Setting.
Constructor Details
#initialize(check_ufo_project = true) ⇒ Setting
Returns a new instance of Setting.
5 6 7 |
# File 'lib/ufo/setting.rb', line 5 def initialize(check_ufo_project=true) @check_ufo_project = check_ufo_project end |
Instance Method Details
#data ⇒ Object
data contains the settings.yml config. The order or precedence for settings is the project ufo/settings.yml and then the ~/.ufo/settings.yml.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ufo/setting.rb', line 11 def data return @settings_yaml if @settings_yaml if @check_ufo_project && !File.exist?(project_settings_path) puts "ERROR: No settings file at #{project_settings_path}. Are you sure you are in a project with ufo setup?" puts "If you want to set up ufo for this prjoect, please create a settings file via: ufo init" exit 1 end # project based settings files project = load_file(project_settings_path) user_file = "#{ENV['HOME']}/.ufo/settings.yml" user = File.exist?(user_file) ? YAML.load_file(user_file) : {} default_file = File.("../default/settings.yml", __FILE__) default = YAML.load_file(default_file) @settings_yaml = default.deep_merge(user.deep_merge(project))[Ufo.env] end |