Sha256: 0b84e19e3f399c7b41e5685493b67dbfcdaee76a5097947bf531663020d7a642

Contents?: true

Size: 948 Bytes

Versions: 2

Compression:

Stored size: 948 Bytes

Contents

module Hieracles
  class Hiera

    def initialize
      raise IOError, "Hierafile #{Config.hierafile} not found." unless File.exist? Config.path('hierafile')
      @hierafile = Config.path('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

2 entries across 2 versions & 1 rubygems

Version Path
hieracles-0.1.7 lib/hieracles/hiera.rb
hieracles-0.1.6 lib/hieracles/hiera.rb