Class: Hieracles::Hiera
- Inherits:
-
Object
- Object
- Hieracles::Hiera
- Defined in:
- lib/hieracles/hiera.rb
Instance Method Summary collapse
- #datadir ⇒ Object
- #datapath ⇒ Object
- #hierarchy ⇒ Object
-
#initialize(config) ⇒ Hiera
constructor
A new instance of Hiera.
- #merge_behavior ⇒ Object
- #params ⇒ Object
Constructor Details
#initialize(config) ⇒ Hiera
Returns a new instance of Hiera.
4 5 6 7 8 9 |
# 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 |
Instance Method Details
#datadir ⇒ Object
22 23 24 |
# File 'lib/hieracles/hiera.rb', line 22 def datadir @loaded[:yaml][:datadir] end |
#datapath ⇒ Object
11 12 13 14 15 16 |
# File 'lib/hieracles/hiera.rb', line 11 def datapath raise TypeError, "Sorry hieracles only knows yaml backend for now." unless @loaded[:yaml] parampath = File.(File.join(@config.basepath, datadir)) raise IOError, "Params dir #{parampath} not found." unless Dir.exist? parampath parampath end |
#hierarchy ⇒ Object
18 19 20 |
# File 'lib/hieracles/hiera.rb', line 18 def hierarchy @loaded[:hierarchy] end |
#merge_behavior ⇒ Object
30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
26 27 28 |
# File 'lib/hieracles/hiera.rb', line 26 def params hierarchy.join(',').scan(/%\{(?:::)?([^\}]*)\}/).flatten.uniq end |