ioc 6.0.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/ioc.gemspec +1 -1
  3. data/lib/ioc.rb +6 -0
  4. data/spec/ioc_spec.rb +12 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45cfdeec3bba0d8515b0cb35b5237b66a028ce85
4
- data.tar.gz: 13fcee15a0d44787e8f79017ec0c5cb81c0bf126
3
+ metadata.gz: 5d74cd8f28348bde6d237602eab9f19a35483152
4
+ data.tar.gz: fe5e748bfbb204763e1285487d0601c59c5d3dcd
5
5
  SHA512:
6
- metadata.gz: 8b880eeb06d15ddf14edcc384ba270d0ec8d7c23364a043a43af2a1211889909d42531d05bb0cbe7f012489c2407f06bc5af8ce1a831751a3bd708930a051326
7
- data.tar.gz: 21b1a31d877de30d7fac725a40208c2e1eeecce806f1e0812eaedd992f95fedad60b68f55bc4c073c3afd5be38334403e88553b836227434cec4d46966823d69
6
+ metadata.gz: c1b6862816c763988e82a8d484205fa8ed5fa233fa9ca8d77fbdc8f1b4e1c28dfb8c64df5f877b2e22c7ea2b4746b531ac6b3bfc84f67bbd4abcb955b125dc0e
7
+ data.tar.gz: f7f162920ae8bfed59bcf3cd1656cc0b8236fe2f434ba9c9126ba6d77a9f8c8712f921fa72c129bd8984751cfc976cdae6987bf71c7a5c4d38216da8b4c98d48
data/ioc.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "ioc"
5
- spec.version = "6.0.0"
5
+ spec.version = "6.1.0"
6
6
  spec.authors = ["Erik Lott"]
7
7
  spec.email = ["erik.lott@kodio.io"]
8
8
  spec.summary = "Minimal dependency injection container for Ruby"
data/lib/ioc.rb CHANGED
@@ -30,6 +30,12 @@ module IOC
30
30
  end
31
31
  end
32
32
 
33
+ def each_type(klass)
34
+ @services.each do |key, service|
35
+ yield(key, service) if service <= klass
36
+ end
37
+ end
38
+
33
39
  def release
34
40
  @cache = {}
35
41
  end
data/spec/ioc_spec.rb CHANGED
@@ -9,7 +9,9 @@ class CarFixture
9
9
  end
10
10
  end
11
11
 
12
- class EngineFixture; end
12
+ class PropulsionFixture; end
13
+ class EngineFixture < PropulsionFixture; end
14
+ class MotorFixture < PropulsionFixture; end
13
15
 
14
16
  describe IOC do
15
17
  it "can resolve a service class" do
@@ -42,6 +44,15 @@ describe IOC do
42
44
  container.resolve(:myobject).must_equal(myobject)
43
45
  end
44
46
 
47
+ it "iterate through registrants by type" do
48
+ container = IOC::Container.new
49
+ container.register(:engine, EngineFixture)
50
+ container.register(:motor, MotorFixture)
51
+ services = {}
52
+ container.each_type(PropulsionFixture) {|key, service| services[key] = service}
53
+ services.must_equal(:engine => EngineFixture, :motor => MotorFixture)
54
+ end
55
+
45
56
  it "complains when resolving unknown service" do
46
57
  container = IOC::Container.new
47
58
  proc {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ioc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Lott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-08 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler