zeitwerk 2.8.0 → 2.8.1
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/README.md +6 -12
- data/lib/zeitwerk/loader/file_system.rb +2 -2
- data/lib/zeitwerk/registry/loaders.rb +2 -2
- data/lib/zeitwerk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6f3971296735d2ad5ae2d2621b5f26d6f480e7b69fde7e6eb21679a2b0c795c
|
|
4
|
+
data.tar.gz: 41ce43ff32412f63d21fb5bd9f45dc070e48e96f03be1e49eb2a5c6c5ef107ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b543e2a0db16c3dcdf8318faeaae7e1a72b0001b6116fa0081fa991266fbcc75da8ebdecaf9cf17568d9b169688810f411fb5d578a6ce7f5fad60a5fea37380
|
|
7
|
+
data.tar.gz: 021343c474a12a015071b20eaff22c53fdf9d0a49e606ee460be809fd731be065e72573ffb082bfab19b14f432000b309cc3e8e44e75669b97d91fa5b275519a
|
data/README.md
CHANGED
|
@@ -305,8 +305,8 @@ loader.nsfile = 'ns.rb' # must be set before setup
|
|
|
305
305
|
you can alternatively define the explicit namespace inside its directory:
|
|
306
306
|
|
|
307
307
|
```
|
|
308
|
-
my_component/ns.rb
|
|
309
|
-
my_component/widget.rb
|
|
308
|
+
my_component/ns.rb -> MyComponent
|
|
309
|
+
my_component/widget.rb -> MyComponent::Widget
|
|
310
310
|
```
|
|
311
311
|
|
|
312
312
|
This may be handy for self-contained units for which a `my_component.rb` file in the parent directory would feel unnatural.
|
|
@@ -316,19 +316,19 @@ A loader's nsfile has to be a non-hidden basename with a `.rb` extension, as in
|
|
|
316
316
|
Collapsed directories work as expected. For example, if we assume that `src` is collapsed, and that `assets` and `tests` are ignored, you could have the code organized this way:
|
|
317
317
|
|
|
318
318
|
```
|
|
319
|
-
my_component/src/ns.rb
|
|
320
|
-
my_component/src/widget.rb
|
|
319
|
+
my_component/src/ns.rb -> MyComponent
|
|
320
|
+
my_component/src/widget.rb -> MyComponent::Widget
|
|
321
321
|
my_component/assets/widget.js
|
|
322
322
|
my_component/tests/test_widget.rb
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
-
Loaders with an nsfile configured also support explicit namespaces defined in ordinary files. The
|
|
325
|
+
Loaders with an nsfile configured also support explicit namespaces defined in ordinary files. The conventions are not exclusive project-wide. Some parts may be component-oriented, while in other parts ordinary files may feel more natural. That works.
|
|
326
326
|
|
|
327
327
|
However, attempting to define the same namespace using an ordinary file and an nsfile is an error condition that raises `Zeitwerk::ConflictingNamespaceDefinitionError`.
|
|
328
328
|
|
|
329
329
|
Nsfiles in root directories raise `Zeitwerk::ConflictingNamespaceDefinitionError` too, since the namespace in a root directory is externally defined.
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
Non-ignored files whose basename is equal to the nsfile are always considered to be nsfiles. You cannot opt out. Therefore, if we have:
|
|
332
332
|
|
|
333
333
|
```ruby
|
|
334
334
|
loader.nsfile = 'index.rb'
|
|
@@ -336,12 +336,6 @@ loader.nsfile = 'index.rb'
|
|
|
336
336
|
|
|
337
337
|
there is no way `foo/index.rb` can define `Foo::Index` in any part of the project, it must define `Foo`.
|
|
338
338
|
|
|
339
|
-
While configurable, `ns.rb` is the recommended convention:
|
|
340
|
-
|
|
341
|
-
* `ns.rb` is short.
|
|
342
|
-
* `ns.rb` suggests "namespace".
|
|
343
|
-
* Needing an `Ns` constant is unlikely.
|
|
344
|
-
|
|
345
339
|
<a id="markdown-collapsing-directories" name="collapsing-directories"></a>
|
|
346
340
|
### Collapsing directories
|
|
347
341
|
|
|
@@ -27,7 +27,7 @@ class Zeitwerk::Loader::FileSystem # :nodoc:
|
|
|
27
27
|
# path, and file type, which can only be :file or :directory.
|
|
28
28
|
#
|
|
29
29
|
#: (String) { (String, String, Symbol) -> void } -> void
|
|
30
|
-
def ls(dir, collapse: true, &)
|
|
30
|
+
def ls(dir, collapse: true, &block)
|
|
31
31
|
children = relevant_dir_entries(dir)
|
|
32
32
|
|
|
33
33
|
# The order in which a directory is listed depends on the file system.
|
|
@@ -43,7 +43,7 @@ class Zeitwerk::Loader::FileSystem # :nodoc:
|
|
|
43
43
|
@loader.__log { "directory #{abspath} is ignored because it has no Ruby files" }
|
|
44
44
|
next
|
|
45
45
|
elsif collapse && @loader.__collapse?(abspath)
|
|
46
|
-
ls(abspath, collapse: collapse, &)
|
|
46
|
+
ls(abspath, collapse: collapse, &block)
|
|
47
47
|
next
|
|
48
48
|
end
|
|
49
49
|
end
|
data/lib/zeitwerk/version.rb
CHANGED