ioc_rb 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -14
- data/lib/ioc_rb/beans_metadata_storage.rb +4 -0
- data/lib/ioc_rb/container.rb +12 -0
- data/lib/ioc_rb/version.rb +1 -1
- data/spec/ioc_rb/container_spec.rb +17 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cdaa166b74b872446a6ae30c0b18ddc7a74e94c
|
4
|
+
data.tar.gz: 41f3d362e8e3f257a0efdcc77c357faf12682c24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 794093273697db155d7b6e975b2b8f5ce47d40c01c983d0f80b8d337979fb21048cefd9b0a8a7c1d6337bcccd6485a09f58904d60e42b152f97d80ff686edecd
|
7
|
+
data.tar.gz: 72527ab78b9f818f428fa0c7dd2781654af3a7d4fe3be38f6b0a2df82cebfaeb12ad5796158555c7c45fd3f4017094453f3e280623b286f5dc1f0f1dc371fdc2
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ioc_rb (0.
|
4
|
+
ioc_rb (0.4.0)
|
5
5
|
activesupport
|
6
6
|
request_store
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (4.0
|
12
|
-
i18n (~> 0.
|
13
|
-
|
14
|
-
|
15
|
-
thread_safe (~> 0.
|
16
|
-
tzinfo (~>
|
17
|
-
atomic (1.1.14)
|
11
|
+
activesupport (4.2.0)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
16
|
+
tzinfo (~> 1.1)
|
18
17
|
diff-lcs (1.2.5)
|
19
|
-
i18n (0.
|
20
|
-
|
21
|
-
|
18
|
+
i18n (0.7.0)
|
19
|
+
json (1.8.3)
|
20
|
+
minitest (5.8.3)
|
22
21
|
rake (10.1.1)
|
23
22
|
request_store (1.0.5)
|
24
23
|
rspec (2.14.1)
|
@@ -29,9 +28,9 @@ GEM
|
|
29
28
|
rspec-expectations (2.14.4)
|
30
29
|
diff-lcs (>= 1.1.3, < 2.0)
|
31
30
|
rspec-mocks (2.14.4)
|
32
|
-
thread_safe (0.
|
33
|
-
|
34
|
-
|
31
|
+
thread_safe (0.3.5)
|
32
|
+
tzinfo (1.2.2)
|
33
|
+
thread_safe (~> 0.1)
|
35
34
|
|
36
35
|
PLATFORMS
|
37
36
|
ruby
|
@@ -41,3 +40,6 @@ DEPENDENCIES
|
|
41
40
|
ioc_rb!
|
42
41
|
rake
|
43
42
|
rspec
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.11.2
|
data/lib/ioc_rb/container.rb
CHANGED
@@ -18,6 +18,7 @@ module IocRb
|
|
18
18
|
# @param resources [Array] array of procs with container's beans definitions
|
19
19
|
# @param &block [Proc] optional proc with container's beans definitions
|
20
20
|
def initialize(const_loader = DEFAULT_CONST_LOADER, &block)
|
21
|
+
@const_loader = const_loader
|
21
22
|
@beans_metadata_storage = IocRb::BeansMetadataStorage.new
|
22
23
|
@bean_factory = IocRb::BeanFactory.new(const_loader, @beans_metadata_storage)
|
23
24
|
|
@@ -72,5 +73,16 @@ module IocRb
|
|
72
73
|
@bean_factory.get_bean(name)
|
73
74
|
end
|
74
75
|
|
76
|
+
# Load defined in bean classes
|
77
|
+
# this is needed for production usage
|
78
|
+
# for eager loading
|
79
|
+
def eager_load_bean_classes
|
80
|
+
@beans_metadata_storage.bean_classes.each do |bean_class|
|
81
|
+
if !bean_class.is_a?(Class)
|
82
|
+
@const_loader.load_const(bean_class)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
75
87
|
end
|
76
88
|
end
|
data/lib/ioc_rb/version.rb
CHANGED
@@ -33,6 +33,23 @@ describe IocRb::Container do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
describe "eager_load_bean_classes" do
|
37
|
+
let(:container) do
|
38
|
+
container = IocRb::Container.new
|
39
|
+
container.bean(:appender, class: 'Appender')
|
40
|
+
container.bean(:logger, class: 'Logger') do
|
41
|
+
attr :appender, ref: :appender
|
42
|
+
end
|
43
|
+
container.bean(:printer, class: 'Printer', instance: false)
|
44
|
+
container
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should eager load bean classes" do
|
48
|
+
container.eager_load_bean_classes
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
36
53
|
describe "#replace_bean" do
|
37
54
|
it "should replace bean definition" do
|
38
55
|
container = IocRb::Container.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ioc_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Gazizov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: request_store
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.2.
|
123
|
+
rubygems_version: 2.2.5
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Inversion of Controll Container
|