Sha256: 4079f742fbe8abad8f0c3005390f9ee3307ca77f3e3627b0d5a85ef9d3933558

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hieracles-0.1.2 lib/hieracles/hiera.rb
hieracles-0.1.1 lib/hieracles/hiera.rb
hieracles-0.1.0 lib/hieracles/hiera.rb