dry-system 1.1.0.beta1 → 1.1.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 +18 -0
- data/lib/dry/system/provider/source.rb +16 -11
- data/lib/dry/system/provider.rb +4 -1
- data/lib/dry/system/provider_registrar.rb +37 -2
- data/lib/dry/system/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f205d51c4e52d33cd3b0a6cc822abc1d69e943c2fc1b0cae287a7087d5017f1
|
4
|
+
data.tar.gz: 18db35de1a85607fd67e7a77bbb5fceb177c5fedf365efc86c136a217f85227e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32f18c0213fd89f044922654d68a7009bd84c39cdfc0f0bcd18c9f91161774e450608c8270d61054f07ba1fc014c860cc8cd0675138e9458a93250d93ed1fa3b
|
7
|
+
data.tar.gz: 23924c05f775fc91bf517eae45eb15a4a44e18a2a41f68e57ac9f743c18237f56ded8c34d5f7ebbebf3b9f2468a18b7d4496d2c1e8eec4a6a1e5349e18c93906
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 1.1.0 2024-10-31
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
[Compare v1.1.0.beta2...v1.1.0](https://github.com/dry-rb/dry-system/compare/v1.1.0.beta2...v1.1.0)
|
8
|
+
|
9
|
+
## 1.1.0.beta2 2024-09-25
|
10
|
+
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Allow provider sources to use a custom superclass. This requires a custom provider registrar
|
15
|
+
to be configured, with its own implementations of `#provider_source_class` (the superclass to
|
16
|
+
use) and `#provider_source_options` (custom initialization args to pass to the provider
|
17
|
+
source). (via #275) (@alassek, @timriley)
|
18
|
+
|
19
|
+
[Compare v1.1.0.beta1...v1.1.0.beta2](https://github.com/dry-rb/dry-system/compare/v1.1.0.beta1...v1.1.0.beta2)
|
20
|
+
|
3
21
|
## 1.1.0.beta1 2024-07-03
|
4
22
|
|
5
23
|
|
@@ -37,10 +37,20 @@ module Dry
|
|
37
37
|
# @see Dry::System::Provider::SourceDSL
|
38
38
|
#
|
39
39
|
# @api private
|
40
|
-
def for(name:, group: nil, &block)
|
41
|
-
|
40
|
+
def for(name:, group: nil, superclass: nil, &block)
|
41
|
+
superclass ||= self
|
42
|
+
|
43
|
+
Class.new(superclass) { |klass|
|
42
44
|
klass.source_name name
|
43
45
|
klass.source_group group
|
46
|
+
|
47
|
+
name_with_group = group ? "#{group}->#{name}" : name
|
48
|
+
klass.instance_eval <<~RUBY, __FILE__, __LINE__ + 1
|
49
|
+
def name
|
50
|
+
"#{superclass.name}[#{name_with_group}]"
|
51
|
+
end
|
52
|
+
RUBY
|
53
|
+
|
44
54
|
SourceDSL.evaluate(klass, &block) if block
|
45
55
|
}
|
46
56
|
end
|
@@ -58,14 +68,6 @@ module Dry
|
|
58
68
|
end
|
59
69
|
end
|
60
70
|
|
61
|
-
# @api private
|
62
|
-
def name
|
63
|
-
source_str = source_name
|
64
|
-
source_str = "#{source_group}->#{source_str}" if source_group
|
65
|
-
|
66
|
-
"Dry::System::Provider::Source[#{source_str}]"
|
67
|
-
end
|
68
|
-
|
69
71
|
# @api private
|
70
72
|
def to_s
|
71
73
|
"#<#{name}>"
|
@@ -117,7 +119,10 @@ module Dry
|
|
117
119
|
#
|
118
120
|
# @api public
|
119
121
|
attr_reader :target_container
|
120
|
-
|
122
|
+
|
123
|
+
# @see #target_container
|
124
|
+
# @api public
|
125
|
+
def target = target_container
|
121
126
|
|
122
127
|
# @api private
|
123
128
|
def initialize(provider_container:, target_container:, &block)
|
data/lib/dry/system/provider.rb
CHANGED
@@ -127,7 +127,8 @@ module Dry
|
|
127
127
|
attr_reader :source
|
128
128
|
|
129
129
|
# @api private
|
130
|
-
|
130
|
+
# rubocop:disable Layout/LineLength, Style/KeywordParametersOrder
|
131
|
+
def initialize(name:, namespace: nil, target_container:, source_class:, source_options: {}, &block)
|
131
132
|
@name = name
|
132
133
|
@namespace = namespace
|
133
134
|
@target_container = target_container
|
@@ -137,11 +138,13 @@ module Dry
|
|
137
138
|
@step_running = nil
|
138
139
|
|
139
140
|
@source = source_class.new(
|
141
|
+
**source_options,
|
140
142
|
provider_container: provider_container,
|
141
143
|
target_container: target_container,
|
142
144
|
&block
|
143
145
|
)
|
144
146
|
end
|
147
|
+
# rubocop:enable Layout/LineLength, Style/KeywordParametersOrder
|
145
148
|
|
146
149
|
# Runs the `prepare` lifecycle step.
|
147
150
|
#
|
@@ -136,6 +136,21 @@ module Dry
|
|
136
136
|
}.first
|
137
137
|
end
|
138
138
|
|
139
|
+
# Extension point for subclasses to customize their
|
140
|
+
# provider source superclass. Expected to be a subclass
|
141
|
+
# of Dry::System::Provider::Source
|
142
|
+
#
|
143
|
+
# @api public
|
144
|
+
# @since 1.1.0
|
145
|
+
def provider_source_class = Dry::System::Provider::Source
|
146
|
+
|
147
|
+
# Extension point for subclasses to customize initialization
|
148
|
+
# params for provider_source_class
|
149
|
+
#
|
150
|
+
# @api public
|
151
|
+
# @since 1.1.0
|
152
|
+
def provider_source_options = {}
|
153
|
+
|
139
154
|
# @api private
|
140
155
|
def finalize!
|
141
156
|
provider_files.each do |path|
|
@@ -196,25 +211,45 @@ module Dry
|
|
196
211
|
end
|
197
212
|
|
198
213
|
def build_provider(name, options:, source: nil, &block)
|
199
|
-
source_class = source || Provider::Source.for(
|
214
|
+
source_class = source || Provider::Source.for(
|
215
|
+
name: name,
|
216
|
+
superclass: provider_source_class,
|
217
|
+
&block
|
218
|
+
)
|
219
|
+
|
220
|
+
source_options =
|
221
|
+
if source_class < provider_source_class
|
222
|
+
provider_source_options
|
223
|
+
else
|
224
|
+
{}
|
225
|
+
end
|
200
226
|
|
201
227
|
Provider.new(
|
202
228
|
**options,
|
203
229
|
name: name,
|
204
230
|
target_container: target_container,
|
205
|
-
source_class: source_class
|
231
|
+
source_class: source_class,
|
232
|
+
source_options: source_options
|
206
233
|
)
|
207
234
|
end
|
208
235
|
|
209
236
|
def build_provider_from_source(name, source:, group:, options:, &block)
|
210
237
|
provider_source = System.provider_sources.resolve(name: source, group: group)
|
211
238
|
|
239
|
+
source_options =
|
240
|
+
if provider_source.source <= provider_source_class
|
241
|
+
provider_source_options
|
242
|
+
else
|
243
|
+
{}
|
244
|
+
end
|
245
|
+
|
212
246
|
Provider.new(
|
213
247
|
**provider_source.provider_options,
|
214
248
|
**options,
|
215
249
|
name: name,
|
216
250
|
target_container: target_container,
|
217
251
|
source_class: provider_source.source,
|
252
|
+
source_options: source_options,
|
218
253
|
&block
|
219
254
|
)
|
220
255
|
end
|
data/lib/dry/system/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-auto_inject
|
@@ -180,9 +180,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '3.0'
|
181
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
182
|
requirements:
|
183
|
-
- - "
|
183
|
+
- - ">="
|
184
184
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
185
|
+
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubygems_version: 3.3.27
|
188
188
|
signing_key:
|