lib/hiera/config.rb
##
# load takes a string or hash as input, strings are treated as filenames
# hashes are stored as data that would have been in the config file
#
# Unless specified it will only use YAML as backend with a single
# 'common' hierarchy and console logger
#
# @return [Hash] representing the configuration.  e.g.
#   {:backends => "yaml", :hierarchy => "common"}
load takes a string or hash as input, strings are treated as filenames
hashes are stored as data that would have been in the config file

Unless specified it will only use YAML as backend with a single
'common' hierarchy and console logger
load takes a string or hash as input strings are treated as filenames hashes are stored as data that would have been in the config file Unless specified it will only use YAML as backend with a single ' common ' hierarchy and console logger
def load(source)
      @config = {:backends => "yaml",
                 :hierarchy => "common",
                 :merge_behavior => :native }
      if source.is_a?(String)
        if File.exist?(source)
          config = begin
                     yaml_load_file(source)
                   rescue TypeError => detail
                     case detail.message
                     when /no implicit conversion from nil to integer/
                       false
                     else
                       raise detail
                     end
                   end
          @config.merge! config if config
        else
          raise "Config file #{source} not found"
        end
      elsif source.is_a?(Hash)
        @config.merge! source
      end
      @config[:backends] = [ @config[:backends] ].flatten
      if @config.include?(:logger)
        Hiera.logger = @config[:logger].to_s
      else
        @config[:logger] = "console"
        Hiera.logger = "console"
      end
      @config
    end
def load ( source ) @config = { :backends => "yaml" , :hierarchy => "common" , :merge_behavior => :native } if source . is_a? ( String ) if File . exist? ( source ) config = begin yaml_load_file ( source ) rescue TypeError => detail case detail . message when / no implicit conversion from nil to integer / false else raise detail end end @config . merge! config if config else raise "Config file #{source} not found" end elsif source . is_a? ( Hash ) @config . merge! source end @config [ :backends ] = [ @config [ :backends ] ] . flatten if @config . include? ( :logger ) Hiera . logger = @config [ :logger ] . to_s else @config [ :logger ] = "console" Hiera . logger = "console" end @config end
load takes a string or hash as input, strings are treated as filenames
hashes are stored as data that would have been in the config file
load takes a string or hash as input strings are treated as filenames hashes are stored as data that would have been in the config file
representing the configuration. e.g. {:backends => "yaml", :hierarchy => "common"}
representing the configuration . e . g . { : backends = > " yaml " : hierarchy = > " common " }
Hash
source
<not_specific>