smart_injection 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: be2ddc375b6609c3bfa9ffebf1b7b85ddccdaa60018e563feeb10ae5693c637e
4
- data.tar.gz: 3ca99d637fed907c2a2241d01a704eea1eb9d538ce61b29d741925b62d75bef1
3
+ metadata.gz: d2f3e7313fff33403ea88f194361cce0c1663621df28a4f4155d976206df2c93
4
+ data.tar.gz: 530212534a8f8b83b111bd81d78f262e05e6d20c4284088128420ef572ac5832
5
5
  SHA512:
6
- metadata.gz: bf831df6f117f75c3ff7eca97ebe7467bc87b4b4464851d2a489f71ac959f59fa101fba123cd194a10501f43617ebfee73d68643bd3968049ba0942cbfa1c269
7
- data.tar.gz: 465ab0c6f1849d045776c9e88e448872fbf5785641286a94205a9a770d4f56518206f473b9f0d1c29109648f90ebc4206c5ba4ed85cfefea2619dcceaa824da8
6
+ metadata.gz: 2823f1a312b377c04eba486c553f379a53dfb5327571e52493aa55e8a9311ee6b6aaf35414c0459fe3483d2a33722205ddd6c3eb89c697c60e458ddf0e373032
7
+ data.tar.gz: 1706bdfd3038fdf5856a87b944be5dc2b972112997d26688ba95a4fe895706eb10b1c428d67620b2f7c29cb9f764bd2ef1b8e9452f98419926475cefa2c941c0
data/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ # [0.3.0] - 2023-01-13
5
+ ## Changed
6
+ - Temporary disabled hard depenedncy binding of dependency locator.
7
+ The nature of dependency binding inside the injectable class will be reviewed and reworked
8
+ in dependncy injection terms and theory (need to be reviewed current "bind" behavior).
9
+ Memoization now working in runtime mode with container and dependcy locator in combination.
10
+
4
11
  # [0.2.0] - 2021-01-18
5
12
  ## Added
6
- - Support for *Ruby@3*;
13
+ - Support for **Ruby@3**;
7
14
 
8
15
  ## Changed
9
16
  - No more `TravisCI` (todo: migrate to `GitHub Actions`);
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_injection (0.2.0)
4
+ smart_injection (0.3.0)
5
5
  smart_container (~> 0.9)
6
6
  smart_engine (~> 0.11)
7
7
 
@@ -83,15 +83,16 @@ GEM
83
83
  simplecov_json_formatter (~> 0.1)
84
84
  simplecov-html (0.12.3)
85
85
  simplecov_json_formatter (0.1.2)
86
- smart_container (0.9.0)
87
- smart_engine (~> 0.11)
88
- smart_engine (0.11.0)
86
+ smart_container (0.11.0)
87
+ smart_engine (~> 0.17)
88
+ smart_engine (0.17.0)
89
89
  tzinfo (2.0.4)
90
90
  concurrent-ruby (~> 1.0)
91
91
  unicode-display_width (1.7.0)
92
92
  zeitwerk (2.4.2)
93
93
 
94
94
  PLATFORMS
95
+ arm64-darwin-21
95
96
  x86_64-darwin-20
96
97
 
97
98
  DEPENDENCIES
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
- # SmartCore::Injection · [![Gem Version](https://badge.fury.io/rb/smart_injection.svg)](https://badge.fury.io/rb/smart_injection)
1
+ # SmartCore::Injection &middot; <a target="_blank" href="https://github.com/Cado-Labs"><img src="https://github.com/Cado-Labs/cado-labs-logos/raw/main/cado_labs_badge.svg" alt="Supported by Cado Labs" style="max-width: 100%; height: 20px"></a> &middot; [![Gem Version](https://badge.fury.io/rb/smart_injection.svg)](https://badge.fury.io/rb/smart_injection)
2
2
 
3
3
  Dependency injection principles and idioms realized in scope of Ruby. Support for method-injeciton strategy, container-based dependency resolving, static and dynamic bindings and etc.
4
4
 
5
5
  ---
6
6
 
7
+ <p>
8
+ <a href="https://github.com/Cado-Labs">
9
+ <img src="https://github.com/Cado-Labs/cado-labs-logos/blob/main/cado_labs_supporting.svg" alt="Supported by Cado Labs" />
10
+ </a>
11
+ </p>
12
+
13
+ ---
14
+
7
15
  ## Major Features
8
16
 
9
17
  - `method-injection` strategy
@@ -66,7 +74,7 @@ end
66
74
 
67
75
  ServiceContainer = SmartCore::Container.define do
68
76
  namespace(:rands) do
69
- register(:alphanum) { -> { SeureRandom.alphanumeric } }
77
+ register(:alphanum) { -> { SecureRandom.alphanumeric } }
70
78
  register(:hex) { -> { SecureRandom.hex } }
71
79
  end
72
80
  end
@@ -122,6 +130,7 @@ end
122
130
  - **[0.3.0]** - support for default injection configuration which should be specified in `SmartCore::Injection` module inclusion (in addition to default containers)
123
131
  - **[0.x.0]** - more docs, more examples, more tips-and-tricks :)
124
132
  - **[0.x.0]** - migrate to GithubActions;
133
+ - **[0.x.0]** - type signatures (rbs);
125
134
 
126
135
  ---
127
136
 
@@ -159,6 +168,12 @@ bundle exec rake rubocop -A
159
168
 
160
169
  Released under MIT License.
161
170
 
