zeitwerk 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zeitwerk/loader.rb +19 -9
- 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: 0ff8931860945782c104aae3e03599df5c84dfdfd05aa422b3b467f227fabb23
|
4
|
+
data.tar.gz: aca07442b309c1d842ebcc9351c4c489c601331832308aee6f8f5bb49a43e4bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e42fb0efc142bae7da85f21d3d8650c5ef8a24f5f07b3b673ca6f4e74b952c90d7d935f4d2fd1c8efa217d0e19476472435df6ee7547f6c76f190796fc87c202
|
7
|
+
data.tar.gz: 1ced31f03716433f32e534952c2811bee84885c6e376c5e5e227ce695bd891154fa8464747b4e0844a74dd1e9a2d196dd3cace12835312e340ae424834b58433
|
data/lib/zeitwerk/loader.rb
CHANGED
@@ -96,7 +96,7 @@ module Zeitwerk
|
|
96
96
|
#
|
97
97
|
# "Admin::Role" => [".../admin/role.rb", [Admin, :Role]]
|
98
98
|
#
|
99
|
-
# The
|
99
|
+
# The cpath as key helps implementing unloadable_cpath? The real file name
|
100
100
|
# is stored in order to be able to delete it from $LOADED_FEATURES, and the
|
101
101
|
# pair [Module, Symbol] is used to remove_const the constant from the class
|
102
102
|
# or module object.
|
@@ -262,7 +262,7 @@ module Zeitwerk
|
|
262
262
|
break if @setup
|
263
263
|
|
264
264
|
expand_ignored_glob_patterns
|
265
|
-
|
265
|
+
actual_root_dirs.each { |root_dir| set_autoloads_in_dir(root_dir, Object) }
|
266
266
|
do_preload
|
267
267
|
|
268
268
|
@setup = true
|
@@ -292,9 +292,9 @@ module Zeitwerk
|
|
292
292
|
if parent.autoload?(cname)
|
293
293
|
unload_autoload(parent, cname)
|
294
294
|
else
|
295
|
-
# Could happen if loaded with require_relative.
|
296
|
-
#
|
297
|
-
#
|
295
|
+
# Could happen if loaded with require_relative. That is unsupported,
|
296
|
+
# and the constant path would escape unloadable_cpath? This is just
|
297
|
+
# defensive code to clean things up as much as we are able to.
|
298
298
|
unload_cref(parent, cname) if cdef?(parent, cname)
|
299
299
|
unloaded_files.add(realpath) if ruby?(realpath)
|
300
300
|
end
|
@@ -360,7 +360,7 @@ module Zeitwerk
|
|
360
360
|
mutex.synchronize do
|
361
361
|
break if @eager_loaded
|
362
362
|
|
363
|
-
queue =
|
363
|
+
queue = actual_root_dirs.reject { |dir| eager_load_exclusions.member?(dir) }
|
364
364
|
while dir = queue.shift
|
365
365
|
each_abspath(dir) do |abspath|
|
366
366
|
next if eager_load_exclusions.member?(abspath)
|
@@ -398,10 +398,18 @@ module Zeitwerk
|
|
398
398
|
#
|
399
399
|
# @param cpath [String]
|
400
400
|
# @return [Boolean]
|
401
|
-
def
|
401
|
+
def unloadable_cpath?(cpath)
|
402
402
|
to_unload.key?(cpath)
|
403
403
|
end
|
404
404
|
|
405
|
+
# Returns an array with the constant paths that would be unloaded on reload.
|
406
|
+
# This predicate returns an empty array if reloading is disabled.
|
407
|
+
#
|
408
|
+
# @return [<String>]
|
409
|
+
def unloadable_cpaths
|
410
|
+
to_unload.keys.freeze
|
411
|
+
end
|
412
|
+
|
405
413
|
# --- Class methods ---------------------------------------------------------------------------
|
406
414
|
|
407
415
|
class << self
|
@@ -450,8 +458,10 @@ module Zeitwerk
|
|
450
458
|
private # -------------------------------------------------------------------------------------
|
451
459
|
|
452
460
|
# @return [<String>]
|
453
|
-
def
|
454
|
-
root_dirs.keys.delete_if
|
461
|
+
def actual_root_dirs
|
462
|
+
root_dirs.keys.delete_if do |root_dir|
|
463
|
+
!dir?(root_dir) || ignored_paths.member?(root_dir)
|
464
|
+
end
|
455
465
|
end
|
456
466
|
|
457
467
|
# @param dir [String]
|
data/lib/zeitwerk/version.rb
CHANGED