dry-system 0.19.2 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +472 -1
  3. data/LICENSE +1 -1
  4. data/README.md +4 -3
  5. data/dry-system.gemspec +16 -15
  6. data/lib/dry/system/auto_registrar.rb +1 -13
  7. data/lib/dry/system/component.rb +104 -47
  8. data/lib/dry/system/component_dir.rb +88 -47
  9. data/lib/dry/system/components.rb +8 -4
  10. data/lib/dry/system/config/component_dir.rb +141 -53
  11. data/lib/dry/system/config/component_dirs.rb +176 -70
  12. data/lib/dry/system/config/namespace.rb +76 -0
  13. data/lib/dry/system/config/namespaces.rb +208 -0
  14. data/lib/dry/system/constants.rb +2 -2
  15. data/lib/dry/system/container.rb +279 -201
  16. data/lib/dry/system/errors.rb +72 -61
  17. data/lib/dry/system/identifier.rb +99 -79
  18. data/lib/dry/system/importer.rb +83 -12
  19. data/lib/dry/system/indirect_component.rb +65 -0
  20. data/lib/dry/system/loader.rb +8 -4
  21. data/lib/dry/system/{manual_registrar.rb → manifest_registrar.rb} +12 -13
  22. data/lib/dry/system/plugins/bootsnap.rb +3 -2
  23. data/lib/dry/system/plugins/dependency_graph/strategies.rb +37 -1
  24. data/lib/dry/system/plugins/dependency_graph.rb +26 -20
  25. data/lib/dry/system/plugins/env.rb +3 -2
  26. data/lib/dry/system/plugins/logging.rb +9 -5
  27. data/lib/dry/system/plugins/monitoring.rb +1 -1
  28. data/lib/dry/system/plugins/notifications.rb +1 -1
  29. data/lib/dry/system/plugins/zeitwerk/compat_inflector.rb +22 -0
  30. data/lib/dry/system/plugins/zeitwerk.rb +109 -0
  31. data/lib/dry/system/plugins.rb +8 -7
  32. data/lib/dry/system/provider/source.rb +324 -0
  33. data/lib/dry/system/provider/source_dsl.rb +94 -0
  34. data/lib/dry/system/provider.rb +264 -24
  35. data/lib/dry/system/provider_registrar.rb +276 -0
  36. data/lib/dry/system/provider_source_registry.rb +70 -0
  37. data/lib/dry/system/provider_sources/settings/config.rb +86 -0
  38. data/lib/dry/system/provider_sources/settings/loader.rb +53 -0
  39. data/lib/dry/system/provider_sources/settings.rb +40 -0
  40. data/lib/dry/system/provider_sources.rb +5 -0
  41. data/lib/dry/system/stubs.rb +1 -1
  42. data/lib/dry/system/version.rb +1 -1
  43. data/lib/dry/system.rb +45 -13
  44. metadata +25 -22
  45. data/lib/dry/system/booter/component_registry.rb +0 -35
  46. data/lib/dry/system/booter.rb +0 -200
  47. data/lib/dry/system/components/bootable.rb +0 -289
  48. data/lib/dry/system/components/config.rb +0 -35
  49. data/lib/dry/system/lifecycle.rb +0 -135
  50. data/lib/dry/system/provider_registry.rb +0 -27
  51. data/lib/dry/system/settings/file_loader.rb +0 -30
  52. data/lib/dry/system/settings/file_parser.rb +0 -51
  53. data/lib/dry/system/settings.rb +0 -67
  54. data/lib/dry/system/system_components/settings.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac1a7cac5a6ff443e0479c8507e50f5d4c3fb1d18615c14953c8187bf116942c
4
- data.tar.gz: c3f58d5572a94399807162667f005ead8b37f88774c3e96968d0fe31642611c2
3
+ metadata.gz: 1719add7d103e13ec062de6515d40d9d47bda60e7e70a063649a111b1c00e4ef
4
+ data.tar.gz: 804f75708ddfc1083a63198a12fcc84226c70ab5e8dd6fd80bca1516831ab0eb
5
5
  SHA512:
