lib/hieracles/config.rb in hieracles-0.1.5 vs lib/hieracles/config.rb in hieracles-0.1.6
- old
+ new
@@ -13,12 +13,11 @@
:modulepath, :hierafile, :basepath, :encpath, :format, :interactive
def load(options)
@optionfile = options[:config] || defaultconfig
@extraparams = extract_params(options[:params])
- initconfig(@optionfile) unless File.exist? @optionfile
- values = YAML.load_file(@optionfile)
+ values = get_config(@optionfile)
@server = values['server']
@classpath = values['classpath']
@modulepath = values['modulepath'] || 'modules'
@encpath = options[:encpath] || values['encpath'] || 'enc'
@basepath = File.expand_path(options[:basepath] || values['basepath'] || '.')
@@ -26,9 +25,14 @@
@format = (options[:format] || values['format'] || 'console').capitalize
facts_file = options[:yaml_facts] || options[:json_facts]
facts_format = options[:json_facts] ? :json : :yaml
@scope = sym_keys((facts_file && load_facts(facts_file, facts_format)) || values['defaultscope'] || {})
@interactive = options[:interactive] || values['interactive']
+ end
+
+ def get_config(file)
+ initconfig(file) unless File.exist? file
+ values = YAML.load_file(file)
end
def initconfig(file)
FileUtils.mkdir_p(File.dirname(file))
File.open(file, 'w') do |f|