Module: Woli::Config

Defined in:
lib/woli/config.rb

Constant Summary collapse

CONFIG_FILE_NAME =
"#{ENV['HOME']}/.woli/config.yml"
CONFIG_TEMPLATE_FILE_NAME =
File.join(File.dirname(__FILE__),
'../../templates/default_config.yml')

Class Method Summary collapse

Class Method Details

.create_config_file_from_templateObject



17
18
19
20
21
22
23
24
25
# File 'lib/woli/config.rb', line 17

def self.create_config_file_from_template
  unless File.exists?(CONFIG_FILE_NAME)
    FileUtils.mkdir_p(File.dirname(CONFIG_FILE_NAME))
    FileUtils.cp(CONFIG_TEMPLATE_FILE_NAME, CONFIG_FILE_NAME)
    CONFIG_FILE_NAME
  else
    nil
  end
end

.load_configObject



9
10
11
12
13
14
15
# File 'lib/woli/config.rb', line 9

def self.load_config
  if File.exists?(CONFIG_FILE_NAME)
    YAML.load_file(CONFIG_FILE_NAME)
  else
    raise ConfigError, "Woli not yet initialized. Run 'woli help init' for more info."
  end
end