stack_commander 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fda9f945f05219e9438a17bc8f263ee0584cf93
4
- data.tar.gz: de1e0efe45393029d55d2d09439b30d76160cb20
3
+ metadata.gz: 193bc58f68f2558b4b761f2c229210af8cfb4ac8
4
+ data.tar.gz: 93db5d8c010915aae4b2660d52dc23a4d8af2466
5
5
  SHA512:
6
- metadata.gz: 07d32fb84a42ee80ca7d02f28a93eb41a6e6eb8d98bd6d5cf0a3f6f028f8228f0be1a79d645135c9a04dcbe69a8280a9ff5233e2e37c92d3026f2266c35f43db
7
- data.tar.gz: a050a61eec438f9d910da316f404af49e618672f6708616342bc88578258acb474dc4c0352212aea6e45f403057c83d2892c627ae7646d7e27e0ae61dfd749f9
6
+ metadata.gz: 8f58bdd6428f9f29e5691b7627edb6560e1b4414392b8e930fa032aef7935b7e30640d644469ea3eff2432a405eb4b0068bff5b04930909d6679960da8809a9d
7
+ data.tar.gz: 0c1fd12293e2e411d3fa183fd6f36cbad7d534086b595803a2f94dc7c1eeb86bebde91b00ebff87b34ec6d0839df594b639cfdd9d8e28ca67959506809d52401
@@ -21,8 +21,12 @@ module StackCommander
21
21
  end
22
22
  end
23
23
 
24
- def extract(scope)
24
+ def match!(scope)
25
25
  raise InvalidScope, scope unless matches?(scope)
26
+ end
27
+
28
+ def extract(scope)
29
+ match!(scope)
26
30
 
27
31
  required_parameters.map do |param|
28
32
  scope.public_send(param)
@@ -17,6 +17,8 @@ module StackCommander
17
17
  end
18
18
 
19
19
  def <<(command)
20
+ StackCommander::DependencyInjection.new(command).match!(@scope)
21
+
20
22
  @queue.push(command)
21
23
 
22
24
  self # for chaining awesomeness << cmd << cmd2 << cmd3
@@ -1,3 +1,3 @@
1
1
  module StackCommander
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/spec/stack_spec.rb CHANGED
@@ -12,7 +12,7 @@ describe StackCommander::Stack do
12
12
 
13
13
  it 'enqueues commands' do
14
14
  expect(stack.size).to eq(0)
15
- stack << double('command')
15
+ stack << double('command').as_null_object
16
16
  expect(stack.size).to eq(1)
17
17
  end
18
18
 
@@ -66,4 +66,17 @@ describe StackCommander::Stack do
66
66
  end
67
67
  end
68
68
  end
69
+
70
+ context 'command not matching scope' do
71
+ let(:command) do
72
+ Class.new(StackCommander::BaseCommand) do
73
+ def initialize(dependency)
74
+ end
75
+ end
76
+ end
77
+
78
+ it 'checks scope when adding command' do
79
+ expect { stack << command }.to raise_error(StackCommander::DependencyInjection::InvalidScope)
80
+ end
81
+ end
69
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Cichra