charmkit 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/template.rb +6 -0
- data/examples/templates/user_auth.txt +1 -0
- data/lib/charmkit.rb +1 -0
- data/lib/charmkit/hook-tools.rb +19 -3
- data/lib/charmkit/template.rb +17 -3
- data/lib/charmkit/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4aaf465f5e2188921b780a65855c2b2882488c5
|
4
|
+
data.tar.gz: 746c903f97888841dbc6f9a123600fe5e01fe7af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104024317ce841e1c8094b015250934b543292580adab0b93f11a8e0f9963b938b5828defc1847020296744a9228150a0f670e80876d15b80e1f9e80754f4d52
|
7
|
+
data.tar.gz: 04f4d7957d325899ef13ac254d4833550e732f9558ac12260a19e98de8362e99e2bf840510b04741626c476aba409e028c1ed64ab7a9d9ff18100a5b862016e6
|
@@ -0,0 +1 @@
|
|
1
|
+
Hi there <%= firstname %> <%= lastname %>
|
data/lib/charmkit.rb
CHANGED
data/lib/charmkit/hook-tools.rb
CHANGED
@@ -9,16 +9,32 @@ module Charmkit
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def config(item)
|
12
|
-
run "config-get #{item}"
|
12
|
+
out, err = run "config-get #{item}"
|
13
|
+
return out.chomp
|
13
14
|
end
|
14
15
|
|
15
16
|
def resource(item)
|
16
|
-
run "resource-get #{item}"
|
17
|
+
out, err = run "resource-get #{item}"
|
18
|
+
return out.chomp
|
17
19
|
end
|
18
20
|
|
19
21
|
def unit(item)
|
20
|
-
run "unit-get #{item}"
|
22
|
+
out, err = run "unit-get #{item}"
|
23
|
+
return out.chomp
|
21
24
|
end
|
22
25
|
|
26
|
+
def action(item)
|
27
|
+
out, err = run "action-get #{item}"
|
28
|
+
return out.chomp
|
29
|
+
end
|
30
|
+
|
31
|
+
def action=(item)
|
32
|
+
out, err = run "action-set #{item}"
|
33
|
+
return out.chomp
|
34
|
+
end
|
35
|
+
|
36
|
+
def log(msg)
|
37
|
+
run "juju-log #{msg}"
|
38
|
+
end
|
23
39
|
end
|
24
40
|
end
|
data/lib/charmkit/template.rb
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
-
|
1
|
+
require 'erb'
|
2
|
+
|
2
3
|
module Charmkit
|
3
4
|
module DSL
|
4
|
-
|
5
|
-
|
5
|
+
class TemplateRenderer
|
6
|
+
def self.empty_binding
|
7
|
+
binding
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.render(template_content, locals = {})
|
11
|
+
b = empty_binding
|
12
|
+
locals.each { |k, v| b.local_variable_set(k, v) }
|
13
|
+
ERB.new(template_content).result(b)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def template(src, dst, **context)
|
18
|
+
rendered = TemplateRenderer.render(File.read(src), context)
|
19
|
+
File.write(dst, rendered)
|
6
20
|
end
|
7
21
|
end
|
8
22
|
end
|
data/lib/charmkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charmkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Stokes
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- bin/setup
|
86
86
|
- charmkit.gemspec
|
87
87
|
- examples/basic.rb
|
88
|
+
- examples/template.rb
|
89
|
+
- examples/templates/user_auth.txt
|
88
90
|
- lib/charmkit.rb
|
89
91
|
- lib/charmkit/hook-tools.rb
|
90
92
|
- lib/charmkit/package.rb
|