zeitwerk 2.5.2 → 2.5.3

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: edfc3d6e8c62e95f5a008e6625b5b7f2ff7e0067e3d311ec352e1bf6c6922c27
4
- data.tar.gz: 9087c6cc6524a8fd2b6843c283496e29cc5d9157421f6ba7994feb362f383333
3
+ metadata.gz: 8e0d44c224600274a41893cc27d119539f5d625c3be6ed46a54052d9b139c58c
4
+ data.tar.gz: 16c701ed5717318fab08631a001a7c067f81a2027fabbfe4b6a0f6775da60a7d
5
5
  SHA512:
6
- metadata.gz: 4d31bf02d352d61024f553f21b14093bc4d8cfc9276c106e8a67b499044aaf12bdd076288c89828b342a1980f163706b62c82d9bd21c15cdc4cadacf117e5299
7
- data.tar.gz: 89cc85a2efeb95760de195fc2acf854256dba89cdee2208992c33ba5d8cb78ad71adaddc757026660dbc4a2d562e1efa623572b91d2107e9cf30020ea83524ab
6
+ metadata.gz: d897fb5bdfc8b27080dbcd6160945e4a4cec6fb0f31c4eb21cd448ec26d1291ad373696995aaddcf4e387b7d731fbe4530b43f3b77f97159ba69bed447f07ade
7
+ data.tar.gz: 3cc2dbbc0840f2d420eb32ed725aaf24b7d889d989060211a9877703b44b6e71fa1d1884df2f50cfbf121b1954cf51db7e867232cde7470698fdb7e408c1be23
@@ -29,7 +29,6 @@ module Kernel
29
29
  required
30
30
  else
31
31
  loader.on_dir_autoloaded(path)
32
- $LOADED_FEATURES << path
33
32
  true
34
33
  end
35
34
  else
@@ -123,7 +123,13 @@ module Zeitwerk
123
123
  # @sig () -> void
124
124
  def unload
125
125
  mutex.synchronize do
126
- abspaths_of_unloaded_crefs = Set.new
126
+ # We are going to keep track of the files that were required by our
127
+ # autoloads to later remove them from $LOADED_FEATURES, thus making them
128
+ # loadable by Kernel#require again.
129
+ #
130
+ # Directories are not stored in $LOADED_FEATURES, keeping track of files
131
+ # is enough.
132
+ unloaded_files = Set.new
127
133
 
128
134
  autoloads.each do |abspath, (parent, cname)|
129
135
  if parent.autoload?(cname)
@@ -133,7 +139,7 @@ module Zeitwerk
133
139
  # and the constant path would escape unloadable_cpath? This is just
134
140
  # defensive code to clean things up as much as we are able to.
135
141
  unload_cref(parent, cname)
136
- abspaths_of_unloaded_crefs.add(abspath)
142
+ unloaded_files.add(abspath) if ruby?(abspath)
137
143
  end
138
144
  end
139
145
 
@@ -144,14 +150,10 @@ module Zeitwerk
144
150
  end
145
151
 
146
152
  unload_cref(parent, cname)
147
- abspaths_of_unloaded_crefs.add(abspath)
153
+ unloaded_files.add(abspath) if ruby?(abspath)
148
154
  end
149
155
 
150
- unless abspaths_of_unloaded_crefs.empty?
151
- # We remove these abspaths from $LOADED_FEATURES because, otherwise,
152
- # `require`'s idempotence would prevent newly defined autoloads from
153
- # loading them again.
154
- #
156
+ unless unloaded_files.empty?
155
157
  # Bootsnap decorates Kernel#require to speed it up using a cache and
156
158
  # this optimization does not check if $LOADED_FEATURES has the file.
157
159
  #
@@ -163,7 +165,7 @@ module Zeitwerk
163
165
  # Rails applications may depend on bootsnap, so for unloading to work
164
166
  # in that setting it is preferable that we restrict our API choice to
165
167
  # one of those methods.
166
- $LOADED_FEATURES.reject! { |file| abspaths_of_unloaded_crefs.member?(file) }
168
+ $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) }
167
169
  end
168
170
 
169
171
  autoloads.clear
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "2.5.2"
4
+ VERSION = "2.5.3"
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.5.2
4
+ version: 2.5.3
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-12-27 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zeitwerk implements constant autoloading with Ruby semantics. Each gem