Skip to content

Commit

Permalink
+ cook syntax sugar
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaspar Schiess committed Sep 6, 2012
1 parent aba4519 commit 2ce1722
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions HISTORY
@@ -1,5 +1,10 @@
VERSION HISTORY

= v0.1.1

* Syntax sugar for 'cook foo, cfg.foo do ... end'. Append the block to cook
directly.

= v0.1.0

* Nodes/Templates
Expand Down
2 changes: 1 addition & 1 deletion bocuse.gemspec
Expand Up @@ -2,7 +2,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY

s.name = 'bocuse'
s.version = '0.1.0'
s.version = '0.1.1'

s.authors = ['Florian Hanke', 'Kaspar Schiess', 'Jens-Christian Fischer']
s.email = ['florian.hanke@technologyastronauts.ch',
Expand Down
3 changes: 2 additions & 1 deletion lib/bocuse/unit.rb
Expand Up @@ -21,8 +21,9 @@ def call(configuration)

# Cook adds to the toplevel recipes of this file's configuration.
#
def cook recipe
def cook recipe, &block
current_configuration.recipes << recipe
current_configuration.send(recipe, &block)
end

# Make the given module a helper module for this node.
Expand Down
6 changes: 6 additions & 0 deletions spec/files/complex/config/nodes/production/complex.rb
Expand Up @@ -4,6 +4,12 @@
include_template :cooking
cook "app::install"
cook "app::deploy"

# This will cook 'my_service', but also append a key 'my_service' to the
# dictionary with the given content. Syntax sugar.
cook 'my_service' do |cfg|
cfg.foo 'bar'
end

# This trips up if the evaluator of this block is in Bocuse constant lookup
# space.
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/cli_spec.rb
Expand Up @@ -9,7 +9,7 @@

compiled = MultiJson.load(`#{project_path('bin/bocuse')} \
compile complex.production.example.com`)
compiled.size.should == 2
compiled.size.should == 3
compiled['recipes'].should == ['nginx', 'git', 'app::install', 'app::deploy'];
compiled['key_location'].should match(%r{spec/files/complex/config/nodes/production/key.txt$})
end
Expand Down
9 changes: 8 additions & 1 deletion spec/integration/complex_spec.rb
Expand Up @@ -51,7 +51,14 @@
find { |name, _| name == 'complex.production.example.com' }.
last

config.to_h[:recipes].should =~ %w(nginx git app::install app::deploy)
config.to_h[:recipes].should =~ %w(nginx git app::install app::deploy my_service)
end
it "configures my_service at the same time" do
config = project.nodes.
find { |name, _| name == 'complex.production.example.com' }.
last

config.to_h[:my_service].should == { :foo => 'bar' }
end
end
end

0 comments on commit 2ce1722

Please sign in to comment.