zeitwerk 2.5.1 → 2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -8
- data/lib/zeitwerk/kernel.rb +9 -9
- data/lib/zeitwerk/loader.rb +0 -1
- data/lib/zeitwerk/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: 8e0d44c224600274a41893cc27d119539f5d625c3be6ed46a54052d9b139c58c
|
4
|
+
data.tar.gz: 16c701ed5717318fab08631a001a7c067f81a2027fabbfe4b6a0f6775da60a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d897fb5bdfc8b27080dbcd6160945e4a4cec6fb0f31c4eb21cd448ec26d1291ad373696995aaddcf4e387b7d731fbe4530b43f3b77f97159ba69bed447f07ade
|
7
|
+
data.tar.gz: 3cc2dbbc0840f2d420eb32ed725aaf24b7d889d989060211a9877703b44b6e71fa1d1884df2f50cfbf121b1954cf51db7e867232cde7470698fdb7e408c1be23
|
data/README.md
CHANGED
@@ -50,8 +50,8 @@
|
|
50
50
|
- [Rules of thumb](#rules-of-thumb)
|
51
51
|
- [Debuggers](#debuggers)
|
52
52
|
- [debug.rb](#debugrb)
|
53
|
-
- [Break](#break)
|
54
53
|
- [Byebug](#byebug)
|
54
|
+
- [Break](#break)
|
55
55
|
- [Pronunciation](#pronunciation)
|
56
56
|
- [Supported Ruby versions](#supported-ruby-versions)
|
57
57
|
- [Testing](#testing)
|
@@ -810,7 +810,9 @@ Kernel.module_eval do
|
|
810
810
|
end
|
811
811
|
```
|
812
812
|
|
813
|
-
|
813
|
+
`Kernel` is already defined by Ruby so the module cannot be autoloaded. Also, that file does not define a constant path after the path name. Therefore, Zeitwerk should not process it at all.
|
814
|
+
|
815
|
+
The extension can still coexist with the rest of the project, you only need to tell Zeitwerk to ignore it:
|
814
816
|
|
815
817
|
```ruby
|
816
818
|
kernel_ext = "#{__dir__}/my_gem/core_ext/kernel.rb"
|
@@ -826,6 +828,14 @@ loader.ignore(core_ext)
|
|
826
828
|
loader.setup
|
827
829
|
```
|
828
830
|
|
831
|
+
Now, that file has to be loaded manually with `require` or `require_relative`:
|
832
|
+
|
833
|
+
```ruby
|
834
|
+
require_relative "my_gem/core_ext/kernel"
|
835
|
+
```
|
836
|
+
|
837
|
+
and you can do that anytime, before configuring the loader, or after configuring the loader, does not matter.
|
838
|
+
|
829
839
|
<a id="markdown-use-case-the-adapter-pattern" name="use-case-the-adapter-pattern"></a>
|
830
840
|
#### Use case: The adapter pattern
|
831
841
|
|
@@ -973,17 +983,19 @@ With that, when Zeitwerk scans the file system and reaches the gem directories `
|
|
973
983
|
<a id="markdown-debugrb" name="debugrb"></a>
|
974
984
|
#### debug.rb
|
975
985
|
|
976
|
-
The new [debug.rb](https://github.com/ruby/debug) gem and Zeitwerk
|
986
|
+
The new [debug.rb](https://github.com/ruby/debug) gem and Zeitwerk are mostly compatible. This is the new debugger that is going to ship with Ruby 3.1.
|
977
987
|
|
978
|
-
|
979
|
-
#### Break
|
980
|
-
|
981
|
-
Zeitwerk works fine with [@gsamokovarov](https://github.com/gsamokovarov)'s [Break](https://github.com/gsamokovarov/break) debugger.
|
988
|
+
There's one exception, though: Due to a technical limitation of tracepoints, explicit namespaces are not autoloaded while expressions are evaluated in the REPL. See [ruby/debug#408](https://github.com/ruby/debug/issues/408).
|
982
989
|
|
983
990
|
<a id="markdown-byebug" name="byebug"></a>
|
984
991
|
#### Byebug
|
985
992
|
|
986
|
-
Zeitwerk and [Byebug](https://github.com/deivid-rodriguez/byebug)
|
993
|
+
Zeitwerk and [Byebug](https://github.com/deivid-rodriguez/byebug) have a similar edge incompatibility.
|
994
|
+
|
995
|
+
<a id="markdown-break" name="break"></a>
|
996
|
+
#### Break
|
997
|
+
|
998
|
+
Zeitwerk works fine with [@gsamokovarov](https://github.com/gsamokovarov)'s [Break](https://github.com/gsamokovarov/break) debugger.
|
987
999
|
|
988
1000
|
<a id="markdown-pronunciation" name="pronunciation"></a>
|
989
1001
|
## Pronunciation
|
data/lib/zeitwerk/kernel.rb
CHANGED
@@ -24,22 +24,22 @@ module Kernel
|
|
24
24
|
def require(path)
|
25
25
|
if loader = Zeitwerk::Registry.loader_for(path)
|
26
26
|
if path.end_with?(".rb")
|
27
|
-
zeitwerk_original_require(path)
|
28
|
-
|
29
|
-
|
27
|
+
required = zeitwerk_original_require(path)
|
28
|
+
loader.on_file_autoloaded(path) if required
|
29
|
+
required
|
30
30
|
else
|
31
31
|
loader.on_dir_autoloaded(path)
|
32
32
|
true
|
33
33
|
end
|
34
34
|
else
|
35
|
-
zeitwerk_original_require(path)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
35
|
+
required = zeitwerk_original_require(path)
|
36
|
+
if required
|
37
|
+
abspath = $LOADED_FEATURES.last
|
38
|
+
if loader = Zeitwerk::Registry.loader_for(abspath)
|
39
|
+
loader.on_file_autoloaded(abspath)
|
41
40
|
end
|
42
41
|
end
|
42
|
+
required
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/lib/zeitwerk/loader.rb
CHANGED
data/lib/zeitwerk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeitwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Noria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Zeitwerk implements constant autoloading with Ruby semantics. Each gem
|