erber 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erber/cli.rb +17 -1
- data/lib/erber/version.rb +1 -1
- data/test-data/props1.yaml +3 -1
- data/test-data/test.erb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e87ce83e90a4a879cd85cae5712d3f9e127d7c
|
4
|
+
data.tar.gz: 56b50895bd0d6142b0af86f930193f600c313969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f8668a674c24b5fb991b54991fa8b9ca4a6e77700cdf9cf02ecc1c36006dff48b0f0b6b1376d97140d81dabf2ad0158fbf9c838746e631cf8380c439f548d87
|
7
|
+
data.tar.gz: 29b9d74e20ea3d8b5c21ef8f872bab0e5e68182ef4b091ee1edd2475283e21efd34396ccccc5f3407fee63439ba910fbc3bc62ddf3ac60bf69fe4f29038b4881
|
data/lib/erber/cli.rb
CHANGED
@@ -11,13 +11,14 @@ module Erber
|
|
11
11
|
def self.go
|
12
12
|
parser = Trollop::Parser.new do
|
13
13
|
opt :property_file, "Property file to include (JSON or YAML)", :type => :string, :multi => true
|
14
|
+
opt :override_property, "'dotted.key.name=value' property to inject.", :type => :string, :multi => true
|
14
15
|
end
|
15
16
|
|
16
17
|
opts = parser.parse(ARGV)
|
17
18
|
filenames = parser.leftovers
|
18
19
|
|
19
20
|
if filenames.length != 1
|
20
|
-
$stderr.puts "Usage: erber [-p props1.yaml [-p props2.json [...]]] template.erb"
|
21
|
+
$stderr.puts "Usage: erber [-p props1.yaml [-p props2.json [...]]] [-o foo=bar [-o baz.boop=beep [...]]] template.erb"
|
21
22
|
Kernel.exit(1)
|
22
23
|
end
|
23
24
|
|
@@ -36,7 +37,22 @@ module Erber
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
40
|
+
props.deep_merge!(unroll_flat_properties(opts[:override_property].map { |o| o.split("=", 2) } ))
|
41
|
+
|
39
42
|
puts templater.render(props)
|
40
43
|
end
|
44
|
+
|
45
|
+
|
46
|
+
def self.unroll_flat_properties(overrides)
|
47
|
+
hash_trees = overrides.map do |main_key, main_value|
|
48
|
+
main_key.to_s.split(".").reverse.inject(main_value) do |value, key|
|
49
|
+
{key.to_s => value}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
retval = {}
|
54
|
+
hash_trees.each { |h| retval.deep_merge!(h) }
|
55
|
+
retval
|
56
|
+
end
|
41
57
|
end
|
42
58
|
end
|
data/lib/erber/version.rb
CHANGED
data/test-data/props1.yaml
CHANGED
data/test-data/test.erb
CHANGED