6
- metadata.gz: 4626bdead25123079942778e76413d05b8e7d86f048e50997c54e61ddbc2d5e31b7520fbfbfd0231106e03bc209074158887caba4958cce3560652b99ea7f562
7
- data.tar.gz: d85046a0106aa9dc062a1e85dec60aac35a556cf6c63c4bcffbdd13702f304cfd383a4acb5815fc9ae25cf6abc3cea7b5bb47f23d129f9a59bdd3912fc8a93c8
6
+ metadata.gz: 3ef24909abb786c3faafcd9fedfc37fb5ef715bed3128243a523e7046171b70fc70b0c8d21bdc1d9ea005f22f3e2bb2129834d99d0f606b699f909b09d78e1ae
7
+ data.tar.gz: 588331f0d24e87414f0b182d855a74a05adc5f33303d79ad8ed98293f7a18de7e9f513218cca672d5ff394369adbaf0543be4375c92cd6c391595dadda446039
data/CHANGELOG.md CHANGED
@@ -1,5 +1,467 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.23.0 2022-02-08
4
+
5
+ This is a major overhaul of bootable components (now known as “Providers”), and brings major advancements to other areas, including container imports and exports.
6
+
7
+ Deprecations are in place for otherwise breaking changes to commonly used parts of dry-system, though some breaking changes remain.
8
+
9
+ This prepares the way for dry-system 1.0, which will be released in the coming months.
10
+
11
+
12
+ ### Added
13
+
14
+ - Containers can configure specific components for export using `config.exports` (@timriley in #209).
15
+
16
+ ```ruby
17
+ class MyContainer < Dry::System::Container
18
+ configure do |config|
19
+ config.exports = %w[component_a component_b]
20
+ end
21
+ end
22
+ ```
23
+
24
+ Containers importing another container with configured exports will import only those components.
25
+
26
+ When importing a specific set of components (see the note in the “Changed” section below), only those components whose keys intersect with the configured exports will be imported.
27
+ - A `:zeitwerk` plugin, to set up [Zeitwerk](https://github.com/fxn/zeitwerk) and integrate it with your container configuration (@ianks and @timriley in #197, #222, 13f8c87, #223)
28
+
29
+ This makes it possible to enable Zeitwerk with a one-liner:
30
+
31
+ ```ruby
32
+ class MyContainer < Dry::System::Container
33
+ use :zeitwerk
34
+
35
+ configure do |config|
36
+ config.component_dirs.add "lib"
37
+ # ...
38
+ end
39
+ end
40
+ ```
41
+
42
+ The plugin makes a `Zeitwerk::Loader` instance available at `config.autoloader`, and then in an after-`:configure` hook, the plugin will set up the loader to work with all of your configured component dirs and their namespaces. It will also enable the `Dry::System::Loader::Autoloading` loader for all component dirs, plus disable those dirs from being added to the `$LOAD_PATH`.
43
+
44
+ The plugin accepts the following options:
45
+
46
+ - `loader:` - (optional) to use a pre-initialized loader, if required.
47
+ - `run_setup:` - (optional) a bool to determine whether to run `Zeitwerk::Loader#setup` as part of the after-`:configure` hook. This may be useful to disable in advanced cases when integrating with an externally managed loader.
48
+ - `eager_load:` - (optional) a bool to determine whether to run `Zeitwerk::Loader#eager_load` as part of an after-`:finalize` hook. When not provided, it will default to true if the `:env` plugin is enabled and the env is set to `:production`.
49
+ - `debug:` - (optional) a bool to set whether Zeitwerk should log to `$stdout`.
50
+ - New `Identifier#end_with?` and `Identifier#include?` predicates (@timriley in #219)
51
+
52
+ These are key segment-aware predicates that can be useful when checking components as part of container configuration.
53
+
54
+ ```ruby
55
+ identifier.key # => "articles.operations.create"
56
+
57
+ identifier.end_with?("create") # => true
58
+ identifier.end_with?("operations.create") # => true
59
+ identifier.end_with?("ate") # => false, not a whole segment
60
+ identifier.end_with?("nope") # => false, not part of the key at all
61
+
62
+ identifier.include?("operations") # => true
63
+ identifier.include?("articles.operations") # => true
64
+ identifier.include?("operations.create") # => true
65
+ identifier.include?("article") # false, not a whole segment
66
+ identifier.include?("update") # => false, not part of the key at all
67
+ ```
68
+ - An `instance` setting for component dirs allows simpler per-dir control over component instantiation (@timriley in #215)
69
+
70
+ This optional setting should be provided a proc that receives a single `Dry::System::Component` instance as an argument, and should return the instance for the given component.
71
+
72
+ ```ruby
73
+ configure do |config|
74
+ config.component_dirs.add "lib" do |dir|
75
+ dir.instance = proc do |component|
76
+ if component.identifier.include?("workers")
77
+ # Register classes for jobs
78
+ component.loader.constant(component)
79
+ else
80
+ # Otherwise register regular instances per default loader
81
+ component.loader.call(component)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ ```
87
+
88
+ For complete control of component loading, you should continue to configure the component dir’s `loader` instead.
89
+ - A new `ComponentNotLoadableError` error and helpful message is raised when resolving a component and an unexpected class is defined in the component’s source file (@cllns in #217).
90
+
91
+ The error shows expected and found class names, and inflector configuration that may be required in the case of class names containing acronyms.
92
+
93
+ ### Fixed
94
+
95
+ - Registrations made in providers (by calling `register` inside a provider step) have all their registration options preserved (such as a block-based registration, or the `memoize:` option) when having their registration merged into the target container after the provider lifecycle steps complete (@timriley in #212).
96
+ - Providers can no longer implicitly re-start themselves while in the process of starting and cause an infinite loop (@timriley #213).
97
+
98
+ This was possible before when a provider resolved a component from the target container that auto-injected dependencies with container keys sharing the same base key as the provider name.
99
+
100
+ ### Changed
101
+
102
+ - “Bootable components” (also referred to in some places simply as “components”) have been renamed to “Providers” (@timriley in #200).
103
+
104
+ Register a provider with `Dry::System::Container.register_provider` (`Dry::System::Container.boot` has been deprecated):
105
+
106
+ ```ruby
107
+ MyContainer.register_provider(:mailer) do
108
+ # ...
109
+ end
110
+ ```
111
+ - Provider `init` lifecycle step has been deprecated and renamed to `prepare` (@timriley in #200).
112
+
113
+ ```ruby
114
+ MyContainer.reigster_provider(:mailer) do
115
+ # Rename `init` to `prepare`
116
+ prepare do
117
+ require "some/third_party/mailer"
118
+ end
119
+ end
120
+ ```
121
+ - Provider behavior is now backed by a class per provider, known as the “Provider source” (@timriley in #202).
122
+
123
+ The provider source class is created for each provider as a subclass of `Dry::System::Provider::Source`.
124
+
125
+ You can still register simple providers using the block-based DSL, but the class backing means you can share state between provider steps using regular instance variables:
126
+
127
+ ```ruby
128
+ MyContainer.reigster_provider(:mailer) do
129
+ prepare do
130
+ require "some/third_party/mailer"
131
+ @some_config = ThirdParty::Mailer::Config.new
132
+ end
133
+
134
+ start do
135
+ # Since the `prepare` step will always run before start, we can access
136
+ # @some_config here
137
+ register "mailer", ThirdParty::Mailer.new(@some_config)
138
+ end
139
+ end
140
+ ```
141
+
142
+ Inside this `register_provider` block, `self` is the source subclass itself, and inside each of the step blocks (i.e. `prepare do`), `self` will be the _instance_ of that provider source.
143
+
144
+ For more complex providers, you can define your own source subclass and register it directly with the `source:` option for `register_provider`. This allows you to more readily use standard arrangements for factoring your logic within a class, such as extraction to another method:
145
+
146
+ ```ruby
147
+ MyContainer.register_provider(:mailer, source: Class.new(Dry::System::Provider::Source) {
148
+ # The provider lifecycle steps are ordinary methods
149
+ def prepare
150
+ end
151
+
152
+ def start
153
+ mailer = some_complex_logic_to_build_the_mailer(some: "config")
154
+ register(:mailer, mailer)
155
+ end
156
+
157
+ private
158
+
159
+ def some_complex_logic_to_build_the_mailer(**options)
160
+ # ...
161
+ end
162
+ })
163
+ ```
164
+ - The block argument to `Dry::System::Container.register_provider` (previously `.boot`) has been deprecated. (@timriley in #202).
165
+
166
+ This argument was used to give you access to the provider's target container (i.e. the container on which you were registering the provider).
167
+
168
+ To access the target container, you can use `#target_container` (or `#target` as a convenience alias) instead.
169
+
170
+ You can also access the provider's own container (which is where the provider's components are registered when you call `register` directly inside a provider step) as `#provider_container` (or `#container` as a convenience alias).
171
+ - `use(provider_name)` inside a provider step has been deprecated. Use `target_container.start(provider_name)` instead (@timriley in #211 and #224)
172
+
173
+ Now that you can access `target_container` consistently within all provider steps, you can use it to also start any other providers as you require without any special additional method. This also allows you to invoke other provider lifecycle steps, like `target_container.prepare(provider_name)`.
174
+ - `method_missing`-based delegation within providers to target container registrations has been removed (**BREAKING**) (@timriley in #202)
175
+
176
+ Delegation to registrations with the provider's own container has been kept, since it can be a convenient way to access registrations made in a prior lifecycle step:
177
+
178
+ ```ruby
179
+ MyContainer.register_provider(:mailer, namespace: true) do
180
+ prepare do
181
+ register :config, "mailer config here"
182
+ end
183
+
184
+ start do
185
+ config # => "mailer config here"
186
+ end
187
+ end
188
+ ```
189
+ - The previous "external component" and "provider" concepts have been renamed to "external provider sources", in keeping with the new provider terminology outlined above (@timriley in #200 and #202).
190
+
191
+ You can register a collection of external provider sources defined in their own source files via `Dry::System.register_provider_sources` (`Dry::System.register_provider` has been deprecated):
192
+
193
+ ```ruby
194
+ require "dry/system"
195
+
196
+ Dry::System.register_provider_sources(path)
197
+ ```
198
+
199
+ You can register an individual external provider source via `Dry::System.register_provider_source` (`Dry::System.register_component` has been deprecated):
200
+
201
+ ```ruby
202
+ Dry::System.register_provider_source(:something, group: :my_gem) do
203
+ start do
204
+ # ...
205
+ end
206
+ end
207
+ ```
208
+
209
+ Just like providers, you can also register a class as an external provider source:
210
+
211
+ ```ruby
212
+ module MyGem
213
+ class MySource < Dry::System::Provider::Source
214
+ def start
215
+ # ...
216
+ end
217
+ end
218
+ end
219
+
220
+ Dry::System.register_provider_source(:something, group: :my_gem, source: MyGem::MySource)
221
+ ```
222
+
223
+ The `group:` argument when registering an external provider sources is for preventing name clashes between provider sources. You should use an underscored version of your gem name or namespace when registering your own provider sources.
224
+ - Registering a provider using an explicitly named external provider source via `key:` argument is deprecated, use the `source:` argument instead (@timriley in #202).
225
+
226
+ You can register a provider using the same name as an external provider source by specifying the `from:` argument only, as before:
227
+
228
+ ```ruby
229
+ # Elsewhere
230
+ Dry::System.register_provider_source(:something, group: :my_gem) { ... }
231
+
232
+ # In your app:
233
+ MyContainer.register_provider(:something, from: :my_gem)
234
+ ```
235
+
236
+ When you wish the name your provider differently, this is when you need to use the `source:` argument:
237
+
238
+ ```ruby
239
+ MyContainer.register_provider(:differently_named, from: :my_gem, source: :something)
240
+ ```
241
+
242
+ When you're registering a provider using an external provider source, you cannot provie your own `Dry::System::Provider::Source` subclass as the `source:`, since that source class is being provided by the external provider source.
243
+ - Provider source settings are now defined using dry-configurable’s `setting` API at the top-level scope (@timriley in #202).
244
+
245
+ Use the top-level `setting` method to define your settings (the `settings` block and settings defined inside the block using `key` is deprecated). Inside the provider steps, the configured settings can be accessed as `config`:
246
+
247
+ ```ruby
248
+ # In the external provider source
249
+ Dry::System.register_provider_source(:something, group: :my_gem) do
250
+ setting :my_option
251
+
252
+ start do
253
+ # Do something with `config.my_option` here
254
+ end
255
+ end
256
+ ```
257
+
258
+ When using an external provider source, configure the source via the `#configure`:
259
+
260
+ ```ruby
261
+ # In your application's provider using the external source
262
+ MyContainer.register_provider(:something, from: :my_gem) do
263
+ configure do |config|
264
+ config.my_option = "some value"
265
+ end
266
+ end
267
+ ```
268
+
269
+ To provide default values and type checking or constraints for your settings, use the dry-configurable’s `default:` and `constructor:` arguments:
270
+
271
+ ```ruby
272
+ # Constructor can take any proc being passed the provided value
273
+ setting :my_option, default: "hello", constructor: -> (v) { v.to_s.upcase }
274
+
275
+ # Constructor will also work with dry-types objects
276
+ setting :my_option, default: "hello", constructor: Types::String.constrained(min_size: 3)
277
+ ```
278
+ - External provider sources can define their own methods for use by the providers alongside lifecycle steps (@timriley in #202).
279
+
280
+ Now that provider sources are class-backed, external provider sources can define their own methods to be made available when that provider source is used. This makes it possible to define your own extended API for interacting with the provider source:
281
+
282
+ ```ruby
283
+ # In the external provider source
284
+
285
+ module MyGem
286
+ class MySource < Dry::System::Provider::Source
287
+ # Standard lifecycle steps
288
+ def start
289
+ # Do something with @on_start here
290
+ end
291
+
292
+ # Custom behavior available when this provider source is used in a provider
293
+ def on_start(&block)
294
+ @on_start = block
295
+ end
296
+ end
297
+ end
298
+
299
+ Dry::System.register_provider_source(:something, group: :my_gem, source: MyGem::MySource)
300
+
301
+ # In your application's provider using the external source
302
+
303
+ MyContainer.register_provider(:something, from: :my_gem) do
304
+ # Use the custom method!
305
+ on_start do
306
+ # ...
307
+ end
308
+ end
309
+ ```
310
+ - Providers can be registered conditionally using the `if:` option (@timriley in #218).
311
+
312
+ You should provide a simple truthy or falsey value to `if:`, and in the case of falsey value, the provider will not be registered.
313
+
314
+ This is useful in cases where you have providers that are loaded explicitly for specific runtime configurations of your app (e.g. when they are needed for specific tasks or processes only), but you do not need them for your primaary app process, for which you may finalize your container.
315
+ - `bootable_dirs` container setting has been deprecated and replaced by `provider_dirs` (@timriley in #200).
316
+
317
+ The default value for `provider_dirs` is now `"system/providers`".
318
+ - Removed the unused `system_dir` container setting (**BREAKING**) (@timriley in #200)
319
+
320
+ If you’ve configured this inside your container, you can remove it.
321
+ - dry-system’s first-party external provider sources now available via `require "dry/system/provider_sources"`, with the previous `require "dry/system/components"` deprecated (@timriley in #202).
322
+ - When using registering a provider using a first-party dry-system provider source, `from: :dry_system` instead of `from: :system` (which is now deprecated) (@timriley in #202).
323
+
324
+ ```ruby
325
+ MyContainer.register_provider(:settings, from: :dry_system) do
326
+ # ...
327
+ end
328
+ - When registering a provider using the `:settings` provider source, settings are now defined using `setting` inside a `settings` block, rather than `key`, which is deprecated (@timriley in #202).
329
+
330
+ This `setting` method uses the dry-configurable setting API:
331
+
332
+ ```ruby
333
+ MyContainer.register_provider(:settings, from: :dry_system) do
334
+ settings do
335
+ # Previously:
336
+ # key :my_int_setting, MyTypes::Coercible::Integer
337
+
338
+ # Now:
339
+ setting :my_setting, default: 0, constructor: MyTypes::Coercible::Integer
340
+ end
341
+ end
342
+ ```
343
+ - The `:settings` provider source now requires the dotenv gem to load settings from `.env*` files (**BREAKING**) (@timriley in #204)
344
+
345
+ To ensure you can load your settings from these `.env*` files, add `gem "dotenv"` to your `Gemfile`.
346
+ - `Dry::System::Container` can be now be configured direclty using the setting writer methods on the class-level `.config` object, without going the `.configure(&block)` API (@timriley in #207).
347
+
348
+ If configuring via the class-level `.config` object, you should call `.configured!` after you're completed your configuration, which will finalize (freeze) the `config` object and then run any after-`:configure` hooks.
349
+ - `Dry::System::Container.configure(&block)` will now finalize (freeze) the `config` object by default, before returning (@timriley in #207).
350
+
351
+ You can opt out of this behavior by passing the `finalize_config: false` option:
352
+
353
+ ```ruby
354
+ class MyContainer < Dry::System::Container
355
+ configure(finalize_config: false) do |config|
356
+ # ...
357
+ end
358
+
359
+ # `config` is still non-finalized here
360
+ end
361
+ ```
362
+ - `Dry::System::Container.finalize!` will call `.configured!` (if it has not yet been called) before doing its work (@timriley in #207)
363
+
364
+ This ensures config finalization is an intrinsic part of the overall container finalization process.
365
+ - The `Dry::System::Container` `before(:configure)` hook has been removed (**BREAKING**) (@timriley in #207).
366
+
367
+ This was previously used for plugins to register their own settings, but this was not necessary given that plugins are modules, and can use their ordinary `.extended(container_class)` hook to register their settings. Essentially, any time after container subclass definition is "before configure" in nature.
368
+ - Container plugins should define their settings on the container using their module `.extended` hook, no longer in a `before(:configure)` hook (as above) (**BREAKING**) (@timriley in #207).
369
+
370
+ This ensures the plugin settings are available immediately after you’ve enabled the plugin via `Dry::System::Container.use`.
371
+ - The `Dry::System::Container` key `namespace_separator` setting is no longer expected to be user-configured. A key namespace separator of "." is hard-coded and expected to remain the separator string. (@timriley in #206)
372
+ - Containers can import a specific subset of another container’s components via changes to `.import`, which is now `.import(keys: nil, from:, as:)` (with prior API deprecated) (@timriley in #209)
373
+
374
+ To import specific components:
375
+
376
+ ```ruby
377
+ class MyContainer < Dry::System::Container
378
+ # config, etc.
379
+
380
+ # Will import components with keys "other.component_a", "other.component_b"
381
+ import(
382
+ keys: %w[component_a component_b],
383
+ from: OtherContainer,
384
+ as: :other
385
+ )
386
+ ```
387
+
388
+ Omitting `keys:` will import all the components available from the other container.
389
+ - Components imported into a container from another will be protected from subsequent export unless explicitly configured in `config.exports` (@timriley in #209)
390
+
391
+ Imported components are considered “private” by default because they did not originate in container that imported them.
392
+
393
+ This ensures there are no redundant imports in arrangements where multiple all containers import a common “base” container, and then some of those containers then import each other.
394
+ - Container imports are now made without finalizing the exporting container in most cases, ensuring more efficient imports (@timriley in #209)
395
+
396
+ Now, the only time the exporting container will be finalized is when a container is importing all components, and the exporting container has not declared any components in `config.exports`.
397
+ - [Internal] The `manual_registrar` container setting and associated `ManualRegistrar` class have been renamed to `manifest_registrar` and `ManifestRegistrar` respectively (**BREAKING**) (@timriley in #208).
398
+ - The default value for the container `registrations_dir` setting has been changed from `"container"` to `"system/registrations"` (**BREAKING**) (@timriley in #208)
399
+ - The `:dependency_graph` plugin now supports all dry-auto_inject injector strategies (@davydovanton and @timriley in #214)
400
+
401
+ [Compare v0.22.0...v0.23.0](https://github.com/dry-rb/dry-system/compare/v0.22.0...v0.23.0)
402
+
403
+ ## 0.22.0 2022-01-06
404
+
405
+
406
+ ### Added
407
+
408
+ - Expanded public interfaces for `Dry::System::Config::ComponentDirs` and `Dry::System::Config::Namespaces` to better support programmatic construction and inspection of these configs (@timriley in #195)
409
+
410
+ ### Changed
411
+
412
+ - Deprecated `Dry::System::Config::Namespaces#root` as the way to add and configure a root namespace. Use `#add_root` instead (@timriley in #195)
413
+ - Allow bootsnap plugin to use bootsnap on Ruby versions up to 3.0 (pusewicz in #196)
414
+
415
+ [Compare v0.21.0...v0.22.0](https://github.com/dry-rb/dry-system/compare/v0.21.0...v0.22.0)
416
+
417
+ ## 0.21.0 2021-11-01
418
+
419
+
420
+ ### Added
421
+
422
+ - Added **component dir namespaces** as a way to specify multiple, ordered, independent namespace rules within a given component dir. This replaces and expands upon the namespace support we previously provided via the singular `default_namespace` component dir setting (@timriley in #181)
423
+
424
+ ### Changed
425
+
426
+ - `default_namespace` setting on component dirs has been deprecated. Add a component dir namespace instead, e.g. instead of:
427
+
428
+ ```ruby
429
+ # Inside Dry::System::Container.configure
430
+ config.component_dirs.add "lib" do |dir|
431
+ dir.default_namespace = "admin"
432
+ end
433
+ ```
434
+
435
+ Add this:
436
+
437
+ ```ruby
438
+ config.component_dirs.add "lib" do |dir|
439
+ dir.namespaces.add "admin", key: nil
440
+ end
441
+ ```
442
+
443
+ (@timriley in #181)
444
+ - `Dry::System::Component#path` has been removed and replaced by `Component#require_path` and `Component#const_path` (@timriley in #181)
445
+ - Unused `Dry::System::FileNotFoundError` and `Dry::System::InvalidComponentIdentifierTypeError` errors have been removed (@timriley in #194)
446
+ - Allow bootsnap for Rubies up to 3.0.x (via #196) (@pusewicz)
447
+
448
+ [Compare v0.20.0...v0.21.0](https://github.com/dry-rb/dry-system/compare/v0.20.0...v0.21.0)
449
+
450
+ ## 0.20.0 2021-09-12
451
+
452
+
453
+ ### Fixed
454
+
455
+ - Fixed dependency graph plugin to work with internal changes introduced in 0.19.0 (@wuarmin in #173)
456
+ - Fixed behavior of `Dry::System::Identifier#start_with?` for components identified by a single segment, or if all matching segments are provided (@wuarmin in #177)
457
+ - Fixed compatibility of `finalize!` signature provided in `Container::Stubs` (@mpokrywka in #178)
458
+
459
+ ### Changed
460
+
461
+ - [internal] Upgraded to new `setting` API provided in dry-configurable 0.13.0 (@timriley in #179)
462
+
463
+ [Compare v0.19.2...v0.20.0](https://github.com/dry-rb/dry-system/compare/v0.19.2...v0.20.0)
464
+
3
465
  ## 0.19.2 2021-08-30
4
466
 
5
467
 
@@ -7,7 +469,16 @@
7
469
 
8
470
  - [internal] Improved compatibility with upcoming dry-configurable 0.13.0 release (@timriley in #186)
9
471
 
10
- [Compare v0.19.1...v0.19.2](https://github.com/dry-rb/dry-system/compare/v0.19.1...v0.19.2)
472
+ [Compare v0.18.2...v0.19.2](https://github.com/dry-rb/dry-system/compare/v0.18.2...v0.19.2)
473
+
474
+ ## 0.18.2 2021-08-30
475
+
476
+
477
+ ### Changed
478
+
479
+ - [internal] Improved compatibility with upcoming dry-configurable 0.13.0 release (@timriley in #187)
480
+
481
+ [Compare v0.19.1...v0.18.2](https://github.com/dry-rb/dry-system/compare/v0.19.1...v0.18.2)
11
482
 
12
483
  ## 0.19.1 2021-07-11
13
484
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2021 dry-rb team
3
+ Copyright (c) 2015-2022 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ <!--- this file is synced from dry-rb/template-gem project -->
1
2
  [gem]: https://rubygems.org/gems/dry-system
2
3
  [actions]: https://github.com/dry-rb/dry-system/actions
3
4
  [codacy]: https://www.codacy.com/gh/dry-rb/dry-system
@@ -14,15 +15,15 @@
14
15
 
15
16
  ## Links
16
17
 
17
- * [User documentation](http://dry-rb.org/gems/dry-system)
18
+ * [User documentation](https://dry-rb.org/gems/dry-system)
18
19
  * [API documentation](http://rubydoc.info/gems/dry-system)
19
20
 
20
21
  ## Supported Ruby versions
21
22
 
22
23
  This library officially supports the following Ruby versions:
23
24
 
24
- * MRI >= `2.5`
25
- * jruby >= `9.2`
25
+ * MRI `>= 2.7.0`
26
+ * jruby `>= 9.3` (postponed until 2.7 is supported)
26
27
 
27
28
  ## License
28
29
 
data/dry-system.gemspec CHANGED
@@ -1,37 +1,38 @@
1
1
  # frozen_string_literal: true
2
- # this file is managed by dry-rb/devtools project
3
2
 
4
- lib = File.expand_path('lib', __dir__)
3
+ # this file is synced from dry-rb/template-gem project
4
+
5
+ lib = File.expand_path("lib", __dir__)
5
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
- require 'dry/system/version'
7
+ require "dry/system/version"
7
8
 
8
9
  Gem::Specification.new do |spec|
9
- spec.name = 'dry-system'
10
+ spec.name = "dry-system"
10
11
  spec.authors = ["Piotr Solnica"]
11
12
  spec.email = ["piotr.solnica@gmail.com"]
12
- spec.license = 'MIT'
13
+ spec.license = "MIT"
13
14
  spec.version = Dry::System::VERSION.dup
14
15
 
15
16
  spec.summary = "Organize your code into reusable components"
16
17
  spec.description = spec.summary
17
- spec.homepage = 'https://dry-rb.org/gems/dry-system'
18
+ spec.homepage = "https://dry-rb.org/gems/dry-system"
18
19
  spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-system.gemspec", "lib/**/*"]
19
- spec.bindir = 'bin'
20
+ spec.bindir = "bin"
20
21
  spec.executables = []
21
- spec.require_paths = ['lib']
22
+ spec.require_paths = ["lib"]
22
23
 
23
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
- spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-system/blob/master/CHANGELOG.md'
25
- spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-system'
26
- spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-system/issues'
24
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-system/blob/master/CHANGELOG.md"
26
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-system"
27
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-system/issues"
27
28
 
28
- spec.required_ruby_version = ">= 2.5.0"
29
+ spec.required_ruby_version = ">= 2.7.0"
29
30
 
30
31
  # to update dependencies edit project.yml
31
32
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
32
33
  spec.add_runtime_dependency "dry-auto_inject", ">= 0.4.0"
33
- spec.add_runtime_dependency "dry-configurable", "~> 0.12", ">= 0.12.1"
34
- spec.add_runtime_dependency "dry-container", "~> 0.7", ">= 0.7.2"
34
+ spec.add_runtime_dependency "dry-configurable", "~> 0.14", ">= 0.14.0"
35
+ spec.add_runtime_dependency "dry-container", "~> 0.9", ">= 0.9.0"
35
36
  spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
36
37
  spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
37
38
  spec.add_runtime_dependency "dry-struct", "~> 1.0"
@@ -29,7 +29,7 @@ module Dry
29
29
 
30
30
  # @api private
31
31
  def call(component_dir)
32
- components(component_dir).each do |component|
32
+ component_dir.each_component do |component|
33
33
  next unless register_component?(component)
34
34
 
35
35
  container.register(component.key, memoize: component.memoize?) { component.instance }
@@ -38,18 +38,6 @@ module Dry
38
38
 
39
39
  private
40
40
 
41
- def components(component_dir)
42
- files(component_dir.full_path).map { |file_path|
43
- component_dir.component_for_path(file_path)
44
- }
45
- end
46
-
47
- def files(dir)
48
- raise ComponentDirNotFoundError, dir unless Dir.exist?(dir)
49
-
50
- Dir["#{dir}/**/#{RB_GLOB}"].sort
51
- end
52
-
53
41
  def register_component?(component)
54
42
  !container.registered?(component.key) && component.auto_register?
55
43
  end