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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0772f1a642fb7e44cdafda2659b417fec6f8d583c14098751a94d1163c9c5571
4
- data.tar.gz: 37a2e8c32bff3b24b1ff47f7bdb5095057dc5d7283327a3eab7c1424964c9f08
3
+ metadata.gz: 3f205d51c4e52d33cd3b0a6cc822abc1d69e943c2fc1b0cae287a7087d5017f1
4
+ data.tar.gz: 18db35de1a85607fd67e7a77bbb5fceb177c5fedf365efc86c136a217f85227e
5
5
  SHA512:
6
- metadata.gz: bb137a83e1fa1eba5578255c6535282edfee7608faf4dbe9771d4dfda4cafbeeef167bb970c986b86e5a1e34162275ca63d796bf1d53148148df2dc835f2db80
7
- data.tar.gz: 42c3050148a8de2e63376642ca4be35f6726b8462d708935ecb206d353ff0f6bf3b45a47e38b8440c368a88592933973705756de81cfd5be7066e0b41ff6d785
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
- Class.new(self) { |klass|
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
- alias_method :target, :target_container
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)
@@ -127,7 +127,8 @@ module Dry
127
127
  attr_reader :source
128
128
 
129
129
  # @api private
130
- def initialize(name:, namespace: nil, target_container:, source_class:, &block) # rubocop:disable Style/KeywordParametersOrder
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(name: name, &block)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module System
5
- VERSION = "1.1.0.beta1"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
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.beta1
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-07-03 00:00:00.000000000 Z
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: 1.3.1
185
+ version: '0'
186
186
  requirements: []
187
187
  rubygems_version: 3.3.27
188
188
  signing_key: