smart_ioc 0.2.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile +1 -0
- data/Gemfile.lock +27 -26
- data/lib/smart_ioc.rb +23 -3
- data/lib/smart_ioc/args.rb +1 -1
- data/lib/smart_ioc/bean.rb +33 -0
- data/lib/smart_ioc/bean_definition.rb +8 -4
- data/lib/smart_ioc/bean_definitions_storage.rb +27 -6
- data/lib/smart_ioc/bean_factory.rb +38 -179
- data/lib/smart_ioc/container.rb +20 -15
- data/lib/smart_ioc/errors.rb +13 -15
- data/lib/smart_ioc/extra_package_contexts.rb +4 -0
- data/lib/smart_ioc/iocify.rb +78 -16
- data/lib/smart_ioc/version.rb +1 -1
- data/smart_ioc.gemspec +1 -1
- data/spec/smart_ioc/bean_definition_spec.rb +10 -10
- data/spec/smart_ioc/bean_factory_spec.rb +49 -23
- data/spec/smart_ioc/benchmark_mode_spec.rb +13 -0
- data/spec/smart_ioc/example/admins/repository/admins_dao.rb +8 -8
- data/spec/smart_ioc/example/admins/repository/admins_repository.rb +2 -5
- data/spec/smart_ioc/example/users/repository/users_dao.rb +5 -3
- data/spec/smart_ioc/example/users/repository/users_repository.rb +2 -0
- data/spec/smart_ioc/example/utils/config.rb +5 -1
- data/spec/smart_ioc/factory_method_spec.rb +7 -7
- data/spec/smart_ioc/object_spec.rb +1 -1
- data/spec/smart_ioc/recursive_spec.rb +24 -0
- metadata +12 -9
- data/lib/smart_ioc/scopes/bean.rb +0 -13
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SmartIoC do
|
4
|
+
it {
|
5
|
+
SmartIoC.clear
|
6
|
+
SmartIoC.benchmark_mode(true)
|
7
|
+
|
8
|
+
dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/admins')
|
9
|
+
SmartIoC.find_package_beans(:admins, dir_path)
|
10
|
+
|
11
|
+
SmartIoC.benchmark_mode(false)
|
12
|
+
}
|
13
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class AdminsDAO
|
4
|
-
include SmartIoC::Iocify
|
5
|
-
|
6
|
-
bean :dao, instance: false
|
1
|
+
bean :dao do
|
2
|
+
after_init :setup
|
7
3
|
|
8
4
|
inject :config
|
9
5
|
|
10
6
|
class << self
|
7
|
+
def setup
|
8
|
+
@data = {}
|
9
|
+
end
|
10
|
+
|
11
11
|
def insert(entity)
|
12
12
|
config.app_name
|
13
|
-
|
13
|
+
@data[entity.id] = entity
|
14
14
|
end
|
15
15
|
|
16
16
|
def get(id)
|
17
|
-
|
17
|
+
@data[id]
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class UsersDAO
|
2
2
|
include SmartIoC::Iocify
|
3
3
|
|
4
|
-
bean :dao, instance: false
|
5
|
-
|
6
|
-
@data = {}
|
4
|
+
bean :dao, instance: false, after_init: :setup
|
7
5
|
|
8
6
|
class << self
|
7
|
+
def setup
|
8
|
+
@data = {}
|
9
|
+
end
|
10
|
+
|
9
11
|
def insert(entity)
|
10
12
|
@data[entity.id] = entity
|
11
13
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
class Config
|
2
2
|
include SmartIoC::Iocify
|
3
3
|
|
4
|
-
bean :config, factory_method: :get_config
|
4
|
+
bean :config, factory_method: :get_config, after_init: :setup
|
5
5
|
|
6
6
|
class TestConfig
|
7
|
+
def setup
|
8
|
+
# do nothing; only for testing purposes
|
9
|
+
end
|
10
|
+
|
7
11
|
def app_name
|
8
12
|
'SmartIoC'
|
9
13
|
end
|
@@ -9,7 +9,7 @@ describe 'Factory Method' do
|
|
9
9
|
|
10
10
|
inject :test_config
|
11
11
|
|
12
|
-
|
12
|
+
public :test_config
|
13
13
|
end
|
14
14
|
|
15
15
|
|
@@ -20,7 +20,7 @@ describe 'Factory Method' do
|
|
20
20
|
|
21
21
|
inject :test_config
|
22
22
|
|
23
|
-
|
23
|
+
public :test_config
|
24
24
|
end
|
25
25
|
|
26
26
|
class TestConfig
|
@@ -52,7 +52,7 @@ describe 'Factory Method' do
|
|
52
52
|
before :all do
|
53
53
|
class SingletonBean
|
54
54
|
include SmartIoC::Iocify
|
55
|
-
|
55
|
+
|
56
56
|
bean :singleton_bean, package: :cross_refference
|
57
57
|
end
|
58
58
|
|
@@ -61,10 +61,10 @@ describe 'Factory Method' do
|
|
61
61
|
|
62
62
|
bean :other_singleton_bean, package: :cross_refference
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
class FactoryConfig
|
66
66
|
include SmartIoC::Iocify
|
67
|
-
|
67
|
+
|
68
68
|
bean :factory_config, factory_method: :build, package: :cross_refference
|
69
69
|
|
70
70
|
inject :singleton_bean
|
@@ -85,7 +85,7 @@ describe 'Factory Method' do
|
|
85
85
|
|
86
86
|
class FactoryLogger
|
87
87
|
include SmartIoC::Iocify
|
88
|
-
|
88
|
+
|
89
89
|
bean :factory_logger, factory_method: :build, package: :cross_refference
|
90
90
|
|
91
91
|
inject :factory_config
|
@@ -99,7 +99,7 @@ describe 'Factory Method' do
|
|
99
99
|
@singleton_bean = singleton_bean
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def build
|
104
104
|
Logger.new(factory_config, singleton_bean)
|
105
105
|
end
|
@@ -32,7 +32,7 @@ describe Object do
|
|
32
32
|
factory_method: :my_method, context: :test
|
33
33
|
end
|
34
34
|
|
35
|
-
@bean_definition = SmartIoC.
|
35
|
+
@bean_definition = SmartIoC.get_bean_definition(:my_bean, :my_package, :test)
|
36
36
|
end
|
37
37
|
|
38
38
|
it { expect(@bean_definition.name).to eq(:my_bean) }
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SmartIoC::Container do
|
4
|
+
before :all do
|
5
|
+
SmartIoC.clear
|
6
|
+
|
7
|
+
dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/admins')
|
8
|
+
SmartIoC.find_package_beans(:admins, dir_path)
|
9
|
+
|
10
|
+
dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/utils')
|
11
|
+
SmartIoC.find_package_beans(:utils, dir_path)
|
12
|
+
|
13
|
+
dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/users')
|
14
|
+
SmartIoC.find_package_beans(:users, dir_path)
|
15
|
+
|
16
|
+
@container = SmartIoC.container
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'loads recursive beans' do
|
20
|
+
users_creator = @container.get_bean(:users_creator)
|
21
|
+
uc2 = users_creator.send(:repository).users_creator
|
22
|
+
expect(users_creator).to eq(uc2)
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_ioc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-16 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
|
-
version: '
|
19
|
+
version: '0'
|
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
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- docs/index.md
|
74
74
|
- lib/smart_ioc.rb
|
75
75
|
- lib/smart_ioc/args.rb
|
76
|
+
- lib/smart_ioc/bean.rb
|
76
77
|
- lib/smart_ioc/bean_definition.rb
|
77
78
|
- lib/smart_ioc/bean_definitions_storage.rb
|
78
79
|
- lib/smart_ioc/bean_dependency.rb
|
@@ -87,7 +88,6 @@ files:
|
|
87
88
|
- lib/smart_ioc/iocify.rb
|
88
89
|
- lib/smart_ioc/railtie.rb
|
89
90
|
- lib/smart_ioc/scopes.rb
|
90
|
-
- lib/smart_ioc/scopes/bean.rb
|
91
91
|
- lib/smart_ioc/scopes/prototype.rb
|
92
92
|
- lib/smart_ioc/scopes/request.rb
|
93
93
|
- lib/smart_ioc/scopes/singleton.rb
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- spec/smart_ioc/bean_file_loader_spec.rb
|
99
99
|
- spec/smart_ioc/bean_locations_spec.rb
|
100
100
|
- spec/smart_ioc/bean_locator_spec.rb
|
101
|
+
- spec/smart_ioc/benchmark_mode_spec.rb
|
101
102
|
- spec/smart_ioc/container_spec.rb
|
102
103
|
- spec/smart_ioc/example/admins/repository/admins_dao.rb
|
103
104
|
- spec/smart_ioc/example/admins/repository/admins_repository.rb
|
@@ -111,6 +112,7 @@ files:
|
|
111
112
|
- spec/smart_ioc/factory_method_spec.rb
|
112
113
|
- spec/smart_ioc/iocify_spec.rb
|
113
114
|
- spec/smart_ioc/object_spec.rb
|
115
|
+
- spec/smart_ioc/recursive_spec.rb
|
114
116
|
- spec/smart_ioc/smart_ioc_spec.rb
|
115
117
|
- spec/spec_helper.rb
|
116
118
|
homepage: http://github.com/droidlabs/smart_ioc
|
@@ -132,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
134
|
- !ruby/object:Gem::Version
|
133
135
|
version: '0'
|
134
136
|
requirements: []
|
135
|
-
|
136
|
-
rubygems_version: 2.5.2
|
137
|
+
rubygems_version: 3.0.3
|
137
138
|
signing_key:
|
138
139
|
specification_version: 4
|
139
140
|
summary: Inversion of Control Container
|
@@ -143,6 +144,7 @@ test_files:
|
|
143
144
|
- spec/smart_ioc/bean_file_loader_spec.rb
|
144
145
|
- spec/smart_ioc/bean_locations_spec.rb
|
145
146
|
- spec/smart_ioc/bean_locator_spec.rb
|
147
|
+
- spec/smart_ioc/benchmark_mode_spec.rb
|
146
148
|
- spec/smart_ioc/container_spec.rb
|
147
149
|
- spec/smart_ioc/example/admins/repository/admins_dao.rb
|
148
150
|
- spec/smart_ioc/example/admins/repository/admins_repository.rb
|
@@ -156,5 +158,6 @@ test_files:
|
|
156
158
|
- spec/smart_ioc/factory_method_spec.rb
|
157
159
|
- spec/smart_ioc/iocify_spec.rb
|
158
160
|
- spec/smart_ioc/object_spec.rb
|
161
|
+
- spec/smart_ioc/recursive_spec.rb
|
159
162
|
- spec/smart_ioc/smart_ioc_spec.rb
|
160
163
|
- spec/spec_helper.rb
|