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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d087ab33f12eb4a96aeedc806223df30c87f9b07
4
- data.tar.gz: 04818970eaf8cab13deac3780cc24a9fbcaf13f8
3
+ metadata.gz: 4c7072e73dc2252039b8c04abc90aadbbf75c773
4
+ data.tar.gz: ee3f8369255712f3f5263767f276a383e8606420
5
5
  SHA512:
6
- metadata.gz: a10d27b132fdbf112bcc29738f450a27b865acbc4e0061818dfc30a5d6594c0634fe63730c7586d52b58225ac6f1bd8ad75209143305efdb18c09989cbfd4548
7
- data.tar.gz: 60ed44c13c5232429d1ebfd0290b6b33f9f44580c5eddcf47adad84ab6fa9314de95fb48c69490693c5d9d5846db74cab3bec874283f937fa6ab9814d2b92c21
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
- # load *.rb file if extra bean location was added or it was not loaded yet
12
- location_count = locations.values.flatten.size
13
-
14
- if !@loaded_locations.has_key?(bean_name) || @loaded_locations[bean_name] != location_count
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
@@ -1,3 +1,3 @@
1
1
  module SmartIoC
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.18"
3
3
  end
@@ -1,19 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SmartIoC::BeanFactory do
4
- class Repo
5
- include SmartIoC::Iocify
6
- bean :repo, context: :default, package: :bean_factory
7
- end
4
+ before :all do
5
+ SmartIoC.clear
8
6
 
9
- class TestRepo
10
- include SmartIoC::Iocify
11
- bean :repo, context: :test, package: :bean_factory
12
- end
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
- class DAO
15
- include SmartIoC::Iocify
16
- bean :dao, context: :default, package: :bean_factory
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
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Object do
4
+ before :all do
5
+ SmartIoC.clear
6
+ end
7
+
4
8
  describe '::inject' do
5
9
  before :all do
6
10
  class TestClass
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.17
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: 2016-12-27 00:00:00.000000000 Z
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