zeitwerk 1.3.3 → 1.3.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 +22 -3
- 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: 53e3caf01e7af10f0f12922ebbe41f400a27eee1fa8d47a1d580ba1bb421393b
|
4
|
+
data.tar.gz: 6b76087bdc7abec95aa7a70ee5c5b70cb7567e7b02c8dbb290852a3bda523089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31aabb9e4c66028674508efa6dad871ece2893a3bb78e9c53d24be6721dbbd1a9f0960348ca5c7b33dc3e16670bd2c8b37eea3d813f6ce045b63410a73033a66
|
7
|
+
data.tar.gz: dc9f42aecb424d7695d48e831ec0ef70159538ded7abf470cc0a26195087aa8a3ce0d3a3a83c8978a88dda8fccb747013db60b0b1b2169e5a6c9ff1b30e94bb8
|
data/lib/zeitwerk/loader.rb
CHANGED
@@ -53,6 +53,21 @@ module Zeitwerk
|
|
53
53
|
# @return [Set<String>]
|
54
54
|
attr_reader :ignored_paths
|
55
55
|
|
56
|
+
# Keeps track of shadowed files.
|
57
|
+
#
|
58
|
+
# A shadowed file is a file managed by this autoloader that is skipped
|
59
|
+
# because its matching constant path has already been seen. Think $LOAD_PATH
|
60
|
+
# + require, only the first occurrence of a given relative name is loaded.
|
61
|
+
#
|
62
|
+
# If the existing occurrence is an autoload, we map the file name to the
|
63
|
+
# shadowing autoload path. If the existing occurrence is an already defined
|
64
|
+
# constant, the file name is mapped to the constant path, meaning it was
|
65
|
+
# loaded elsewhere.
|
66
|
+
#
|
67
|
+
# @private
|
68
|
+
# @return [{String => String}]
|
69
|
+
attr_reader :shadowed
|
70
|
+
|
56
71
|
# Maps real absolute paths for which an autoload has been set to their
|
57
72
|
# corresponding parent class or module and constant name.
|
58
73
|
#
|
@@ -106,6 +121,7 @@ module Zeitwerk
|
|
106
121
|
@autoloads = {}
|
107
122
|
@loaded = Set.new
|
108
123
|
@lazy_subdirs = {}
|
124
|
+
@shadowed = {}
|
109
125
|
|
110
126
|
@mutex = Mutex.new
|
111
127
|
@setup = false
|
@@ -216,6 +232,7 @@ module Zeitwerk
|
|
216
232
|
autoloads.clear
|
217
233
|
loaded.clear
|
218
234
|
lazy_subdirs.clear
|
235
|
+
shadowed.clear
|
219
236
|
|
220
237
|
Registry.on_unload(self)
|
221
238
|
ExplicitNamespace.unregister(self)
|
@@ -249,7 +266,7 @@ module Zeitwerk
|
|
249
266
|
while dir = queue.shift
|
250
267
|
each_abspath(dir) do |abspath|
|
251
268
|
if ruby?(abspath)
|
252
|
-
require abspath
|
269
|
+
require abspath unless shadowed.key?(abspath)
|
253
270
|
elsif dir?(abspath)
|
254
271
|
queue << abspath
|
255
272
|
end
|
@@ -370,7 +387,7 @@ module Zeitwerk
|
|
370
387
|
def autoload_file(parent, cname, file)
|
371
388
|
if autoload_path = autoload_for?(parent, cname)
|
372
389
|
# First autoload for a Ruby file wins, just ignore subsequent ones.
|
373
|
-
return if ruby?(autoload_path)
|
390
|
+
shadowed[file] = autoload_path and return if ruby?(autoload_path)
|
374
391
|
|
375
392
|
# Override autovivification, we want the namespace to become the
|
376
393
|
# class/module defined in this file.
|
@@ -379,7 +396,9 @@ module Zeitwerk
|
|
379
396
|
|
380
397
|
set_autoload(parent, cname, file)
|
381
398
|
register_explicit_namespace(cpath(parent, cname))
|
382
|
-
elsif
|
399
|
+
elsif cdef?(parent, cname)
|
400
|
+
shadowed[file] = cpath(parent, cname)
|
401
|
+
else
|
383
402
|
set_autoload(parent, cname, file)
|
384
403
|
end
|
385
404
|
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: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Noria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Zeitwerk implements constant autoloading with Ruby semantics. Each gem
|