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 CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby -W0
2
2
  # Encoding: UTF-8
3
3
 
4
+ $VERBOSE=nil
5
+
4
6
  require 'thor'
5
7
 
6
8
  $:.unshift File.expand_path '../../lib', __FILE__
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, node_context)
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, @context)
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
- # Returns the current configuration, but only during a call to this unit.
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
- @current_configuration = configuration
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
- @current_configuration = nil
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
- current_configuration.recipes << recipe
27
- current_configuration.send(recipe, &block)
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(current_configuration)
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
@@ -44,7 +44,7 @@ describe Bocuse::File do
44
44
  end
45
45
 
46
46
  config = Bocuse::Configuration.new
47
- template.call config
47
+ template.call config, context
48
48
 
49
49
  config.to_h.should == { :something => :value, :something_else => { :key => "value" } }
50
50
  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, context).
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.0
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: guard-rspec
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: flexmock
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: