producer-core 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/recipe_macro.feature +11 -1
- data/lib/producer/core/recipe.rb +10 -10
- data/lib/producer/core/version.rb +1 -1
- data/spec/producer/core/recipe_spec.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 673005f434315f9a24f55976aaac79c42a2a58df
|
4
|
+
data.tar.gz: 9856330c2e39915260cfe7186ec684c6e363262c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae738019692289d5bcd5b76269051dfdc4faca9e4fe342308f93ab5cc901d9399b0129e9b51a48110406393886918c62a346dc71c1c2fb9b8f2a62cc1482a796
|
7
|
+
data.tar.gz: 328fc0a31d1e60aebe86747e9042510e4788dfbe98f14a0f0f7172002cfc80f21c8f9c8d05f9abffb49a60dc23a3da2ebe0999de394c8d11ab9776090b7be366
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Feature: `macro' recipe keyword
|
2
2
|
|
3
|
-
Scenario: declares a new keyword accepting task code
|
3
|
+
Scenario: declares a new recipe keyword accepting task code
|
4
4
|
Given a recipe with:
|
5
5
|
"""
|
6
6
|
macro :hello do
|
@@ -12,6 +12,16 @@ Feature: `macro' recipe keyword
|
|
12
12
|
When I successfully execute the recipe
|
13
13
|
Then the output must contain "hello macro"
|
14
14
|
|
15
|
+
Scenario: declares a new task keyword
|
16
|
+
Given a recipe with:
|
17
|
+
"""
|
18
|
+
macro(:hello) { echo 'hello macro' }
|
19
|
+
|
20
|
+
task(:some_task) { hello }
|
21
|
+
"""
|
22
|
+
When I successfully execute the recipe
|
23
|
+
Then the output must contain "hello macro"
|
24
|
+
|
15
25
|
Scenario: supports arguments
|
16
26
|
Given a recipe with:
|
17
27
|
"""
|
data/lib/producer/core/recipe.rb
CHANGED
@@ -3,11 +3,15 @@ module Producer
|
|
3
3
|
class Recipe
|
4
4
|
class << self
|
5
5
|
def define_macro(name, block)
|
6
|
-
|
6
|
+
[self, Task].each do |klass|
|
7
|
+
klass.class_eval do
|
8
|
+
define_method(name) { |*args| task name, *args, &block }
|
9
|
+
end
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
|
-
def compose_macro(name,
|
10
|
-
define_method(name) { |*args| send
|
13
|
+
def compose_macro(name, macro, *base_args)
|
14
|
+
define_method(name) { |*args| send macro, *(base_args + args) }
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
@@ -31,15 +35,11 @@ module Producer
|
|
31
35
|
end
|
32
36
|
|
33
37
|
def macro(name, &block)
|
34
|
-
|
35
|
-
task "#{name}", *args, &block
|
36
|
-
end
|
38
|
+
self.class.class_eval { define_macro name, block }
|
37
39
|
end
|
38
40
|
|
39
|
-
def compose_macro(name,
|
40
|
-
|
41
|
-
send meth, *(base_args + args)
|
42
|
-
end
|
41
|
+
def compose_macro(name, macro, *base_args)
|
42
|
+
self.class.class_eval { compose_macro name, macro, *base_args}
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_macro(name, &block)
|
@@ -49,10 +49,15 @@ module Producer::Core
|
|
49
49
|
|
50
50
|
describe '#macro' do
|
51
51
|
it 'defines the new recipe keyword' do
|
52
|
-
recipe.macro
|
52
|
+
recipe.macro(:hello) { }
|
53
53
|
expect(recipe).to respond_to(:hello)
|
54
54
|
end
|
55
55
|
|
56
|
+
it 'defines the new task keyword' do
|
57
|
+
recipe.macro(:hello) { }
|
58
|
+
expect { recipe.task(:some_task) { hello } }.not_to raise_error
|
59
|
+
end
|
60
|
+
|
56
61
|
context 'when a defined macro is called' do
|
57
62
|
before { recipe.macro(:hello) { :some_macro_code } }
|
58
63
|
|