smart_injection 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +5 -4
- data/README.md +17 -2
- data/lib/smart_core/injection/locator/dependency.rb +28 -6
- data/lib/smart_core/injection/locator/factory.rb +8 -3
- data/lib/smart_core/injection/locator.rb +14 -2
- data/lib/smart_core/injection/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f3e7313fff33403ea88f194361cce0c1663621df28a4f4155d976206df2c93
|
4
|
+
data.tar.gz: 530212534a8f8b83b111bd81d78f262e05e6d20c4284088128420ef572ac5832
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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.
|
87
|
-
smart_engine (~> 0.
|
88
|
-
smart_engine (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 · <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> · [![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) { -> {
|
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
|
-
|
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.
|
36
|
+
# @since 0.2.0
|
37
|
+
# @version 0.3.0
|
33
38
|
def bind(&block)
|
34
39
|
with_barrier do
|
35
|
-
|
36
|
-
|
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
|
-
|
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(
|
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
|
-
|
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
|
-
@
|
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
|
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.
|
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:
|
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.
|
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
|