Class: Ufo::Settings
- Inherits:
-
Object
- Object
- Ufo::Settings
- Defined in:
- lib/ufo/settings.rb
Instance Method Summary collapse
-
#data ⇒ Object
data contains the settings.yml config.
-
#initialize(project_root = '.', check_ufo_project = true) ⇒ Settings
constructor
A new instance of Settings.
Constructor Details
#initialize(project_root = '.', check_ufo_project = true) ⇒ Settings
Returns a new instance of Settings.
5 6 7 8 |
# File 'lib/ufo/settings.rb', line 5 def initialize(project_root='.', check_ufo_project=true) @project_root = project_root @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.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ufo/settings.rb', line 12 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 "Please create a settings file via: ufo init" exit 1 end project = File.exist?(project_settings_path) ? YAML.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.merge(user.merge(project)) end |