zeitwerk 2.4.2 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Zeitwerk::RealModName
2
4
  UNBOUND_METHOD_MODULE_NAME = Module.instance_method(:name)
3
5
  private_constant :UNBOUND_METHOD_MODULE_NAME
@@ -17,7 +17,7 @@ module Zeitwerk
17
17
  # @sig Hash[String, Zeitwerk::Loader]
18
18
  attr_reader :loaders_managing_gems
19
19
 
20
- # Maps real paths to the loaders responsible for them.
20
+ # Maps absolute paths to the loaders responsible for them.
21
21
  #
22
22
  # This information is used by our decorated `Kernel#require` to be able to
23
23
  # invoke callbacks and autovivify modules.
@@ -73,6 +73,15 @@ module Zeitwerk
73
73
  loaders << loader
74
74
  end
75
75
 
76
+ # @private
77
+ # @sig (Zeitwerk::Loader) -> void
78
+ def unregister_loader(loader)
79
+ loaders.delete(loader)
80
+ loaders_managing_gems.delete_if { |_, l| l == loader }
81
+ autoloads.delete_if { |_, l| l == loader }
82
+ inceptions.delete_if { |_, (_, l)| l == loader }
83
+ end
84
+
76
85
  # This method returns always a loader, the same instance for the same root
77
86
  # file. That is how Zeitwerk::Loader.for_gem is idempotent.
78
87
  #
@@ -90,20 +99,20 @@ module Zeitwerk
90
99
 
91
100
  # @private
92
101
  # @sig (Zeitwerk::Loader, String) -> String
93
- def register_autoload(loader, realpath)
94
- autoloads[realpath] = loader
102
+ def register_autoload(loader, abspath)
103
+ autoloads[abspath] = loader
95
104
  end
96
105
 
97
106
  # @private
98
107
  # @sig (String) -> void
99
- def unregister_autoload(realpath)
100
- autoloads.delete(realpath)
108
+ def unregister_autoload(abspath)
109
+ autoloads.delete(abspath)
101
110
  end
102
111
 
103
112
  # @private
104
113
  # @sig (String, String, Zeitwerk::Loader) -> void
105
- def register_inception(cpath, realpath, loader)
106
- inceptions[cpath] = [realpath, loader]
114
+ def register_inception(cpath, abspath, loader)
115
+ inceptions[cpath] = [abspath, loader]
107
116
  end
108
117
 
109
118
  # @private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "2.4.2"
4
+ VERSION = "2.5.1"
5
5
  end
data/lib/zeitwerk.rb CHANGED
@@ -9,4 +9,16 @@ module Zeitwerk
9
9
  require_relative "zeitwerk/gem_inflector"
10
10
  require_relative "zeitwerk/kernel"
11
11
  require_relative "zeitwerk/error"
12
+ require_relative "zeitwerk/version"
13
+
14
+ # This is a dangerous method.
15
+ #
16
+ # @experimental
17
+ # @sig () -> void
18
+ def self.with_loader
19
+ loader = Zeitwerk::Loader.new
20
+ yield loader
21
+ ensure
22
+ loader.unregister
23
+ end
12
24
  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.4.2
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-27 00:00:00.000000000 Z
11
+ date: 2021-10-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zeitwerk implements constant autoloading with Ruby semantics. Each gem
@@ -30,6 +30,8 @@ files:
30
30
  - lib/zeitwerk/kernel.rb
31
31
  - lib/zeitwerk/loader.rb
32
32
  - lib/zeitwerk/loader/callbacks.rb
33
+ - lib/zeitwerk/loader/config.rb
34
+ - lib/zeitwerk/loader/helpers.rb
33
35
  - lib/zeitwerk/real_mod_name.rb
34
36
  - lib/zeitwerk/registry.rb
35
37
  - lib/zeitwerk/version.rb
@@ -49,14 +51,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
51
  requirements:
50
52
  - - ">="
51
53
  - !ruby/object:Gem::Version
52
- version: 2.4.4
54
+ version: '2.5'
53
55
  required_rubygems_version: !ruby/object:Gem::Requirement
54
56
  requirements:
55
57
  - - ">="
56
58
  - !ruby/object:Gem::Version
57
59
  version: '0'
58
60
  requirements: []
59
- rubygems_version: 3.1.2
61
+ rubygems_version: 3.2.22
60
62
  signing_key:
61
63
  specification_version: 4
62
64
  summary: Efficient and thread-safe constant autoloader