Sha256: 080fba78b4026e56aae9831601e3b506bc858cc22ca51c4cffc95ae831dca961

Contents?: true

Size: 932 Bytes

Versions: 4

Compression:

Stored size: 932 Bytes

Contents

module Hieracles
  class Hiera

    def initialize
      raise IOError, "Hierafile #{Config.hierafile} not found." unless File.exist? Config.hierafile
      @hierafile = Config.hierafile
      @loaded = YAML.load_file(@hierafile)
    end

    def datapath
      raise TypeError, "Sorry hieracles only knows yaml backend for now." unless @loaded[:yaml]
      parampath = File.expand_path(File.join(Config.basepath, datadir))
      raise IOError, "Params dir #{parampath} not found." unless Dir.exist? parampath
      parampath
    end

    def hierarchy
      @loaded[:hierarchy]
    end

    def datadir
      @loaded[:yaml][:datadir]
    end

    def params
      hierarchy.join(',').scan(/%\{(?:::)?([^\}]*)\}/).flatten.uniq
    end

    def merge_behavior
      case @loaded[:merge_behavior]
      when :deep,'deep',:deeper,'deeper'
        @loaded[:merge_behavior].to_sym
      else
        :native
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hieracles-0.3.0 lib/hieracles/hiera.rb
hieracles-0.2.2 lib/hieracles/hiera.rb
hieracles-0.2.1 lib/hieracles/hiera.rb
hieracles-0.2.0 lib/hieracles/hiera.rb