dry-system 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +101 -86
- data/README.md +2 -2
- data/lib/dry-system.rb +2 -0
- data/lib/dry/system.rb +3 -1
- data/lib/dry/system/auto_registrar.rb +12 -8
- data/lib/dry/system/auto_registrar/configuration.rb +2 -0
- data/lib/dry/system/booter.rb +10 -9
- data/lib/dry/system/booter/component_registry.rb +3 -5
- data/lib/dry/system/component.rb +5 -2
- data/lib/dry/system/components.rb +2 -0
- data/lib/dry/system/components/bootable.rb +13 -11
- data/lib/dry/system/components/config.rb +2 -0
- data/lib/dry/system/constants.rb +8 -7
- data/lib/dry/system/container.rb +64 -25
- data/lib/dry/system/errors.rb +9 -1
- data/lib/dry/system/importer.rb +2 -0
- data/lib/dry/system/lifecycle.rb +3 -1
- data/lib/dry/system/loader.rb +2 -0
- data/lib/dry/system/magic_comments_parser.rb +3 -3
- data/lib/dry/system/manual_registrar.rb +3 -1
- data/lib/dry/system/plugins.rb +9 -4
- data/lib/dry/system/plugins/bootsnap.rb +4 -1
- data/lib/dry/system/plugins/dependency_graph.rb +47 -0
- data/lib/dry/system/plugins/dependency_graph/strategies.rb +30 -0
- data/lib/dry/system/plugins/env.rb +2 -0
- data/lib/dry/system/plugins/logging.rb +8 -7
- data/lib/dry/system/plugins/monitoring.rb +3 -1
- data/lib/dry/system/plugins/monitoring/proxy.rb +2 -0
- data/lib/dry/system/plugins/notifications.rb +4 -1
- data/lib/dry/system/provider.rb +3 -1
- data/lib/dry/system/provider_registry.rb +2 -0
- data/lib/dry/system/settings.rb +9 -7
- data/lib/dry/system/settings/file_loader.rb +4 -2
- data/lib/dry/system/settings/file_parser.rb +5 -3
- data/lib/dry/system/stubs.rb +2 -0
- data/lib/dry/system/system_components/settings.rb +2 -0
- data/lib/dry/system/version.rb +3 -1
- metadata +25 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9e7b9270e8cf896626e675f2bf98f2e8a7521a56e6b16a64ee30d724aa307a4
|
|
4
|
+
data.tar.gz: fa1ca1a837c0f3185d04a4d420ebb7325793f1165b4dcf4427ee94f81c10c26b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d774649cda42fc3eb0f4253f3db5d869947f9ac0e0189a0256926b26f97d15761efa30384991bf62b388c1b59eb370780d787c61984c654544b57ced182d8935
|
|
7
|
+
data.tar.gz: adc45c72848ec6fc31f96a17cfcd02f5034492e645cb549024c149aadc8de2096dc54b27b893c2218bf61a23db610c8b1bf85898fddab0f401ac9af9a0f14fc9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
# 0.13.0 - 2019-10-13
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
|
|
5
|
+
- [BREAKING] `Container.key?` triggers lazy-loading for not finalized containers. If component wasn't found it returns `false` without raising an error. This is a breaking change, if you seek the previous behavior, use `Container.registered?` (flash-gordon)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `Container.resolve` accepts and optional block parameter which will be called if component cannot be found. This makes dry-system consistent with dry-container 0.7.2 (flash-gordon)
|
|
10
|
+
```ruby
|
|
11
|
+
App.resolve('missing.dep') { :fallback } # => :fallback
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
[Compare v0.12.0...v0.13.0](https://github.com/dry-rb/dry-system/compare/v0.12.0...v0.13.0)
|
|
15
|
+
|
|
1
16
|
# 0.12.0 - 2019-04-24
|
|
2
17
|
|
|
3
18
|
### Changed
|
|
4
19
|
|
|
5
|
-
|
|
20
|
+
- Compatibility with dry-struct 1.0 and dry-types 1.0 (flash-gordon)
|
|
6
21
|
|
|
7
22
|
[Compare v0.11.0...v0.12.0](https://github.com/dry-rb/dry-system/compare/v0.11.0...v0.12.0)
|
|
8
23
|
|
|
@@ -10,8 +25,8 @@
|
|
|
10
25
|
|
|
11
26
|
### Changed
|
|
12
27
|
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
- [BREAKING] `:decorate` plugin was moved from dry-system to dry-container (available in 0.7.0+). To upgrade remove `use :decorate` and change `decorate` calls from `decorate(key, decorator: something)` to `decorate(key, with: something)` (flash-gordon)
|
|
29
|
+
- [internal] Compatibility with dry-struct 0.7.0 and dry-types 0.15.0
|
|
15
30
|
|
|
16
31
|
[Compare v0.10.1...v0.11.0](https://github.com/dry-rb/dry-system/compare/v0.10.1...v0.11.0)
|
|
17
32
|
|
|
@@ -19,18 +34,19 @@
|
|
|
19
34
|
|
|
20
35
|
### Added
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
- Support for stopping bootable components with `Container.stop(component_name)` (GustavoCaso)
|
|
23
38
|
|
|
24
39
|
### Fixed
|
|
25
40
|
|
|
26
|
-
|
|
41
|
+
- When using a non-finalized container, you can now resolve multiple different container objects registered using the same root key as a bootable component (timriley)
|
|
27
42
|
|
|
28
43
|
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-system/compare/v0.10.0...v0.10.1)
|
|
29
44
|
|
|
30
45
|
# 0.10.0 - 2018-06-07
|
|
31
46
|
|
|
32
47
|
### Added
|
|
33
|
-
|
|
48
|
+
|
|
49
|
+
- You can now set a custom inflector on the container level. As a result, the `Loader`'s constructor accepts two arguments: `path` and `inflector`, update your custom loaders accordingly (flash-gordon)
|
|
34
50
|
|
|
35
51
|
```ruby
|
|
36
52
|
class MyContainer < Dry::System::Container
|
|
@@ -44,10 +60,10 @@
|
|
|
44
60
|
|
|
45
61
|
### Changed
|
|
46
62
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
- A helpful error will be raised if an invalid setting value is provided (GustavoCaso)
|
|
64
|
+
- When using setting plugin, will use default values from types (GustavoCaso)
|
|
65
|
+
- Minimal supported ruby version was bumped to `2.3` (flash-gordon)
|
|
66
|
+
- `dry-struct` was updated to `~> 0.5` (flash-gordon)
|
|
51
67
|
|
|
52
68
|
[Compare v0.9.2...v0.10.0](https://github.com/dry-rb/dry-system/compare/v0.9.2...v0.10.0)
|
|
53
69
|
|
|
@@ -55,7 +71,7 @@
|
|
|
55
71
|
|
|
56
72
|
### Fixed
|
|
57
73
|
|
|
58
|
-
|
|
74
|
+
- Default namespace no longer breaks resolving dependencies with identifier that includes part of the namespace (ie `mail.mailer`) (GustavoCaso)
|
|
59
75
|
|
|
60
76
|
[Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-system/compare/v0.9.1...v0.9.2)
|
|
61
77
|
|
|
@@ -63,7 +79,7 @@
|
|
|
63
79
|
|
|
64
80
|
### Fixed
|
|
65
81
|
|
|
66
|
-
|
|
82
|
+
- Plugin dependencies are now auto-required and a meaningful error is raised when a dep failed to load (solnic)
|
|
67
83
|
|
|
68
84
|
[Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-system/compare/v0.9.0...v0.9.1)
|
|
69
85
|
|
|
@@ -71,21 +87,21 @@
|
|
|
71
87
|
|
|
72
88
|
### Added
|
|
73
89
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
- Plugin API (solnic)
|
|
91
|
+
- `:env` plugin which adds support for setting `env` config value (solnic)
|
|
92
|
+
- `:logging` plugin which adds a default logger (solnic)
|
|
93
|
+
- `:decorate` plugin for decorating registered objects (solnic)
|
|
94
|
+
- `:notifications` plugin adding pub/sub bus to containers (solnic)
|
|
95
|
+
- `:monitoring` plugin which adds `monitor` method for monitoring object method calls (solnic)
|
|
96
|
+
- `:bootsnap` plugin which adds support for bootsnap (solnic)
|
|
81
97
|
|
|
82
98
|
### Changed
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
- [BREAKING] renamed `Container.{require=>require_from_root}` (GustavoCaso)
|
|
85
101
|
|
|
86
102
|
### Internal
|
|
87
103
|
|
|
88
|
-
|
|
104
|
+
- `#bootable?` and `#boot_file` methods were moved from `Component` to `Booter` (GustavoCaso)
|
|
89
105
|
|
|
90
106
|
[Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-system/compare/v0.8.1...v0.9.0)
|
|
91
107
|
|
|
@@ -93,8 +109,8 @@
|
|
|
93
109
|
|
|
94
110
|
### Fixed
|
|
95
111
|
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
- Aliasing an external component works correctly (solnic)
|
|
113
|
+
- Manually calling `:init` will also finalize a component (solnic)
|
|
98
114
|
|
|
99
115
|
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-system/compare/v0.8.0...v0.8.1)
|
|
100
116
|
|
|
@@ -102,16 +118,16 @@
|
|
|
102
118
|
|
|
103
119
|
### Added
|
|
104
120
|
|
|
105
|
-
|
|
106
|
-
|
|
121
|
+
- Support for external bootable components (solnic)
|
|
122
|
+
- Built-in `:system` components including `:settings` component (solnic)
|
|
107
123
|
|
|
108
124
|
### Fixed
|
|
109
125
|
|
|
110
|
-
|
|
126
|
+
- Lazy-loading components work when a container has `default_namespace` configured (GustavoCaso)
|
|
111
127
|
|
|
112
128
|
### Changed
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
- [BREAKING] Improved boot DSL with support for namespacing and lifecycle before/after callbacks (solnic)
|
|
115
131
|
|
|
116
132
|
[Compare v0.7.3...v0.8.0](https://github.com/dry-rb/dry-system/compare/v0.7.3...v0.8.0)
|
|
117
133
|
|
|
@@ -119,20 +135,20 @@
|
|
|
119
135
|
|
|
120
136
|
### Fixed
|
|
121
137
|
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
- `Container.enable_stubs!` calls super too, which actually adds `stub` API (solnic)
|
|
139
|
+
- Issues with lazy-loading and import in stub mode are gone (solnic)
|
|
124
140
|
|
|
125
141
|
# 0.7.2 - 2017-08-02
|
|
126
142
|
|
|
127
143
|
### Added
|
|
128
144
|
|
|
129
|
-
|
|
145
|
+
- `Container.enable_stubs!` for test environments which enables stubbing components (GustavoCaso)
|
|
130
146
|
|
|
131
147
|
### Changed
|
|
132
148
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
149
|
+
- Component identifiers can now include same name more than once ie `foo.stuff.foo` (GustavoCaso)
|
|
150
|
+
- `Container#boot!` was renamed to `Container#start` (davydovanton)
|
|
151
|
+
- `Container#boot` was renamed to `Container#init` (davydovanton)
|
|
136
152
|
|
|
137
153
|
[Compare v0.7.1...v0.7.2](https://github.com/dry-rb/dry-system/compare/v0.7.1...v0.7.2)
|
|
138
154
|
|
|
@@ -150,20 +166,20 @@
|
|
|
150
166
|
- AutoRegistrar parses initial lines of Ruby source files for "magic comments" when auto-registering components. An `# auto_register: false` magic comment will prevent a Ruby file from being auto-registered (timriley)
|
|
151
167
|
- `Container.auto_register!`, when called with a block, yields a configuration object to control the auto-registration behavior for that path, with support for configuring 2 different aspects of auto-registration behavior (both optional):
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
end
|
|
169
|
+
```ruby
|
|
170
|
+
class MyContainer < Dry::System::Container
|
|
171
|
+
auto_register!('lib') do |config|
|
|
172
|
+
config.instance do |component|
|
|
173
|
+
# custom logic for initializing a component
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
config.exclude do |component|
|
|
177
|
+
# return true to skip auto-registration of the component, e.g.
|
|
178
|
+
# component.path =~ /entities/
|
|
164
179
|
end
|
|
165
180
|
end
|
|
166
|
-
|
|
181
|
+
end
|
|
182
|
+
```
|
|
167
183
|
|
|
168
184
|
- A helpful error will be raised if a bootable component's finalize block name doesn't match its boot file name (GustavoCaso)
|
|
169
185
|
|
|
@@ -175,13 +191,12 @@
|
|
|
175
191
|
|
|
176
192
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-system/compare/v0.6.0...v0.7.0)
|
|
177
193
|
|
|
178
|
-
|
|
179
194
|
# 0.6.0 - 2016-02-02
|
|
180
195
|
|
|
181
196
|
### Changed
|
|
182
197
|
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
- Lazy load components as they are resolved, rather than on injection (timriley)
|
|
199
|
+
- Perform registration even though component already required (blelump)
|
|
185
200
|
|
|
186
201
|
[Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-system/compare/v0.5.1...v0.6.0)
|
|
187
202
|
|
|
@@ -201,8 +216,8 @@ for multi-container setups. As part of this release `dry-system` has been rename
|
|
|
201
216
|
### Added
|
|
202
217
|
|
|
203
218
|
- Boot DSL with:
|
|
204
|
-
|
|
205
|
-
|
|
219
|
+
- Lifecycle triggers: `init`, `start` and `stop` (solnic)
|
|
220
|
+
- `use` method which auto-boots a dependency and makes it available in the booting context (solnic)
|
|
206
221
|
- When a component relies on a bootable component, and is being loaded in isolation, the component will be booted automatically (solnic)
|
|
207
222
|
|
|
208
223
|
### Changed
|
|
@@ -251,27 +266,27 @@ for multi-container setups. As part of this release `dry-system` has been rename
|
|
|
251
266
|
|
|
252
267
|
- Support for supplying a default namespace to a container, which is passed to the container's injector to allow for convenient shorthand access to registered objects in the same namespace (timriley in [#20](https://github.com/dry-rb/dry-system/pull/20))
|
|
253
268
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
end
|
|
269
|
+
```ruby
|
|
270
|
+
# Set up container with default namespace
|
|
271
|
+
module Admin
|
|
272
|
+
class Container < Dry::Component::Container
|
|
273
|
+
configure do |config|
|
|
274
|
+
config.root = Pathname.new(__dir__).join("../..")
|
|
275
|
+
config.default_namespace = "admin"
|
|
262
276
|
end
|
|
263
|
-
|
|
264
|
-
Import = Container.injector
|
|
265
277
|
end
|
|
266
278
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
279
|
+
Import = Container.injector
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
module Admin
|
|
283
|
+
class CreateUser
|
|
284
|
+
# "users.repository" will resolve an Admin::Users::Repository instance,
|
|
285
|
+
# where previously you had to identify it as "admin.users.repository"
|
|
286
|
+
include Admin::Import["users.repository"]
|
|
273
287
|
end
|
|
274
|
-
|
|
288
|
+
end
|
|
289
|
+
```
|
|
275
290
|
|
|
276
291
|
- Support for supplying to options directly to dry-auto_inject's `Builder` via `Dry::Component::Container#injector(options)`. This allows you to provide dry-auto_inject customizations like your own container of injection strategies (timriley in [#20](https://github.com/dry-rb/dry-system/pull/20))
|
|
277
292
|
- Support for accessing all available injector strategies, not just the defaults (e.g. `MyContainer.injector.some_custom_strategy`) (timriley in [#19](https://github.com/dry-rb/dry-system/pull/19))
|
|
@@ -311,27 +326,27 @@ Removed two pieces that are moving to dry-web:
|
|
|
311
326
|
|
|
312
327
|
### Added
|
|
313
328
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
329
|
+
- Provide a dependency injector as an `Inject` constant inside any subclass of `Dry::Component::Container`. This injector supports all of `dry-auto_inject`'s default injection strategies, and will lazily load any dependencies as they are injected. It also supports arbitrarily switching strategies, so they can be used in different classes as required (e.g. `include MyComponent::Inject.args["dep"]`) (timriley)
|
|
330
|
+
- Support aliased dependency names when calling the injector object (e.g. `MyComponent::Inject[foo: "my_app.foo", bar: "another.thing"]`) (timriley)
|
|
331
|
+
- Allow a custom dependency loader to be set on a container via its config (AMHOL)
|
|
317
332
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
end
|
|
333
|
+
```ruby
|
|
334
|
+
class MyContainer < Dry::Component::Container
|
|
335
|
+
configure do |config|
|
|
336
|
+
# other config
|
|
337
|
+
config.loader = MyLoader
|
|
324
338
|
end
|
|
325
|
-
|
|
339
|
+
end
|
|
340
|
+
```
|
|
326
341
|
|
|
327
342
|
### Changed
|
|
328
343
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
344
|
+
- `Container.boot` now only makes a simple `require` for the boot file (solnic)
|
|
345
|
+
- Container object is passed to `Container.finalize` blocks (solnic)
|
|
346
|
+
- Allow `Pathname` objects passed to `Container.require` (solnic)
|
|
347
|
+
- Support lazily loading missing dependencies from imported containers (solnic)
|
|
348
|
+
- `Container.import_module` renamed to `.injector` (timriley)
|
|
349
|
+
- Default injection strategy is now `kwargs`, courtesy of the new dry-auto_inject default (timriley)
|
|
335
350
|
|
|
336
351
|
[Compare v0.0.2...v0.1.0](https://github.com/dry-rb/dry-system/compare/v0.0.2...v0.1.0)
|
|
337
352
|
|
|
@@ -339,12 +354,12 @@ Removed two pieces that are moving to dry-web:
|
|
|
339
354
|
|
|
340
355
|
### Added
|
|
341
356
|
|
|
342
|
-
|
|
343
|
-
|
|
357
|
+
- Containers have a `name` setting (solnic)
|
|
358
|
+
- Containers can be imported into one another (solnic)
|
|
344
359
|
|
|
345
360
|
### Changed
|
|
346
361
|
|
|
347
|
-
|
|
362
|
+
- Container name is used to determine the name of its config file (solnic)
|
|
348
363
|
|
|
349
364
|
[Compare v0.0.1...v0.0.2](https://github.com/dry-rb/dry-system/compare/v0.0.1...v0.0.2)
|
|
350
365
|
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[gem]: https://rubygems.org/gems/dry-system
|
|
2
|
-
[travis]: https://travis-ci.
|
|
2
|
+
[travis]: https://travis-ci.com/dry-rb/dry-system
|
|
3
3
|
[codeclimate]: https://codeclimate.com/github/dry-rb/dry-system
|
|
4
4
|
[inchpages]: http://inch-ci.org/github/dry-rb/dry-system
|
|
5
5
|
[chat]: https://dry-rb.zulipchat.com
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
[][gem]
|
|
11
|
-
[][travis]
|
|
12
12
|
[][codeclimate]
|
|
13
13
|
[][codeclimate]
|
|
14
14
|
[][inchpages]
|
data/lib/dry-system.rb
CHANGED
data/lib/dry/system.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'dry/system/provider'
|
|
2
4
|
require 'dry/system/provider_registry'
|
|
3
5
|
|
|
@@ -22,7 +24,7 @@ module Dry
|
|
|
22
24
|
|
|
23
25
|
# @api private
|
|
24
26
|
def self.providers
|
|
25
|
-
@
|
|
27
|
+
@providers ||= ProviderRegistry.new
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'dry/system/constants'
|
|
2
4
|
require 'dry/system/magic_comments_parser'
|
|
3
5
|
require 'dry/system/auto_registrar/configuration'
|
|
@@ -35,7 +37,9 @@ module Dry
|
|
|
35
37
|
next if !component.auto_register? || registration_config.exclude.(component)
|
|
36
38
|
|
|
37
39
|
container.require_component(component) do
|
|
38
|
-
register(component.identifier, memoize: registration_config.memoize) {
|
|
40
|
+
register(component.identifier, memoize: registration_config.memoize) {
|
|
41
|
+
registration_config.instance.(component)
|
|
42
|
+
}
|
|
39
43
|
end
|
|
40
44
|
end
|
|
41
45
|
end
|
|
@@ -44,15 +48,15 @@ module Dry
|
|
|
44
48
|
|
|
45
49
|
# @api private
|
|
46
50
|
def components(dir)
|
|
47
|
-
files(dir)
|
|
48
|
-
map { |file_name| [file_name, file_options(file_name)] }
|
|
49
|
-
map { |(file_name, options)| component(relative_path(dir, file_name), **options) }
|
|
50
|
-
reject { |component|
|
|
51
|
+
files(dir)
|
|
52
|
+
.map { |file_name| [file_name, file_options(file_name)] }
|
|
53
|
+
.map { |(file_name, options)| component(relative_path(dir, file_name), **options) }
|
|
54
|
+
.reject { |component| registered?(component.identifier) }
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
# @api private
|
|
54
58
|
def files(dir)
|
|
55
|
-
Dir["#{root}/#{dir}/**/#{RB_GLOB}"]
|
|
59
|
+
::Dir["#{root}/#{dir}/**/#{RB_GLOB}"].sort
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
# @api private
|
|
@@ -77,8 +81,8 @@ module Dry
|
|
|
77
81
|
end
|
|
78
82
|
|
|
79
83
|
# @api private
|
|
80
|
-
def
|
|
81
|
-
container.
|
|
84
|
+
def registered?(name)
|
|
85
|
+
container.registered?(name)
|
|
82
86
|
end
|
|
83
87
|
|
|
84
88
|
# @api private
|
data/lib/dry/system/booter.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'dry/system/components/bootable'
|
|
2
4
|
require 'dry/system/errors'
|
|
3
5
|
require 'dry/system/constants'
|
|
@@ -49,9 +51,7 @@ module Dry
|
|
|
49
51
|
def load_component(path)
|
|
50
52
|
identifier = Pathname(path).basename(RB_EXT).to_s.to_sym
|
|
51
53
|
|
|
52
|
-
unless components.exists?(identifier)
|
|
53
|
-
require path
|
|
54
|
-
end
|
|
54
|
+
require path unless components.exists?(identifier)
|
|
55
55
|
|
|
56
56
|
self
|
|
57
57
|
end
|
|
@@ -108,7 +108,7 @@ module Dry
|
|
|
108
108
|
# @api private
|
|
109
109
|
def stop(name_or_component)
|
|
110
110
|
call(name_or_component) do |component|
|
|
111
|
-
raise ComponentNotStartedError
|
|
111
|
+
raise ComponentNotStartedError, name_or_component unless booted.include?(component)
|
|
112
112
|
|
|
113
113
|
component.stop
|
|
114
114
|
booted.delete(component)
|
|
@@ -120,9 +120,7 @@ module Dry
|
|
|
120
120
|
# @api private
|
|
121
121
|
def call(name_or_component)
|
|
122
122
|
with_component(name_or_component) do |component|
|
|
123
|
-
unless component
|
|
124
|
-
raise ComponentFileMismatchError.new(name, registered_booted_keys)
|
|
125
|
-
end
|
|
123
|
+
raise ComponentFileMismatchError.new(name, registered_booted_keys) unless component
|
|
126
124
|
|
|
127
125
|
yield(component) if block_given?
|
|
128
126
|
|
|
@@ -153,13 +151,16 @@ module Dry
|
|
|
153
151
|
|
|
154
152
|
# @api private
|
|
155
153
|
def require_boot_file(identifier)
|
|
156
|
-
boot_file = boot_files.detect { |path|
|
|
154
|
+
boot_file = boot_files.detect { |path|
|
|
155
|
+
Pathname(path).basename(RB_EXT).to_s == identifier.to_s
|
|
156
|
+
}
|
|
157
|
+
|
|
157
158
|
require boot_file if boot_file
|
|
158
159
|
end
|
|
159
160
|
|
|
160
161
|
# @api private
|
|
161
162
|
def boot_files
|
|
162
|
-
Dir["#{path}/**/#{RB_GLOB}"]
|
|
163
|
+
::Dir["#{path}/**/#{RB_GLOB}"].sort
|
|
163
164
|
end
|
|
164
165
|
|
|
165
166
|
# @api private
|