erb-hiera 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erb-hiera.rb +26 -16
- data/lib/erb-hiera/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc6d4ae917342fbb62b9debfdcc027099284d98a
|
4
|
+
data.tar.gz: b00a638a52371b3cb53622aed168a2964a025214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5acefa45f15ca30d341c8718d84b904d5bd0292d7f33d5875db10e2ace2e28425c23141bcea0492109a3d90b338c713308232128af22aa1b878e8b020c1e5a6
|
7
|
+
data.tar.gz: 33abb2397e7cdac18f735d04660be51c2d0a71609fac1920e65cad7af176c9bf26f97e29ac4ec4f2a737fbefc73950da1d3908d1dfe4f2cff08864210964c731
|
data/lib/erb-hiera.rb
CHANGED
@@ -20,26 +20,23 @@ module ErbHiera
|
|
20
20
|
|
21
21
|
mappings.each do |mapping|
|
22
22
|
ErbHiera.scope = mapping["scope"]
|
23
|
-
|
24
|
-
|
23
|
+
input = mapping["dir"]["input"]
|
24
|
+
output = mapping["dir"]["output"]
|
25
25
|
|
26
|
-
[:
|
27
|
-
raise StandardError, "error: undefined #{dir.to_s.split('_')[0]}put
|
26
|
+
[:input, :output].each do |location|
|
27
|
+
raise StandardError, "error: undefined #{dir.to_s.split('_')[0]}put" unless binding.local_variable_get(location)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
erb = ERB.new(File.read(manifest), nil, "-").result(Hiera.get_binding)
|
36
|
-
|
37
|
-
puts erb if options[:verbose]
|
30
|
+
# if input is a file then out_file is a file too
|
31
|
+
if input =~ /.erb$/
|
32
|
+
generate(output, input)
|
33
|
+
next
|
34
|
+
end
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
# otherwise the input/output are directories and all files should be processed..
|
37
|
+
manifests(input).each do |manifest|
|
38
|
+
out_file = File.join(output, manifest.gsub(input, ""))
|
39
|
+
generate(out_file, manifest)
|
43
40
|
end
|
44
41
|
end
|
45
42
|
rescue => error
|
@@ -49,6 +46,19 @@ module ErbHiera
|
|
49
46
|
|
50
47
|
private
|
51
48
|
|
49
|
+
def self.generate(out_file, manifest)
|
50
|
+
Manifest.info(manifest, out_file) if options[:verbose]
|
51
|
+
|
52
|
+
erb = ERB.new(File.read(manifest), nil, "-").result(Hiera.get_binding)
|
53
|
+
|
54
|
+
puts erb if options[:verbose]
|
55
|
+
|
56
|
+
unless options[:dry_run]
|
57
|
+
FileUtils.mkdir_p File.dirname(out_file) unless Dir.exists?(File.dirname(out_file))
|
58
|
+
File.write(out_file, erb)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
52
62
|
def self.handle_error(error)
|
53
63
|
if options[:debug]
|
54
64
|
puts
|
data/lib/erb-hiera/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erb-hiera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hiera
|