smart_ioc 0.1.17 → 0.1.18
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 +4 -4
- data/lib/smart_ioc/bean_file_loader.rb +5 -12
- data/lib/smart_ioc/version.rb +1 -1
- data/spec/smart_ioc/bean_factory_spec.rb +15 -11
- data/spec/smart_ioc/bean_file_loader_spec.rb +21 -0
- data/spec/smart_ioc/object_spec.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c7072e73dc2252039b8c04abc90aadbbf75c773
|
4
|
+
data.tar.gz: ee3f8369255712f3f5263767f276a383e8606420
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6787d8889e1b732a0504b985420586554011fc7f4771a633172d66ca8b4c390bddea636524b33207ae086e0877c2ce3548d90a276bc3c9aa36fadf5954723533
|
7
|
+
data.tar.gz: b5007f88e1a4cc16e9410e737d488c0a85c5ae21a0a3b76800348936e518755318503b2d16c27209de7013d9cbccb139f593a13b6ce9bea1c2c7281a7f8dfe88
|
@@ -6,19 +6,12 @@ class SmartIoC::BeanFileLoader
|
|
6
6
|
# @param bean_name [Symbol] bean name
|
7
7
|
# return nil
|
8
8
|
def require_bean(bean_name)
|
9
|
-
locations = SmartIoC::BeanLocations.get_bean_locations(bean_name)
|
9
|
+
locations = SmartIoC::BeanLocations.get_bean_locations(bean_name).values.flatten
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
locations.each do |package_name, locations|
|
16
|
-
locations.each do |location|
|
17
|
-
require location
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
@loaded_locations[bean_name] = location_count
|
11
|
+
locations.each do |location|
|
12
|
+
next if @loaded_locations.has_key?(location)
|
13
|
+
@loaded_locations[location] = true
|
14
|
+
load location
|
22
15
|
end
|
23
16
|
|
24
17
|
nil
|
data/lib/smart_ioc/version.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SmartIoC::BeanFactory do
|
4
|
-
|
5
|
-
|
6
|
-
bean :repo, context: :default, package: :bean_factory
|
7
|
-
end
|
4
|
+
before :all do
|
5
|
+
SmartIoC.clear
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
class Repo
|
8
|
+
include SmartIoC::Iocify
|
9
|
+
bean :repo, context: :default, package: :bean_factory
|
10
|
+
end
|
11
|
+
|
12
|
+
class TestRepo
|
13
|
+
include SmartIoC::Iocify
|
14
|
+
bean :repo, context: :test, package: :bean_factory
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
class DAO
|
18
|
+
include SmartIoC::Iocify
|
19
|
+
bean :dao, context: :default, package: :bean_factory
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
it 'returns proper bean for test context' do
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SmartIoC::BeanFileLoader 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
|
+
@container = SmartIoC::Container.get_instance
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'requires beans only once' do
|
17
|
+
repository = @container.get_bean(:repository, package: :admins, context: :test)
|
18
|
+
repository = @container.get_bean(:repository, package: :admins, context: :test)
|
19
|
+
expect(repository.get(1)).to eq(nil)
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_ioc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
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: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- smart_ioc.gemspec
|
74
74
|
- spec/smart_ioc/bean_definition_spec.rb
|
75
75
|
- spec/smart_ioc/bean_factory_spec.rb
|
76
|
+
- spec/smart_ioc/bean_file_loader_spec.rb
|
76
77
|
- spec/smart_ioc/bean_locator_spec.rb
|
77
78
|
- spec/smart_ioc/example/admins/repository/admins_dao.rb
|
78
79
|
- spec/smart_ioc/example/admins/repository/admins_repository.rb
|
@@ -113,6 +114,7 @@ summary: Inversion of Control Container
|
|
113
114
|
test_files:
|
114
115
|
- spec/smart_ioc/bean_definition_spec.rb
|
115
116
|
- spec/smart_ioc/bean_factory_spec.rb
|
117
|
+
- spec/smart_ioc/bean_file_loader_spec.rb
|
116
118
|
- spec/smart_ioc/bean_locator_spec.rb
|
117
119
|
- spec/smart_ioc/example/admins/repository/admins_dao.rb
|
118
120
|
- spec/smart_ioc/example/admins/repository/admins_repository.rb
|