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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3bdbb4562dc3fe33ca9a8c061fe3f66024e62d3
4
- data.tar.gz: e2c52ab359c244621fe8cd2e84aeb1dbbab4f282
3
+ metadata.gz: 673005f434315f9a24f55976aaac79c42a2a58df
4
+ data.tar.gz: 9856330c2e39915260cfe7186ec684c6e363262c
5
5
  SHA512:
6
- metadata.gz: cf04f1f9375497ec688db6bf0e74ace0b7d678805b32d14a20bb92bd743bbeab2e470f5f06052761c958c7d80326b71cca338a8a21abca457f33764549d2aef5
7
- data.tar.gz: e561bf5bdc15b4f3603c2c3a1e6f4c51d68063b564ec937738c9980cc96f0ac40e5aeff4e58de9c182038bd2a606515028c9becc3dab849b0db4e6c5919cdb75
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
  """
@@ -3,11 +3,15 @@ module Producer
3
3
  class Recipe
4
4
  class << self
5
5
  def define_macro(name, block)
6
- define_method(name) { |*args| task name, *args, &block }
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, meth, *base_args)
10
- define_method(name) { |*args| send meth, *(base_args + args) }
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
- define_singleton_method name do |*args|
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, meth, *base_args)
40
- define_singleton_method name do |*args|
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)
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.3.4'.freeze
3
+ VERSION = '0.3.5'.freeze
4
4
  end
5
5
  end
@@ -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 :hello
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: producer-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan