lib/hieracles/config.rb in hieracles-0.1.2 vs lib/hieracles/config.rb in hieracles-0.1.3
- old
+ new
@@ -1,15 +1,17 @@
require 'fileutils'
require 'json'
require 'yaml'
+require 'hieracles/utils'
module Hieracles
# configuration singleton
module Config
+ include Hieracles::Utils
extend self
- attr_reader :extraparams, :server, :classpath, :facts,
+ attr_reader :extraparams, :server, :classpath, :scope,
:modulepath, :hierafile, :basepath, :encpath, :format
def load(options)
@optionfile = options[:config] || defaultconfig
@extraparams = extract_params(options[:params])
@@ -22,10 +24,10 @@
@basepath = File.expand_path(options[:basepath] || values['basepath'] || '.')
@hierafile = options[:hierafile] || values['hierafile'] || 'hiera.yaml'
@format = (options[:format] || values['format'] || 'console').capitalize
facts_file = options[:yaml_facts] || options[:json_facts]
facts_format = options[:json_facts] ? :json : :yaml
- @facts = (facts_file && load_facts(facts_file, facts_format)) || {}
+ @scope = sym_keys((facts_file && load_facts(facts_file, facts_format)) || values['defaultscope'] || {})
end
def initconfig(file)
FileUtils.mkdir_p(File.dirname(file))
File.open(file, 'w') do |f|