Class: Ufo::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/ufo/settings.rb

Instance Method Summary collapse

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

#dataObject

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 = .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_pathObject



29
30
31
# File 'lib/ufo/settings.rb', line 29

def settings_path
  "#{@project_root}/ufo/settings.yml"
end

#user_settingsObject



24
25
26
27
# File 'lib/ufo/settings.rb', line 24

def 
  path = "#{ENV['HOME']}/.ufo/settings.yml"
  File.exist?(path) ? YAML.load_file(path) : {}
end