scorpion-ioc 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scorpion/hunting_map.rb +4 -4
- data/lib/scorpion/version.rb +1 -1
- data/spec/lib/scorpion/hunter_spec.rb +4 -3
- data/spec/lib/scorpion/hunting_map_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c95b03306b50c7e49688d4736c3287ec3ebab9d0
|
4
|
+
data.tar.gz: 6011ea65e623df92f421ad2037ca3a6aa02e0a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3de90e129024ce65ee4591d49e821877d0854c8c0f6abebf85f6237cb4558cc905bf9961ae59530fb10884c0f890f33ccb733fe802afb01245417c761d52118
|
7
|
+
data.tar.gz: b9f9feb46528c3f66ab2a4c835bb88b309b0e6f017bf138ef841633a5e71b3e141a6476a170181f26590fc9914162de976cbf3ff5cf784c6aabf2adfe087028b
|
data/lib/scorpion/hunting_map.rb
CHANGED
@@ -31,8 +31,8 @@ module Scorpion
|
|
31
31
|
|
32
32
|
def initialize( scorpion )
|
33
33
|
@scorpion = scorpion
|
34
|
-
@prey_set = @active_prey_set =
|
35
|
-
@shared_prey_set =
|
34
|
+
@prey_set = @active_prey_set = []
|
35
|
+
@shared_prey_set = []
|
36
36
|
end
|
37
37
|
|
38
38
|
# Find {Prey} that matches the requested `contract` and `traits`.
|
@@ -66,7 +66,7 @@ module Scorpion
|
|
66
66
|
# @param [Array<Symbol>] traits found on the {Prey}.
|
67
67
|
# @return [Scorpion::Prey] the prey to be hunted for.
|
68
68
|
def hunt_for( contract, traits = nil, &builder )
|
69
|
-
active_prey_set
|
69
|
+
active_prey_set.unshift prey_class( contract, &builder ).new( contract, traits, &builder )
|
70
70
|
end
|
71
71
|
alias_method :offer, :hunt_for
|
72
72
|
|
@@ -74,7 +74,7 @@ module Scorpion
|
|
74
74
|
# for the resource.
|
75
75
|
# @see #hunt_for
|
76
76
|
def capture( contract, traits = nil, &builder )
|
77
|
-
active_prey_set
|
77
|
+
active_prey_set.unshift Scorpion::Prey::CapturedPrey.new( prey_class( contract, &builder ).new( contract, traits, &builder ) )
|
78
78
|
end
|
79
79
|
alias_method :singleton, :capture
|
80
80
|
|
data/lib/scorpion/version.rb
CHANGED
@@ -28,23 +28,24 @@ describe Scorpion::Hunter do
|
|
28
28
|
|
29
29
|
let( :hunter ) do
|
30
30
|
Scorpion::Hunter.new do
|
31
|
+
capture Test::Hunter::Lion, :tame
|
32
|
+
|
31
33
|
hunt_for Test::Hunter::Bear
|
32
34
|
hunt_for Test::Hunter::Lion, :male
|
33
35
|
hunt_for Test::Hunter::Grizly, :female
|
34
36
|
hunt_for Test::Hunter::Argumented
|
35
37
|
|
36
|
-
capture Test::Hunter::Lion, :tame
|
37
38
|
hunt_for Test::Hunter::Zoo
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
42
|
it "spawns prey" do
|
42
|
-
expect( hunter.hunt Test::Hunter::Beast ).to be_a Test::Hunter::
|
43
|
+
expect( hunter.hunt Test::Hunter::Beast ).to be_a Test::Hunter::Beast
|
43
44
|
end
|
44
45
|
|
45
46
|
it "spawns a new instance for multiple requests" do
|
46
47
|
first = hunter.hunt Test::Hunter::Beast
|
47
|
-
expect( hunter.hunt Test::Hunter::Beast ).not_to
|
48
|
+
expect( hunter.hunt Test::Hunter::Beast ).not_to be first
|
48
49
|
end
|
49
50
|
|
50
51
|
it "spawns the same instance for captured prey" do
|
@@ -54,15 +54,15 @@ describe Scorpion::HuntingMap do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
it "returns the
|
58
|
-
expect( map.find( Test::HuntingMap::Weapon, :one_handed ).traits ).to include :
|
57
|
+
it "returns the last prey that matches one trait" do
|
58
|
+
expect( map.find( Test::HuntingMap::Weapon, :one_handed ).traits ).to include :blunt
|
59
59
|
end
|
60
60
|
|
61
|
-
it "returns the
|
61
|
+
it "returns the last prey that matches all of the traits" do
|
62
62
|
expect( map.find( Test::HuntingMap::Weapon, [ :one_handed, :blunt ] ).traits ).to include :blunt
|
63
63
|
end
|
64
64
|
|
65
|
-
it "returns the
|
65
|
+
it "returns the last prey that matches a unique trait" do
|
66
66
|
expect( map.find( Test::HuntingMap::Weapon, :blunt ).traits ).to include :blunt
|
67
67
|
end
|
68
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scorpion-ioc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|