Sha256: bf352ba7881cbebd7f1f4b551ac1960c7d08d3372243019d49b10f60f506e5e5

Contents?: true

Size: 723 Bytes

Versions: 6

Compression:

Stored size: 723 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 datadir
      raise TypeError, "Sorry hieracles only knows yaml backend for now." unless @loaded[:yaml]
      parampath = File.expand_path(File.join(Config.basepath, @loaded[:yaml][:datadir]))
      raise IOError, "Params dir #{parampath} not found." unless Dir.exist? parampath
      parampath
    end

    def hierarchy
      @loaded[:hierarchy]
    end

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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hieracles-0.0.6 lib/hieracles/hiera.rb
hieracles-0.0.5 lib/hieracles/hiera.rb
hieracles-0.0.4 lib/hieracles/hiera.rb
hieracles-0.0.3 lib/hieracles/hiera.rb
hieracles-0.0.2 lib/hieracles/hiera.rb
hieracles-0.0.1 lib/hieracles/hiera.rb