scorpion-ioc 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/circle.yml +8 -1
- data/lib/scorpion.rb +4 -1
- data/lib/scorpion/dependency/class_dependency.rb +2 -1
- data/lib/scorpion/version.rb +1 -1
- data/scorpion.gemspec +1 -1
- data/spec/lib/scorpion/hunter_spec.rb +32 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d9743363773a85cd8edd7d91b4b9c064ca0588261706eee6bd20cf7b8ed7e9a4
|
4
|
+
data.tar.gz: 83f5104291bc2a00ddf1a274d116ecf8a4adeec3309af2b78d2ccd300bdebce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f4f81d5ad4762fec21d10486b2dc4e427402a45bb72da9dd422eda52d10a42d012217ef231ab2b761f1d55782785e25024b94398c9d9c8b3a1cb4d3d60926dd
|
7
|
+
data.tar.gz: 124563115dc80311d260cd9b18bec4ff8159e11277fa2d0740d51202d67d37a746d25fb4924a4f325482f3fbf0a3b13567af356734135ec866e65449a4f381e4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
data/Gemfile
CHANGED
data/circle.yml
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
machine:
|
2
|
+
pre:
|
3
|
+
# https://discuss.circleci.com/t/ruby-2-5-0-builds-failing-on-circleci-1-0-due-to-missing-home-travis/19620
|
4
|
+
# https://discuss.circleci.com/t/ruby-2-5-0-still-a-problem/19637/4
|
5
|
+
- sudo rm -rf /home/travis
|
6
|
+
- sudo ln -s /home/ubuntu /home/travis
|
7
|
+
|
1
8
|
database:
|
2
9
|
override:
|
3
10
|
# We don't actually use a DB but it is included in the internal rails app
|
@@ -6,4 +13,4 @@ database:
|
|
6
13
|
|
7
14
|
test:
|
8
15
|
post:
|
9
|
-
- bundle exec codeclimate-test-reporter
|
16
|
+
- bundle exec codeclimate-test-reporter
|
data/lib/scorpion.rb
CHANGED
@@ -117,12 +117,15 @@ module Scorpion
|
|
117
117
|
|
118
118
|
def self.instance=( scorpion )
|
119
119
|
if @instance_referenced
|
120
|
-
logger.warn "Replacing the global Scorpion.instance will not update any Scorpion::Nest instances created with the original scorpion." # rubocop:disable Metrics/LineLength
|
120
|
+
logger.warn "Replacing the global Scorpion.instance will not update any Scorpion::Nest instances created with the original scorpion." if warn_global_replace # rubocop:disable Metrics/LineLength
|
121
121
|
@instance_referenced = false
|
122
122
|
end
|
123
123
|
@instance = scorpion
|
124
124
|
end
|
125
125
|
|
126
|
+
cattr_accessor :warn_global_replace
|
127
|
+
self.warn_global_replace = true
|
128
|
+
|
126
129
|
# Prepare the {#instance} for hunting.
|
127
130
|
# @param [Boolean] reset true to free all existing resource and initialize a
|
128
131
|
# new scorpion.
|
@@ -6,9 +6,10 @@ module Scorpion
|
|
6
6
|
class ClassDependency < Scorpion::Dependency
|
7
7
|
|
8
8
|
def fetch( hunt )
|
9
|
-
hunt.scorpion.spawn hunt,
|
9
|
+
hunt.scorpion.spawn hunt, contract, *hunt.arguments, &hunt.block
|
10
10
|
end
|
11
11
|
|
12
|
+
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/scorpion/version.rb
CHANGED
data/scorpion.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/phallguy/scorpion"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.files = `git ls-files -z 2>/dev/null`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
@@ -5,6 +5,7 @@ module Test
|
|
5
5
|
class Beast; end
|
6
6
|
class Bear < Beast; end
|
7
7
|
class Lion < Beast; end
|
8
|
+
class Tiger < Beast; end
|
8
9
|
class Grizly < Bear; end
|
9
10
|
class Argumented
|
10
11
|
def initialize( arg )
|
@@ -53,6 +54,11 @@ module Test
|
|
53
54
|
class Singleton
|
54
55
|
end
|
55
56
|
|
57
|
+
class Madonna < Singleton
|
58
|
+
end
|
59
|
+
|
60
|
+
class Cher < Singleton
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
58
64
|
|
@@ -61,6 +67,7 @@ describe Scorpion::Hunter do
|
|
61
67
|
let( :hunter ) do
|
62
68
|
Scorpion::Hunter.new do
|
63
69
|
capture Test::Hunter::Lion
|
70
|
+
capture Test::Hunter::Tiger
|
64
71
|
|
65
72
|
hunt_for Test::Hunter::Bear
|
66
73
|
hunt_for Test::Hunter::Grizly
|
@@ -69,7 +76,8 @@ describe Scorpion::Hunter do
|
|
69
76
|
hunt_for Test::Hunter::Zoo
|
70
77
|
|
71
78
|
share do
|
72
|
-
capture Test::Hunter::
|
79
|
+
capture Test::Hunter::Madonna
|
80
|
+
capture Test::Hunter::Cher
|
73
81
|
end
|
74
82
|
end
|
75
83
|
end
|
@@ -88,6 +96,29 @@ describe Scorpion::Hunter do
|
|
88
96
|
expect( hunter.fetch(Test::Hunter::Lion) ).to be first
|
89
97
|
end
|
90
98
|
|
99
|
+
it "does not capture a sibling dependency" do
|
100
|
+
first = hunter.fetch Test::Hunter::Lion
|
101
|
+
expect( hunter.fetch(Test::Hunter::Tiger) ).not_to be first
|
102
|
+
expect( hunter.fetch(Test::Hunter::Tiger) ).to be_a Test::Hunter::Tiger
|
103
|
+
end
|
104
|
+
|
105
|
+
it "does not share a captured sibling dependency" do
|
106
|
+
singer = hunter.fetch Test::Hunter::Madonna
|
107
|
+
expect( hunter.fetch( Test::Hunter::Cher ) ).not_to be singer
|
108
|
+
expect( hunter.fetch( Test::Hunter::Cher ) ).to be_a Test::Hunter::Cher
|
109
|
+
end
|
110
|
+
|
111
|
+
it "does not share a captured ancestor dependency" do
|
112
|
+
singer = hunter.fetch Test::Hunter::Singleton
|
113
|
+
expect( hunter.fetch( Test::Hunter::Madonna ) ).not_to be singer
|
114
|
+
expect( hunter.fetch( Test::Hunter::Madonna ) ).to be_a Test::Hunter::Madonna
|
115
|
+
end
|
116
|
+
|
117
|
+
it "captures derived dependency" do
|
118
|
+
singer = hunter.fetch Test::Hunter::Singleton
|
119
|
+
expect( singer ).to be_a Test::Hunter::Cher
|
120
|
+
end
|
121
|
+
|
91
122
|
it "injects nested objects" do
|
92
123
|
zoo = hunter.fetch Test::Hunter::Zoo
|
93
124
|
expect( zoo.bear ).to be_a Test::Hunter::Bear
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
225
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.6
|
226
|
+
rubygems_version: 2.7.6
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: Add IoC to rails with minimal fuss and ceremony
|