smart_ioc 0.1.30 → 0.2.0

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: 0146809a105a5135977a543956a5929d6dca9951
4
- data.tar.gz: 51c86019fa338d8008bdf120dd17acc5be8e9f95
3
+ metadata.gz: 9e4ad2f8d73d09ec4aa7bc84c8bd2b78f302f52c
4
+ data.tar.gz: 3cc1419f66178f8ceb0adb3d373f5c691c0c66ab
5
5
  SHA512:
6
- metadata.gz: fb68c1a7b8e4b7844ea8fb39f1cf7cb5711251d64e7b73516066b9aae85b3de013577ccfb2f742f136fb86d38318d6b72546862df4d2ae5e3c9a941110eddee6
7
- data.tar.gz: 13b01014967f0c0677aca18cc06556e6a7a1bbc7265cb7e5f6aeb6e9165f6602112594b0f6876b3d10d94a08346abfb089df4c6ceaffc6a1c5ef5727609d0eb9
6
+ metadata.gz: fa1317bdef1810f0822d31fb6c58c05a9da9d9e38dfab022f703f527e6dd60c7b2f267ae8d5b84da2ce5f57edce126020d116324badc8b645e0653fa7e618d09
7
+ data.tar.gz: 3d3fc1d281a26604b9356c45da596691e2d6e36fa8a099f76b8c382031a6791ed39c76221884239d3fb7eb5db071574bb047499224197e8e6d3945282d0c0210
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_ioc (0.1.30)
4
+ smart_ioc (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -48,4 +48,4 @@ DEPENDENCIES
48
48
  smart_ioc!
49
49
 
50
50
  BUNDLED WITH
51
- 1.14.5
51
+ 1.15.1
@@ -22,4 +22,8 @@ class SmartIoC::BeanFileLoader
22
22
 
23
23
  nil
24
24
  end
25
+
26
+ def clear_locations
27
+ @loaded_locations = {}
28
+ end
25
29
  end
@@ -69,5 +69,12 @@ class SmartIoC::BeanLocations
69
69
 
70
70
  nil
71
71
  end
72
+
73
+ def get_all_bean_files
74
+ @data
75
+ .map { |_, bean_locations| bean_locations.values }
76
+ .flatten
77
+ .uniq
78
+ end
72
79
  end
73
80
  end
@@ -128,6 +128,7 @@ module SmartIoC
128
128
 
129
129
  def force_clear_scopes
130
130
  bean_factory.force_clear_scopes
131
+ bean_factory.bean_file_loader.clear_locations
131
132
  end
132
133
 
133
134
  private
@@ -0,0 +1,24 @@
1
+ class SmartIoC::Railtie < Rails::Railtie
2
+ initializer "smart_ioc.watching_for_bean_changes" do |app|
3
+ if app.config.reload_classes_only_on_change
4
+ bean_file_locations = SmartIoC::BeanLocations.get_all_bean_files
5
+
6
+ reloader = app.config.file_watcher.new(bean_file_locations) do
7
+ SmartIoC.container.force_clear_scopes
8
+ end
9
+
10
+ app.config.to_prepare { reloader.execute_if_updated }
11
+ end
12
+ end
13
+
14
+ console do
15
+ module Rails::ConsoleMethods
16
+ alias :old_reload! :reload!
17
+
18
+ def reload!(print = true)
19
+ SmartIoC.container.force_clear_scopes
20
+ old_reload!(print = true)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module SmartIoC
2
- VERSION = "0.1.30"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/smart_ioc.rb CHANGED
@@ -26,6 +26,8 @@ module SmartIoC
26
26
  require 'smart_ioc/errors'
27
27
  end
28
28
 
29
+ require 'smart_ioc/railtie' if defined?(Rails)
30
+
29
31
  class << self
30
32
  # @param package_name [String or Symbol] package name for bean definitions
31
33
  # @param dir [String] absolute path with bean definitions
@@ -1,3 +1,5 @@
1
+ $data ||= {}
2
+
1
3
  class AdminsDAO
2
4
  include SmartIoC::Iocify
3
5
 
@@ -5,16 +7,14 @@ class AdminsDAO
5
7
 
6
8
  inject :config
7
9
 
8
- @data = {}
9
-
10
10
  class << self
11
11
  def insert(entity)
12
12
  config.app_name
13
- @data[entity.id] = entity
13
+ $data[entity.id] = entity
14
14
  end
15
15
 
16
16
  def get(id)
17
- @data[id]
17
+ $data[id]
18
18
  end
19
19
  end
20
20
  end
@@ -1,17 +1,17 @@
1
+ $data ||= {}
2
+
1
3
  class TestAdminsRepository
2
4
  include SmartIoC::Iocify
3
5
 
4
6
  bean :repository, context: :test, instance: false
5
7
 
6
- @data = {}
7
-
8
8
  class << self
9
9
  def put(user)
10
- @data[user.id] = user
10
+ $data[user.id] = user
11
11
  end
12
12
 
13
13
  def get(id)
14
- @data[id]
14
+ $data[id]
15
15
  end
16
16
  end
17
17
  end
@@ -12,6 +12,7 @@ describe 'Factory Method' do
12
12
  attr_reader :test_config
13
13
  end
14
14
 
15
+
15
16
  class OtherService
16
17
  include SmartIoC::Iocify
17
18
 
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.30
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,7 @@ files:
84
84
  - lib/smart_ioc/extra_package_contexts.rb
85
85
  - lib/smart_ioc/inject_metadata.rb
86
86
  - lib/smart_ioc/iocify.rb
87
+ - lib/smart_ioc/railtie.rb
87
88
  - lib/smart_ioc/scopes.rb
88
89
  - lib/smart_ioc/scopes/bean.rb
89
90
  - lib/smart_ioc/scopes/prototype.rb
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  version: '0'
131
132
  requirements: []
132
133
  rubyforge_project:
133
- rubygems_version: 2.5.1
134
+ rubygems_version: 2.6.12
134
135
  signing_key:
135
136
  specification_version: 4
136
137
  summary: Inversion of Control Container