class Hieracles::Hiera

Public Class Methods

new(config) click to toggle source
# File lib/hieracles/hiera.rb, line 4
def initialize(config)
  @config = config
  raise IOError, "Hierafile #{@config.hierafile} not found." unless File.exist? @config.hierafile
  @hierafile = @config.hierafile
  @loaded = YAML.load_file(@hierafile)
end

Public Instance Methods

datadir() click to toggle source
# File lib/hieracles/hiera.rb, line 22
def datadir
  @loaded[:yaml][:datadir]
end
datapath() click to toggle source
# File lib/hieracles/hiera.rb, line 11
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
hierarchy() click to toggle source
# File lib/hieracles/hiera.rb, line 18
def hierarchy
  @loaded[:hierarchy]
end
merge_behavior() click to toggle source
# File lib/hieracles/hiera.rb, line 30
def merge_behavior
  case @loaded[:merge_behavior]
  when :deep,'deep',:deeper,'deeper'
    @loaded[:merge_behavior].to_sym
  else
    :native
  end
end
params() click to toggle source
# File lib/hieracles/hiera.rb, line 26
def params
  hierarchy.join(',').scan(/%\{(?:::)?([^\}]*)\}/).flatten.uniq
end