Module: ErbHiera

Defined in:
lib/erb-hiera.rb,
lib/erb-hiera/cli.rb,
lib/erb-hiera/hiera.rb,
lib/erb-hiera/version.rb,
lib/erb-hiera/manifest.rb,
lib/erb-hiera/directory.rb

Defined Under Namespace

Modules: CLI, Directory, Hiera, Manifest

Constant Summary collapse

VERSION =
"0.4.4"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/erb-hiera.rb', line 15

def options
  @options
end

.scopeObject

Returns the value of attribute scope.



15
16
17
# File 'lib/erb-hiera.rb', line 15

def scope
  @scope
end

Class Method Details

.runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/erb-hiera.rb', line 18

def self.run
  @options = CLI.parse

  mappings.each do |mapping|
    ErbHiera.scope  = mapping["scope"]
    input           = mapping["dir"]["input"]
    output          = mapping["dir"]["output"]

    [:input, :output].each do |location|
      raise StandardError, "error: undefined #{dir.to_s.split('_')[0]}put" unless binding.local_variable_get(location)
    end

    # if input is a file then out_file is a file too
    if input =~ /.erb$/
      generate(output, input)
      next
    end

    # otherwise the input/output are directories and all files should be processed..
    manifests(input).each do |manifest|
      out_file = File.join(output, manifest.gsub(input, ""))
      generate(out_file, manifest)
    end
  end
rescue => error
  handle_error(error)
  exit 1
end