zeitwerk 1.4.2 → 1.4.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: 05ee62051ec4e4b4a50ab150ee600cf4f39ecece0f072a17ee5984a1a65b2a14
4
- data.tar.gz: 605e82704338fa70cc07daa4d8700e03bd84442ba59d8c5b8ed82835b03162e7
3
+ metadata.gz: 6cb6bd7dd37980b33d67ae3b1a8b5a8228911dd833698617991f6026b06a122c
4
+ data.tar.gz: 8a9d2438c2008c5c04f21692d1dea9dd0cd7756eb3cd4460262866b1b9eda42f
5
5
  SHA512:
6
- metadata.gz: 2d65cc6e332f47bc471ee3cc18c54e4b3fe3a1a1b60c2943a075646260fced9ed8cf63709dbd6adf7b71be3544353d38107a8a0eafd48e453729b865bd037017
7
- data.tar.gz: db95bb4028025ded4491f16eb10f22c77af5f4245cc67d23d47471ae8491a1f5f58be276e54c37714357d891997caaa398f77a5a70b0b763d9264b77570605d6
6
+ metadata.gz: aa2bfe23d1b4c3dde4f6df132c0e6bfb908e540cdc76177cc676fdd7d6843bd6b9af4032978f9948c46c1b74e1979ee592028cafba02fa25f3bdd5eaec0a3d67
7
+ data.tar.gz: ba5301619afb7d13dd1081330826b06c5bf6a8d520f56aa788423f14fcc2854c70cc9e8d5db7abec9733e05bc7ac3f6e8c7852f4563359abbcc46e5171f96371
@@ -227,19 +227,31 @@ module Zeitwerk
227
227
  # @return [void]
228
228
  def unload
229
229
  mutex.synchronize do
230
- autoloads.each do |path, (parent, cname)|
230
+ # We are going to keep track of the files that were required by our
231
+ # autoloads to later remove them from $LOADED_FEATURES, thus making them
232
+ # loadable by Kernel#require again.
233
+ #
234
+ # Directories are not stored in $LOADED_FEATURES, keeping track of files
235
+ # is enough.
236
+ unloaded_files = Set.new
237
+
238
+ autoloads.each do |realpath, (parent, cname)|
231
239
  if parent.autoload?(cname)
232
240
  parent.send(:remove_const, cname)
233
241
  log("autoload for #{cpath(parent, cname)} removed") if logger
234
- elsif cdef?(parent, cname)
235
- parent.send(:remove_const, cname)
236
- log("#{cpath(parent, cname)} unloaded") if logger
242
+ else
243
+ if cdef?(parent, cname)
244
+ parent.send(:remove_const, cname)
245
+ log("#{cpath(parent, cname)} unloaded") if logger
246
+ else
247
+ # Already unloaded somehow, that is fine.
248
+ end
249
+ unloaded_files.add(realpath) if ruby?(realpath)
237
250
  end
251
+ end
238
252
 
239
- # Let Kernel#require load the same path later again by removing it
240
- # from $LOADED_FEATURES. We check the extension to avoid unnecessary
241
- # array lookups, since directories are not stored in $LOADED_FEATURES.
242
- $LOADED_FEATURES.delete(path) if ruby?(path)
253
+ unless unloaded_files.empty?
254
+ $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) }
243
255
  end
244
256
 
245
257
  autoloads.clear
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "1.4.2"
4
+ VERSION = "1.4.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: 1.4.2
4
+ version: 1.4.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: 2019-03-23 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zeitwerk implements constant autoloading with Ruby semantics. Each gem