itamae 1.0.0.beta44 → 1.0.0.beta45
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30928582ba392469a4486a627a338679a043325d
|
4
|
+
data.tar.gz: ebe9aa8b1277b3ff6bd1fc24eb90e3d4bdbdb09a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c520cec281a78ac8adb14dbe3f65c9736b9a2dadd810d6fc38e3e12a5e03484444404ee9cf068125d680a6c36e7cc4c77004757e46d844c83af1f4a666c2aa7
|
7
|
+
data.tar.gz: 642f82a7545b77029ebce1372996eb18488864d315b9e302a5a0e4a39b702e47bec32231d5af8ff649fdf4cd77c42992e076613ad9c320274729294918d550ce
|
@@ -6,13 +6,36 @@ module Itamae
|
|
6
6
|
module Resource
|
7
7
|
class Template < File
|
8
8
|
define_attribute :source, type: String, required: true
|
9
|
+
define_attribute :variables, type: Hash, default: {}
|
9
10
|
|
10
11
|
def pre_action
|
11
12
|
src = ::File.expand_path(attributes.source, ::File.dirname(@recipe.path))
|
12
|
-
attributes.content =
|
13
|
+
attributes.content = RenderContext.new(self).render_file(src)
|
13
14
|
|
14
15
|
super
|
15
16
|
end
|
17
|
+
|
18
|
+
class RenderContext
|
19
|
+
def initialize(resource)
|
20
|
+
@resource = resource
|
21
|
+
|
22
|
+
@resource.attributes.variables.each_pair do |key, value|
|
23
|
+
instance_variable_set("@#{key}".to_sym, value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def render(template)
|
28
|
+
ERB.new(template, nil, '-').result(binding)
|
29
|
+
end
|
30
|
+
|
31
|
+
def render_file(src)
|
32
|
+
render(::File.read(src))
|
33
|
+
end
|
34
|
+
|
35
|
+
def node
|
36
|
+
@resource.recipe.runner.node
|
37
|
+
end
|
38
|
+
end
|
16
39
|
end
|
17
40
|
end
|
18
41
|
end
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta45
|