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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85f0f26c7d82aeb28d8f04d99d0c52ebdeed61b5
4
- data.tar.gz: 12d2af5706bf986c5c4b01c4fc6fd0a7c8910c9f
3
+ metadata.gz: 7cdaa166b74b872446a6ae30c0b18ddc7a74e94c
4
+ data.tar.gz: 41f3d362e8e3f257a0efdcc77c357faf12682c24
5
5
  SHA512:
6
- metadata.gz: e6ada01c013048e28219bcf6b2aa06adb2e9a31790263eced54e6b8a818fb3e74729df5553c7d2df2ab48408a7b0a55d325a67f783c674fda8bce5c6b279876d
7
- data.tar.gz: 36cdcc328ddd3e1c34a8fd2e377ccef29696924df2436269b40849f5cae88dae80d4c5c50084813217db9478ed0cce39aa502a61648ec13e447c5c453326bb26
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.3.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.2)
12
- i18n (~> 0.6, >= 0.6.4)
13
- minitest (~> 4.2)
14
- multi_json (~> 1.3)
15
- thread_safe (~> 0.1)
16
- tzinfo (~> 0.3.37)
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.6.9)
20
- minitest (4.7.5)
21
- multi_json (1.8.4)
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.1.3)
33
- atomic
34
- tzinfo (0.3.38)
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
@@ -16,4 +16,8 @@ class IocRb::BeansMetadataStorage
16
16
  def put(bean_metadata)
17
17
  @bean_metadatas[bean_metadata.name] = bean_metadata
18
18
  end
19
+
20
+ def bean_classes
21
+ @bean_metadatas.values.map(&:bean_class)
22
+ end
19
23
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module IocRb
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -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.3.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: 2015-08-12 00:00:00.000000000 Z
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.2
123
+ rubygems_version: 2.2.5
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Inversion of Controll Container