ioc 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16e4bbc94810cfff1a0cce335a242993c9993767
4
- data.tar.gz: 0c9e66471ee6b827adccbdcf927bfc042ea13cab
3
+ metadata.gz: c4f7ece1883442db7d03642ac2a0723e0e4208ec
4
+ data.tar.gz: abf30ff7dbb9f75f608cbe6fe0b0d4df0a1f0b4a
5
5
  SHA512:
6
- metadata.gz: 7d8691f028e9efbf5d19eaa37189c10f40a57af2eb2eda2ae8e5d814212bd9ce4d6f1d5991b21e10bf6b8db477da1a266f70cab9b2f4bfa202b8409807392295
7
- data.tar.gz: 489021e8551b4d98f2705f377780c5f30949384a88f8409a9e71c53937b26ea7ea30e03cd17ed3ee94d25a5af7ba29471bdeea2ff719657483daca7d397dbf31
6
+ metadata.gz: 0f6a0d831a5823f85df5eb71577be1cfa38c613cd4f0559c3bb9e8220a07392cbbaf0baf541108014f063ae15ec2cd5b2193621998f7a52e2cc0e2678bbcf422
7
+ data.tar.gz: 1e492ebbb5e74d66660ba98d4746c01c5b9c4e5c76bd8768ea73f89b5c9970ac02f78e434343eaab559afe7650abb31056323c9502a0717585c749e78f64ff45
data/lib/ioc/container.rb CHANGED
@@ -17,6 +17,11 @@ module IOC
17
17
  @resolvers[name] = ResolverFactory.new_instance(object, self, options)
18
18
  end
19
19
 
20
+ def register_instance(name, object, options={})
21
+ options[:as] = :instance
22
+ register(name, object, options)
23
+ end
24
+
20
25
  def resolve(name)
21
26
  raise(UnknownService, "Service '#{name}' has not been registered") unless @resolvers.key?(name)
22
27
  @cache[name] ||= @resolvers[name].resolve
data/lib/ioc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module IOC
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
data/spec/ioc_spec.rb CHANGED
@@ -100,6 +100,13 @@ describe IOC::Container do
100
100
  end
101
101
  end
102
102
 
103
+ it 'can register object as an instance' do
104
+ object = stub
105
+ container = IOC::Container.new
106
+ container.register_instance(:myobj, object)
107
+ container.resolve(:myobj).must_equal(object)
108
+ end
109
+
103
110
  it 'can register components using an installer' do
104
111
  installer_class = Class.new do
105
112
  def self.install(c)
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ioc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.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: 2014-02-14 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.14.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.14.0
55
55
  description: Minimal inversion of control container for Ruby
@@ -59,7 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
62
+ - ".gitignore"
63
63
  - Gemfile
64
64
  - Guardfile
65
65
  - LICENSE.txt
@@ -86,17 +86,17 @@ require_paths:
86
86
  - lib
87
87
  required_ruby_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.0.7
99
+ rubygems_version: 2.2.2
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Minimal inversion of control container for Ruby