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 = '.') ⇒ Settings
constructor
A new instance of Settings.
- #settings_path ⇒ Object
- #user_settings ⇒ Object
Constructor Details
#initialize(project_root = '.') ⇒ Settings
Returns a new instance of Settings.
5 6 7 |
# File 'lib/ufo/settings.rb', line 5 def initialize(project_root='.') @project_root = project_root 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 |
# File 'lib/ufo/settings.rb', line 11 def data return @data if @data if File.exist?(settings_path) @data = YAML.load_file(settings_path) @data = user_settings.merge(@data) else puts "ERROR: No settings file at #{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 end |
#settings_path ⇒ Object
29 30 31 |
# File 'lib/ufo/settings.rb', line 29 def settings_path "#{@project_root}/ufo/settings.yml" end |
#user_settings ⇒ Object
24 25 26 27 |
# File 'lib/ufo/settings.rb', line 24 def user_settings path = "#{ENV['HOME']}/.ufo/settings.yml" File.exist?(path) ? YAML.load_file(path) : {} end |