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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e58e19aad2055cd64f4ac3018cd6425e8f29f83d765b2410a28bef02f3fee381
4
- data.tar.gz: e23bb3b21e15667fb8be922b0ced718ba135a5610cc0c6965304701ff580e404
3
+ metadata.gz: 3dbf7502d4126651ab645926f072af5f5164fcb495c06ae32e9748aa2807670e
4
+ data.tar.gz: e124bca82ed054d1ca304e95605ad011a2c6411792653c3c86b785a3cc956e06
5
5
  SHA512:
6
- metadata.gz: 3e6e6271f1f9cce47fb81b50d495aeb1159819ee68b0675752bb329494d77524ac624cb067d96f638a1580c2ad342832e3eab9f8cf8ad6b296d83524ef590f03
7
- data.tar.gz: 7b4c4bae3b1fdf0214eeb7881ab855ad1babd5a28d1ab640105405b073bc1fcc54b08df1d6d0c416584363804268d7428b082a9822d8a0870f59224462ded513
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, resets the loader so that it will pick whatever is in the file system now, and runs preloads if there are any.
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
 
@@ -4,4 +4,7 @@ module Zeitwerk
4
4
 
5
5
  class ReloadingDisabledError < Error
6
6
  end
7
+
8
+ class NameError < ::NameError
9
+ end
7
10
  end
@@ -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
- if ruby?(basename)
478
- basename.slice!(-3, 3)
479
- cname = inflector.camelize(basename, abspath).to_sym
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
- autoload_subdir(parent, cname, abspath)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "2.1.9"
4
+ VERSION = "2.1.10"
5
5
  end
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.9
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-07-16 00:00:00.000000000 Z
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