zeitwerk 2.1.9 → 2.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/zeitwerk/error.rb +3 -0
- data/lib/zeitwerk/loader.rb +30 -13
- data/lib/zeitwerk/real_mod_name.rb +1 -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: 3dbf7502d4126651ab645926f072af5f5164fcb495c06ae32e9748aa2807670e
|
4
|
+
data.tar.gz: e124bca82ed054d1ca304e95605ad011a2c6411792653c3c86b785a3cc956e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efe14aeb7e16563d6a1b69b2aac82d75dd1c4e79dae2fb4654e7c93742e15018f16fad4591f8763bf03b2f9d9d71a6e95209907a0765952dafa8dedc957d2ef
|
7
|
+
data.tar.gz: 8dea5ad3b1979cacb619b13385b337e81cc08efc39e0411f890229f0a9d17035fdfb17cf2ac84f6dcd3eeec4b4daa732e796e51fc1fdf707c210d9943481edcf
|
data/README.md
CHANGED
@@ -221,7 +221,7 @@ Enabling reloading after setup raises `Zeitwerk::Error`. Similarly, calling `rel
|
|
221
221
|
|
222
222
|
Generally speaking, reloading is useful while developing running services like web applications. Gems that implement regular libraries, so to speak, or services running in testing or production environments, won't normally have a use case for reloading. If reloading is not enabled, Zeitwerk is able to use less memory.
|
223
223
|
|
224
|
-
Reloading removes the currently loaded classes and modules
|
224
|
+
Reloading removes the currently loaded classes and modules and resets the loader so that it will pick whatever is in the file system now.
|
225
225
|
|
226
226
|
It is important to highlight that this is an instance method. Don't worry about project dependencies managed by Zeitwerk, their loaders are independent.
|
227
227
|
|
data/lib/zeitwerk/error.rb
CHANGED
data/lib/zeitwerk/loader.rb
CHANGED
@@ -474,21 +474,38 @@ module Zeitwerk
|
|
474
474
|
# @return [void]
|
475
475
|
def set_autoloads_in_dir(dir, parent)
|
476
476
|
ls(dir) do |basename, abspath|
|
477
|
-
|
478
|
-
basename
|
479
|
-
|
480
|
-
autoload_file(parent, cname, abspath)
|
481
|
-
elsif dir?(abspath)
|
482
|
-
# In a Rails application, `app/models/concerns` is a subdirectory of
|
483
|
-
# `app/models`, but both of them are root directories.
|
484
|
-
#
|
485
|
-
# To resolve the ambiguity file name -> constant path this introduces,
|
486
|
-
# the `app/models/concerns` directory is totally ignored as a namespace,
|
487
|
-
# it counts only as root. The guard checks that.
|
488
|
-
unless root_dirs.key?(abspath)
|
477
|
+
begin
|
478
|
+
if ruby?(basename)
|
479
|
+
basename.slice!(-3, 3)
|
489
480
|
cname = inflector.camelize(basename, abspath).to_sym
|
490
|
-
|
481
|
+
autoload_file(parent, cname, abspath)
|
482
|
+
elsif dir?(abspath)
|
483
|
+
# In a Rails application, `app/models/concerns` is a subdirectory of
|
484
|
+
# `app/models`, but both of them are root directories.
|
485
|
+
#
|
486
|
+
# To resolve the ambiguity file name -> constant path this introduces,
|
487
|
+
# the `app/models/concerns` directory is totally ignored as a namespace,
|
488
|
+
# it counts only as root. The guard checks that.
|
489
|
+
unless root_dirs.key?(abspath)
|
490
|
+
cname = inflector.camelize(basename, abspath).to_sym
|
491
|
+
autoload_subdir(parent, cname, abspath)
|
492
|
+
end
|
491
493
|
end
|
494
|
+
rescue ::NameError => error
|
495
|
+
path_type = ruby?(abspath) ? "file" : "directory"
|
496
|
+
|
497
|
+
raise NameError, <<~MESSAGE
|
498
|
+
#{error.message} inferred by #{inflector.class} from #{path_type}
|
499
|
+
|
500
|
+
#{abspath}
|
501
|
+
|
502
|
+
Possible ways to address this:
|
503
|
+
|
504
|
+
* Tell Zeitwerk to ignore this particular #{path_type}.
|
505
|
+
* Tell Zeitwerk to ignore one of its parent directories.
|
506
|
+
* Rename the #{path_type} to comply with the naming conventions.
|
507
|
+
* Modify the inflector to handle this case.
|
508
|
+
MESSAGE
|
492
509
|
end
|
493
510
|
end
|
494
511
|
end
|
@@ -8,7 +8,7 @@ module Zeitwerk::RealModName
|
|
8
8
|
# The name method can be overridden, hence the indirection in this method.
|
9
9
|
#
|
10
10
|
# @param mod [Class, Module]
|
11
|
-
# @return [String]
|
11
|
+
# @return [String, nil]
|
12
12
|
def real_mod_name(mod)
|
13
13
|
UNBOUND_METHOD_MODULE_NAME.bind(mod).call
|
14
14
|
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.1.
|
4
|
+
version: 2.1.10
|
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-
|
11
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Zeitwerk implements constant autoloading with Ruby semantics. Each gem
|