inprovise 0.2.19 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/inprovise/template/inprovise.rb.erb +11 -3
- data/lib/inprovise/template.rb +24 -1
- data/lib/inprovise/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGQzNjQ2MjVjMWYxZjM1M2ZmNTYwYjE4MGRhZDhjYjM5NTU5ZjI3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTFmODBiY2YwYmNkZGIxNGUxYTQzOGM0YTUwNmY1Y2ZmZTVkODBkYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjY4NWQ0ZjA5YjZjNzc4ZjNhNTU2MjA1ZWUxMDEwM2Q5NWI0N2NmZjA1MDk2
|
10
|
+
MDlmM2YwMjE5MTk4ZWUzY2ZhM2JkYzE0ZWRlOTU4ZmQ3MzA1ZDQwOGMxMjQx
|
11
|
+
YzQ2YjA1ZWQxYjE4NDM2NGRkZjFmZDI2NjdjZjc0NDQyMWQ2MTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTI0NmQ1ZDQ0MTA3NGI2ZmJlNjY5ZDRiZWI4YzM1MGZlMzIyZTVmZGVlZDQy
|
14
|
+
YWUxZWUzOTlkYjI3ZjVjY2JjMmQ5ZDZmMGVjNGY5MWFlYTU3MjliY2FjNjVj
|
15
|
+
NDdmZmM3ZmZlZmI1OGMxMzBjNjcxNWY0Nzk4OTE1ZTdhZDM1N2I=
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#
|
10
10
|
# description 'description'
|
11
11
|
#
|
12
|
-
# configuration <data>
|
12
|
+
# configuration <data> [{ }]
|
13
13
|
#
|
14
14
|
# action('action1') { }
|
15
15
|
# action('action2') { }
|
@@ -52,7 +52,7 @@
|
|
52
52
|
#
|
53
53
|
# run_local 'command' execute command locally
|
54
54
|
#
|
55
|
-
# log 'msg'
|
55
|
+
# log 'msg', color=nil log a message; color is symbol like :red, :blue, :yellow ...
|
56
56
|
#
|
57
57
|
# sudo 'command'[, {}] execute command on current node over SSH connection using 'sudo'
|
58
58
|
# options: see 'run'
|
@@ -87,6 +87,14 @@
|
|
87
87
|
# template('/local/file') creates a template object for the specified (ERB) template file
|
88
88
|
# providing 2 rendering options
|
89
89
|
# .render(locals ={}) returns rendered result string
|
90
|
-
# .render_to_tempfile(locals = {}) returns path of tempfile containing rendered result
|
90
|
+
# .render_to_tempfile(locals = {}) returns path of local tempfile containing rendered result
|
91
|
+
# .render_to(fname[, mktmp = true], locals={})
|
92
|
+
# return remote file object referencing (temp)
|
93
|
+
# file containing rendered result
|
94
|
+
# .render_to(fname[, mktmp = true], locals={}) { |fremote| ... }
|
95
|
+
# yields block with remote file object referencing (temp)
|
96
|
+
# file containing rendered result
|
97
|
+
# deletes the remote file after block finishes if it still
|
98
|
+
# exists
|
91
99
|
#
|
92
100
|
|
data/lib/inprovise/template.rb
CHANGED
@@ -15,7 +15,30 @@ class Inprovise::Template
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def render(locals={})
|
18
|
-
@template.render(@context, locals)
|
18
|
+
@template.render(Inprovise::ExecutionContext::DSL.new(@context), locals)
|
19
|
+
end
|
20
|
+
|
21
|
+
def render_to(fname, *opts, &block)
|
22
|
+
mktmp = opts.size > 1 ? opts.shift : true
|
23
|
+
locals = opts.shift || {}
|
24
|
+
tmpfile = @context.local(render_to_tempfile(locals))
|
25
|
+
fremote = nil
|
26
|
+
begin
|
27
|
+
# upload to temporary file
|
28
|
+
fremote = tmpfile.upload("#{File.basename(fname, '.*')}-#{tmpfile.hash}.#{File.extname(fname)}")
|
29
|
+
# move/rename temporary file if required
|
30
|
+
unless mktmp && File.dirname(fname) == '.'
|
31
|
+
fremote = fremote.move_to(mktmp ? File.dirname(fname) : fname)
|
32
|
+
end
|
33
|
+
if block_given?
|
34
|
+
@context.exec(block, fremote)
|
35
|
+
fremote.delete! if mktmp
|
36
|
+
fremote = nil
|
37
|
+
end
|
38
|
+
ensure
|
39
|
+
tmpfile.delete!
|
40
|
+
end
|
41
|
+
fremote
|
19
42
|
end
|
20
43
|
|
21
44
|
def render_to_tempfile(locals={})
|
data/lib/inprovise/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inprovise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Corino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|