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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e4554b3de6ac16dd3564b7ce94776dbe389ecce
4
- data.tar.gz: 32245b81b11860337171ae2df0b867f7bd0758f7
3
+ metadata.gz: fc3ad78f4a3452b17503b92dd05c67d92b624fef
4
+ data.tar.gz: ee0e5c93a6371334a930f2428052cfaea063e4f5
5
5
  SHA512:
6
- metadata.gz: 2b73bd3f9581b6a626d3dd07b4cbafdea26bc938f7f22d1cb4d2cdbcba361ff6b6c529f6fc4c9a0d8b39029735e7782779dd5bb0d15d72a8ee175eedda076c82
7
- data.tar.gz: 49b1a70c443588a55f28165bcf89e23fc427b635f257f41233700b56bd3af8166e504f7e80c0d3561830706b1815f0f54d3e0d5c5accc69b9e45e2bd3aeb832e
6
+ metadata.gz: 105d1a6926bf1c14acd9569335154d4af678785a8014975b1c693347a4fbd3607f5d2fce3c72f5e254ef02bbbf970d7c629f212d24d08fd5dd9d335ade077cc0
7
+ data.tar.gz: e0947d50f0753da7fd9a4b9166b2f5477d00230b474c05e9322813d2ce8384402ff601dd119ba694c99144cdf801617151a798ce8a75ada3a50b7c7731f56b57
@@ -48,10 +48,9 @@ module Scorpion
48
48
  replica
49
49
  end
50
50
 
51
- # @see Scorpion#hunt
51
+ # @see Scorpion#execute
52
52
  def execute( hunt, explicit_only = false )
53
- dependency = dependency_map.find( hunt.contract, hunt.traits )
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
@@ -1,5 +1,5 @@
1
1
  module Scorpion
2
- VERSION_NUMBER = "0.5.21"
2
+ VERSION_NUMBER = "0.5.22"
3
3
  VERSION_SUFFIX = ""
4
4
  VERSION = "#{VERSION_NUMBER}#{VERSION_SUFFIX}"
5
5
  end
@@ -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.21
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-14 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails