zeitwerk 2.5.0.beta5 → 2.5.0.beta6
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/lib/zeitwerk/loader/callbacks.rb +8 -5
- data/lib/zeitwerk/loader.rb +8 -2
- 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: 74d74bec1f4963cc5d04f037e14723408ae5d1f8c4df16f31f2901402e3230ed
|
4
|
+
data.tar.gz: 3ebd7f860583cc7a560360b2e766193dc0c74c5cd902c7cb632a614e32dc68e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0bec92696285efb5ad1f76094b71a4de5a38a0665b493737c945623042b4d744be2c58f4006ed5c8c4abe0ccb70854c94ba63c3b7eeef1a5ae47086a956668d
|
7
|
+
data.tar.gz: a1392b3b73dcd85769f793aeca9a9d10cb50c70259d88761574c1e62e201b24f32d7122eda587af6017dea93fca27ce9463e5f0dae7b98523d3edba2c13802eb
|
@@ -11,16 +11,19 @@ module Zeitwerk::Loader::Callbacks
|
|
11
11
|
cref = autoloads.delete(file)
|
12
12
|
cpath = cpath(*cref)
|
13
13
|
|
14
|
+
# If reloading is enabled, we need to put this constant for unloading
|
15
|
+
# regardless of what cdef? says. In Ruby < 3.1 the internal state is not
|
16
|
+
# fully cleared. Module#constants still includes it, and you need to
|
17
|
+
# remove_const. See https://github.com/ruby/ruby/pull/4715.
|
14
18
|
to_unload[cpath] = [file, cref] if reloading_enabled?
|
15
19
|
Zeitwerk::Registry.unregister_autoload(file)
|
16
20
|
|
17
|
-
if
|
18
|
-
log("constant #{cpath} loaded from file #{file}")
|
19
|
-
|
21
|
+
if cdef?(*cref)
|
22
|
+
log("constant #{cpath} loaded from file #{file}") if logger
|
23
|
+
run_on_load_callbacks(cpath, cget(*cref), file) unless on_load_callbacks.empty?
|
24
|
+
else
|
20
25
|
raise Zeitwerk::NameError.new("expected file #{file} to define constant #{cpath}, but didn't", cref.last)
|
21
26
|
end
|
22
|
-
|
23
|
-
run_on_load_callbacks(cpath, cget(*cref), file) unless on_load_callbacks.empty?
|
24
27
|
end
|
25
28
|
|
26
29
|
# Invoked from our decorated Kernel#require when a managed directory is
|
data/lib/zeitwerk/loader.rb
CHANGED
@@ -145,7 +145,7 @@ module Zeitwerk
|
|
145
145
|
# Could happen if loaded with require_relative. That is unsupported,
|
146
146
|
# and the constant path would escape unloadable_cpath? This is just
|
147
147
|
# defensive code to clean things up as much as we are able to.
|
148
|
-
unload_cref(parent, cname)
|
148
|
+
unload_cref(parent, cname)
|
149
149
|
unloaded_files.add(abspath) if ruby?(abspath)
|
150
150
|
end
|
151
151
|
end
|
@@ -156,7 +156,7 @@ module Zeitwerk
|
|
156
156
|
run_on_unload_callbacks(cpath, value, abspath)
|
157
157
|
end
|
158
158
|
|
159
|
-
unload_cref(parent, cname)
|
159
|
+
unload_cref(parent, cname)
|
160
160
|
unloaded_files.add(abspath) if ruby?(abspath)
|
161
161
|
end
|
162
162
|
|
@@ -494,7 +494,13 @@ module Zeitwerk
|
|
494
494
|
|
495
495
|
# @sig (Module, Symbol) -> void
|
496
496
|
def unload_cref(parent, cname)
|
497
|
+
# Let's optimistically remove_const. The way we use it, this is going to
|
498
|
+
# succeed always if all is good.
|
497
499
|
parent.__send__(:remove_const, cname)
|
500
|
+
rescue ::NameError
|
501
|
+
# There are a few edge scenarios in which this may happen. If the constant
|
502
|
+
# is gone, that is OK, anyway.
|
503
|
+
else
|
498
504
|
log("#{cpath(parent, cname)} unloaded") if logger
|
499
505
|
end
|
500
506
|
end
|
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.0.
|
4
|
+
version: 2.5.0.beta6
|
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-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Zeitwerk implements constant autoloading with Ruby semantics. Each gem
|