171
+ ## Supporting
172
+
173
+ <a href="https://github.com/Cado-Labs">
174
+ <img src="https://github.com/Cado-Labs/cado-labs-logos/blob/main/cado_labs_logo.png" alt="Supported by Cado Labs" />
175
+ </a>
176
+
162
177
  ## Authors
163
178
 
164
179
  [Rustam Ibragimov](https://github.com/0exp)
@@ -2,14 +2,18 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
+ # @version 0.3.0
5
6
  class SmartCore::Injection::Locator::Dependency
7
+ # @option memoize [Boolean]
6
8
  # @return [void]
7
9
  #
8
10
  # @api private
9
11
  # @since 0.1.0
10
- def initialize
12
+ # @version 0.3.0
13
+ def initialize(memoize:)
11
14
  @binded = false
12
15
  @value = nil
16
+ @memoize = memoize
13
17
  @barrier = SmartCore::Engine::Lock.new
14
18
  end
15
19
 
@@ -29,14 +33,32 @@ class SmartCore::Injection::Locator::Dependency
29
33
  # @return [Any]
30
34
  #
31
35
  # @api public
32
- # @since 0.7.0
36
+ # @since 0.2.0
37
+ # @version 0.3.0
33
38
  def bind(&block)
34
39
  with_barrier do
35
- if @binded
36
- @value
40
+ # NOTE:
41
+ # Temporary disabled old variant of dependency resolving
42
+ # cuz we need to reivew the canonical way of dependency resolving
43
+ # and rework the resolving at all on runtime level (under `memoize: true` option).
44
+ # Old code variant:
45
+ #
46
+ # if @binded
47
+ # @value
48
+ # else
49
+ # @binded = true
50
+ # @value = yield
51
+ # end
52
+
53
+ if @memoize
54
+ if @binded
55
+ @value
56
+ else
57
+ @binded = true
58
+ @value = yield
59
+ end
37
60
  else
38
- @binded = true
39
- @value = yield
61
+ yield
40
62
  end
41
63
  end
42
64
  end
@@ -11,7 +11,7 @@ module SmartCore::Injection::Locator::Factory
11
11
  # @since 0.1.0
12
12
  def create(injection_settings, import_key, import_path)
13
13
  container_proxy = create_container_proxy(injection_settings)
14
- create_locator(import_path, container_proxy).tap do |locator|
14
+ create_locator(injection_settings, import_path, container_proxy).tap do |locator|
15
15
  control_injection_memoization(injection_settings, container_proxy, locator, import_path)
16
16
  end
17
17
  end
@@ -29,14 +29,19 @@ module SmartCore::Injection::Locator::Factory
29
29
  )
30
30
  end
31
31
 
32
+ # @param injection_settings [SmartCore::Injection::Injector::InjectionSettings]
32
33
  # @param import_path [String]
33
34
  # @param container_proxy [SmartCore::Injection::Locator::ContainerProxy]
34
35
  # @return [SmartCore::Injection::Locator]
35
36
  #
36
37
  # @api private
37
38
  # @since 0.1.0
38
- def create_locator(import_path, container_proxy)
39
- SmartCore::Injection::Locator.new(import_path, container_proxy)
39
+ def create_locator(injection_settings, import_path, container_proxy)
40
+ SmartCore::Injection::Locator.new(
41
+ import_path,
42
+ container_proxy,
43
+ memoize_dependency: injection_settings.memoize
44
+ )
40
45
  end
41
46
 
42
47
  # @param injection_settings [SmartCore::Injection::Injector::InjectionSettings]
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
+ # @version 0.3.0
5
6
  class SmartCore::Injection::Locator
6
7
  require_relative 'locator/container_proxy'
7
8
  require_relative 'locator/dependency'
@@ -15,14 +16,17 @@ class SmartCore::Injection::Locator
15
16
 
16
17
  # @param import_path [String]
17
18
  # @param container_proxy [SmartCore::Injection::Locator::ContainerProxy]
19
+ # @option memoize_dependency [Boolean]
18
20
  # @return [void]
19
21
  #
20
22
  # @api private
21
23
  # @since 0.1.0
22
- def initialize(import_path, container_proxy)
24
+ # @version 0.3.0
25
+ def initialize(import_path, container_proxy, memoize_dependency:)
23
26
  @import_path = import_path
24
27
  @container_proxy = container_proxy
25
- @dependency = SmartCore::Injection::Locator::Dependency.new
28
+ @memoize_dependency = memoize_dependency
29
+ @dependency = SmartCore::Injection::Locator::Dependency.new(memoize: memoize_dependency)
26
30
  end
27
31
 
28
32
  # @return [Any]
@@ -56,4 +60,12 @@ class SmartCore::Injection::Locator
56
60
  # @api private
57
61
  # @since 0.1.0
58
62
  attr_reader :container_proxy
63
+
64
+ # NOTE: non-usable ivar, added only for commfort debaggung
65
+ # NOTE: will be reworked in next version
66
+ # @return [Boolean]
67
+ #
68
+ # @api private
69
+ # @since 0.3.0
70
+ attr_reader :memoize_dependency
59
71
  end
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.2.0
10
- VERSION = '0.2.0'
9
+ # @version 0.3.0
10
+ VERSION = '0.3.0'
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_injection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-17 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0'
184
184
  requirements: []
185
- rubygems_version: 3.2.3
185
+ rubygems_version: 3.3.7
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: DI principles and idioms realized in scope of Ruby