scorpion-ioc 0.5.21 → 0.5.22
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 +4 -4
- data/lib/scorpion/hunter.rb +12 -3
- data/lib/scorpion/version.rb +1 -1
- data/spec/lib/scorpion/dependency_map_spec.rb +2 -0
- data/spec/lib/scorpion/hunter_spec.rb +25 -0
- 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: fc3ad78f4a3452b17503b92dd05c67d92b624fef
|
4
|
+
data.tar.gz: ee0e5c93a6371334a930f2428052cfaea063e4f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 105d1a6926bf1c14acd9569335154d4af678785a8014975b1c693347a4fbd3607f5d2fce3c72f5e254ef02bbbf970d7c629f212d24d08fd5dd9d335ade077cc0
|
7
|
+
data.tar.gz: e0947d50f0753da7fd9a4b9166b2f5477d00230b474c05e9322813d2ce8384402ff601dd119ba694c99144cdf801617151a798ce8a75ada3a50b7c7731f56b57
|
data/lib/scorpion/hunter.rb
CHANGED
@@ -48,10 +48,9 @@ module Scorpion
|
|
48
48
|
replica
|
49
49
|
end
|
50
50
|
|
51
|
-
# @see Scorpion#
|
51
|
+
# @see Scorpion#execute
|
52
52
|
def execute( hunt, explicit_only = false )
|
53
|
-
dependency =
|
54
|
-
dependency ||= parent.dependency_map.find( hunt.contract, hunt.traits ) if parent
|
53
|
+
dependency = find_dependency( hunt )
|
55
54
|
dependency ||= Dependency.define( hunt.contract ) if hunt.traits.blank? && !explicit_only
|
56
55
|
|
57
56
|
unsuccessful_hunt( hunt.contract, hunt.traits ) unless dependency
|
@@ -59,6 +58,16 @@ module Scorpion
|
|
59
58
|
dependency.fetch hunt
|
60
59
|
end
|
61
60
|
|
61
|
+
# Find any explicitly defined dependencies that can satisfy the hunt.
|
62
|
+
# @param [Hunt] hunt being resolved.
|
63
|
+
# @return [Dependency] the matching dependency if found
|
64
|
+
def find_dependency( hunt )
|
65
|
+
dependency = dependency_map.find( hunt.contract, hunt.traits )
|
66
|
+
dependency ||= parent.find_dependency( hunt ) if parent
|
67
|
+
|
68
|
+
dependency
|
69
|
+
end
|
70
|
+
|
62
71
|
# @see Scorpion#reset
|
63
72
|
def reset
|
64
73
|
dependency_map.reset
|
data/lib/scorpion/version.rb
CHANGED
@@ -82,6 +82,8 @@ describe Scorpion::DependencyMap do
|
|
82
82
|
|
83
83
|
describe "#replicate_from" do
|
84
84
|
it "does not dup shared dependency" do
|
85
|
+
# Instead of duping shared dependencies, the scorpion should delegate to
|
86
|
+
# its parent which shares the same instance with all of its children.
|
85
87
|
map.chart do
|
86
88
|
share do
|
87
89
|
capture Test::DependencyMap::Weapon
|
@@ -44,6 +44,9 @@ module Test
|
|
44
44
|
initialize( zoo: Test::Hunter::Zoo )
|
45
45
|
end
|
46
46
|
|
47
|
+
class Singleton
|
48
|
+
end
|
49
|
+
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
@@ -59,6 +62,10 @@ describe Scorpion::Hunter do
|
|
59
62
|
hunt_for Test::Hunter::Argumented
|
60
63
|
|
61
64
|
hunt_for Test::Hunter::Zoo
|
65
|
+
|
66
|
+
share do
|
67
|
+
capture Test::Hunter::Singleton
|
68
|
+
end
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
@@ -121,6 +128,24 @@ describe Scorpion::Hunter do
|
|
121
128
|
end
|
122
129
|
end
|
123
130
|
|
131
|
+
describe "#find_dependency" do
|
132
|
+
def build_hunt( hunter )
|
133
|
+
Scorpion::Hunt.new hunter, Test::Hunter::Singleton, []
|
134
|
+
end
|
135
|
+
|
136
|
+
it "finds a dependency" do
|
137
|
+
expect( hunter.find_dependency( build_hunt( hunter ) ) ).to be_a Scorpion::Dependency
|
138
|
+
end
|
139
|
+
|
140
|
+
it "finds a parent dependency" do
|
141
|
+
expect( hunter.find_dependency( build_hunt( hunter.replicate ) ) ).to be_a Scorpion::Dependency
|
142
|
+
end
|
143
|
+
|
144
|
+
it "finds grandparent dependency" do
|
145
|
+
expect( hunter.find_dependency( build_hunt( hunter.replicate.replicate ) ) ).to be_a Scorpion::Dependency
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
124
149
|
describe "#inspect" do
|
125
150
|
it "is helpful" do
|
126
151
|
expect( hunter.inspect ).to match /contracts/
|
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.5.
|
4
|
+
version: 0.5.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|