bocuse 0.2.0 → 0.2.1
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.
- data/bin/bocuse +2 -0
- data/lib/bocuse/file.rb +3 -3
- data/lib/bocuse/project_context.rb +7 -1
- data/lib/bocuse/unit.rb +9 -11
- data/spec/integration/environment_spec.rb +4 -0
- data/spec/lib/bocuse/file_spec.rb +1 -1
- data/spec/lib/bocuse/unit_spec.rb +2 -2
- metadata +37 -4
data/bin/bocuse
CHANGED
data/lib/bocuse/file.rb
CHANGED
@@ -38,8 +38,8 @@ class Bocuse::File
|
|
38
38
|
node_context = Bocuse::NodeContext.new(name, @context)
|
39
39
|
configuration = Bocuse::Configuration.new
|
40
40
|
|
41
|
-
unit = Bocuse::Unit.new(Proc.new, @project
|
42
|
-
unit.call(configuration)
|
41
|
+
unit = Bocuse::Unit.new(Proc.new, @project)
|
42
|
+
unit.call(configuration, node_context)
|
43
43
|
|
44
44
|
@project.register_node name, configuration
|
45
45
|
|
@@ -49,7 +49,7 @@ class Bocuse::File
|
|
49
49
|
# Delay template evaluation until someone tries to call include_template.
|
50
50
|
# At that time, we'll have a configuration object to have the template
|
51
51
|
# manipulate.
|
52
|
-
unit = Bocuse::Unit.new(Proc.new, @project
|
52
|
+
unit = Bocuse::Unit.new(Proc.new, @project)
|
53
53
|
@project.register_template path, unit
|
54
54
|
unit
|
55
55
|
end
|
@@ -1,6 +1,12 @@
|
|
1
|
+
|
2
|
+
require 'hashie/mash'
|
3
|
+
|
1
4
|
require 'bocuse/context_delegation'
|
2
5
|
|
3
6
|
module Bocuse
|
7
|
+
class ContextHash < Hashie::Mash
|
8
|
+
end
|
9
|
+
|
4
10
|
# Project wide evaluation context.
|
5
11
|
#
|
6
12
|
class ProjectContext
|
@@ -8,7 +14,7 @@ module Bocuse
|
|
8
14
|
end
|
9
15
|
|
10
16
|
def bocuse
|
11
|
-
|
17
|
+
ContextHash.new
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
data/lib/bocuse/unit.rb
CHANGED
@@ -2,29 +2,27 @@ module Bocuse
|
|
2
2
|
# A configuration unit.
|
3
3
|
#
|
4
4
|
class Bocuse::Unit
|
5
|
-
|
6
|
-
attr_reader :current_configuration
|
7
|
-
|
8
|
-
def initialize(block, project, context)
|
5
|
+
def initialize(block, project)
|
9
6
|
@block = block
|
10
|
-
@context = context
|
11
7
|
@project = project
|
12
8
|
end
|
13
9
|
|
14
|
-
def call(configuration)
|
15
|
-
@
|
10
|
+
def call(configuration, context)
|
11
|
+
@configuration = configuration
|
12
|
+
@context = context
|
16
13
|
|
17
14
|
# Fill in the config hash argument if the block cares at all.
|
18
15
|
instance_exec(configuration, &@block)
|
19
16
|
ensure
|
20
|
-
@
|
17
|
+
@configuration = nil
|
18
|
+
@context = nil
|
21
19
|
end
|
22
20
|
|
23
21
|
# Cook adds to the toplevel recipes of this file's configuration.
|
24
22
|
#
|
25
23
|
def cook recipe, &block
|
26
|
-
|
27
|
-
|
24
|
+
@configuration.recipes << recipe
|
25
|
+
@configuration.send(recipe, &block)
|
28
26
|
end
|
29
27
|
|
30
28
|
# Make the given module a helper module for this node.
|
@@ -40,7 +38,7 @@ module Bocuse
|
|
40
38
|
def include_template identifier
|
41
39
|
template_block = @project.lookup_template identifier
|
42
40
|
|
43
|
-
template_block.call(
|
41
|
+
template_block.call(@configuration, @context)
|
44
42
|
end
|
45
43
|
|
46
44
|
# Exposes some of bocuses internal variables to the node that is currently
|
@@ -7,4 +7,8 @@ describe "bocuse environment" do
|
|
7
7
|
project.nodes['A'].to_h[:name].should == 'A'
|
8
8
|
project.nodes['B'].to_h[:name].should == 'B'
|
9
9
|
end
|
10
|
+
it "exports node_name to templates" do
|
11
|
+
project.nodes['A'].to_h[:t_name].should == 'A'
|
12
|
+
project.nodes['B'].to_h[:t_name].should == 'B'
|
13
|
+
end
|
10
14
|
end
|
@@ -4,8 +4,8 @@ describe Bocuse::Unit do
|
|
4
4
|
let(:context) { flexmock('context', bocuse: {node_name: 'test.of.bocuse'}) }
|
5
5
|
let(:project) { flexmock('project') }
|
6
6
|
def unit(configuration)
|
7
|
-
described_class.new(Proc.new, project
|
8
|
-
tap { |unit| unit.call(configuration) }
|
7
|
+
described_class.new(Proc.new, project).
|
8
|
+
tap { |unit| unit.call(configuration, context) }
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#bocuse environment hash" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bocuse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: '0'
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
|
-
name: guard
|
33
|
+
name: guard-rspec
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
none: false
|
36
36
|
requirements:
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: flexmock
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
@@ -62,7 +62,23 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
-
name:
|
65
|
+
name: rb-fsevent
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: growl
|
66
82
|
requirement: !ruby/object:Gem::Requirement
|
67
83
|
none: false
|
68
84
|
requirements:
|
@@ -125,6 +141,22 @@ dependencies:
|
|
125
141
|
- - '='
|
126
142
|
- !ruby/object:Gem::Version
|
127
143
|
version: 3.1.2
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: hashie
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ~>
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.2.0
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ~>
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.2.0
|
128
160
|
description: ! " bocuse teaches chef-solo a few tricks. A strict front-end to chef-solo,
|
129
161
|
\n it reads a configuration syntax that is under source control and \n generates
|
130
162
|
JSON for chef-solo.\n\n This library puts the full power of Ruby at your fingertips
|
@@ -196,3 +228,4 @@ test_files:
|
|
196
228
|
- spec/lib/bocuse/project_spec.rb
|
197
229
|
- spec/lib/bocuse/unit_spec.rb
|
198
230
|
- spec/lib/bocuse/value_spec.rb
|
231
|
+
has_rdoc:
|