dry-system 1.1.0.beta1 → 1.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432379faf1a5f4a181f7bc5c729ce9eb337818c7bd882a6742565fb032ebc3ce
|
4
|
+
data.tar.gz: 813b6ea310a5125199f636080e7c3c122b7c66018972b434e4262bbe2048b5fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e440c87a5df03645d15189f35b4a73988088849038fee92b1f48803f33789a1bfd639658d6361b95c1edd1ee89d6e6a3dfbbb0b1ef6af5ae7836a85c031520ad
|
7
|
+
data.tar.gz: e4d2a8d500c320975c3f67ff849aef9ba518852111929c7953ad4865ec70d2feb9eff1fa39de2854664b7a3f9ceea033bf4085b7581543a4148d60c9d8db663a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 1.1.0.beta2 2024-09-25
|
4
|
+
|
5
|
+
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- Allow provider sources to use a custom superclass. This requires a custom provider registrar
|
9
|
+
to be configured, with its own implementations of `#provider_source_class` (the superclass to
|
10
|
+
use) and `#provider_source_options` (custom initialization args to pass to the provider
|
11
|
+
source). (via #275) (@alassek, @timriley)
|
12
|
+
|
13
|
+
[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)
|
14
|
+
|
3
15
|
## 1.1.0.beta1 2024-07-03
|
4
16
|
|
5
17
|
|
@@ -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.beta2
|
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-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-auto_inject
|