zeitwerk 2.2.1 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,7 @@ module Zeitwerk::Loader::Callbacks
4
4
  # Invoked from our decorated Kernel#require when a managed file is autoloaded.
5
5
  #
6
6
  # @private
7
- # @param file [String]
8
- # @return [void]
7
+ # @sig (String) -> void
9
8
  def on_file_autoloaded(file)
10
9
  cref = autoloads.delete(file)
11
10
  to_unload[cpath(*cref)] = [file, cref] if reloading_enabled?
@@ -14,7 +13,7 @@ module Zeitwerk::Loader::Callbacks
14
13
  if logger && cdef?(*cref)
15
14
  log("constant #{cpath(*cref)} loaded from file #{file}")
16
15
  elsif !cdef?(*cref)
17
- raise Zeitwerk::NameError, "expected file #{file} to define constant #{cpath(*cref)}, but didn't"
16
+ raise Zeitwerk::NameError.new("expected file #{file} to define constant #{cpath(*cref)}, but didn't", cref.last)
18
17
  end
19
18
  end
20
19
 
@@ -22,8 +21,7 @@ module Zeitwerk::Loader::Callbacks
22
21
  # autoloaded.
23
22
  #
24
23
  # @private
25
- # @param dir [String]
26
- # @return [void]
24
+ # @sig (String) -> void
27
25
  def on_dir_autoloaded(dir)
28
26
  # Module#autoload does not serialize concurrent requires, and we handle
29
27
  # directories ourselves, so the callback needs to account for concurrency.
@@ -59,8 +57,7 @@ module Zeitwerk::Loader::Callbacks
59
57
  # subdirectories, we descend into them now.
60
58
  #
61
59
  # @private
62
- # @param namespace [Module]
63
- # @return [void]
60
+ # @sig (Module) -> void
64
61
  def on_namespace_loaded(namespace)
65
62
  if subdirs = lazy_subdirs.delete(real_mod_name(namespace))
66
63
  subdirs.each do |subdir|
@@ -7,8 +7,7 @@ module Zeitwerk::RealModName
7
7
  #
8
8
  # The name method can be overridden, hence the indirection in this method.
9
9
  #
10
- # @param mod [Class, Module]
11
- # @return [String, nil]
10
+ # @sig (Module) -> String?
12
11
  if UnboundMethod.method_defined?(:bind_call)
13
12
  def real_mod_name(mod)
14
13
  UNBOUND_METHOD_MODULE_NAME.bind_call(mod)
@@ -7,14 +7,14 @@ module Zeitwerk
7
7
  # them from being garbage collected.
8
8
  #
9
9
  # @private
10
- # @return [<Zeitwerk::Loader>]
10
+ # @sig Array[Zeitwerk::Loader]
11
11
  attr_reader :loaders
12
12
 
13
13
  # Registers loaders created with `for_gem` to make the method idempotent
14
14
  # in case of reload.
15
15
  #
16
16
  # @private
17
- # @return [{String => Zeitwerk::Loader}]
17
+ # @sig Hash[String, Zeitwerk::Loader]
18
18
  attr_reader :loaders_managing_gems
19
19
 
20
20
  # Maps real paths to the loaders responsible for them.
@@ -23,7 +23,7 @@ module Zeitwerk
23
23
  # invoke callbacks and autovivify modules.
24
24
  #
25
25
  # @private
26
- # @return [{String => Zeitwerk::Loader}]
26
+ # @sig Hash[String, Zeitwerk::Loader]
27
27
  attr_reader :autoloads
28
28
 
29
29
  # This hash table addresses an edge case in which an autoload is ignored.
@@ -62,14 +62,13 @@ module Zeitwerk
62
62
  # end
63
63
  #
64
64
  # @private
65
- # @return [{String => (String, Zeitwerk::Loader)}]
65
+ # @sig Hash[String, [String, Zeitwerk::Loader]]
66
66
  attr_reader :inceptions
67
67
 
68
68
  # Registers a loader.
69
69
  #
70
70
  # @private
71
- # @param loader [Zeitwerk::Loader]
72
- # @return [void]
71
+ # @sig (Zeitwerk::Loader) -> void
73
72
  def register_loader(loader)
74
73
  loaders << loader
75
74
  end
@@ -78,8 +77,7 @@ module Zeitwerk
78
77
  # file. That is how Zeitwerk::Loader.for_gem is idempotent.
79
78
  #
80
79
  # @private
81
- # @param root_file [String]
82
- # @return [Zeitwerk::Loader]
80
+ # @sig (String) -> Zeitwerk::Loader
83
81
  def loader_for_gem(root_file)
84
82
  loaders_managing_gems[root_file] ||= begin
85
83
  Loader.new.tap do |loader|
@@ -91,32 +89,25 @@ module Zeitwerk
91
89
  end
92
90
 
93
91
  # @private
94
- # @param loader [Zeitwerk::Loader]
95
- # @param realpath [String]
96
- # @return [void]
92
+ # @sig (Zeitwerk::Loader, String) -> String
97
93
  def register_autoload(loader, realpath)
98
94
  autoloads[realpath] = loader
99
95
  end
100
96
 
101
97
  # @private
102
- # @param realpath [String]
103
- # @return [void]
98
+ # @sig (String) -> void
104
99
  def unregister_autoload(realpath)
105
100
  autoloads.delete(realpath)
106
101
  end
107
102
 
108
103
  # @private
109
- # @param cpath [String]
110
- # @param realpath [String]
111
- # @param loader [Zeitwerk::Loader]
112
- # @return [void]
104
+ # @sig (String, String, Zeitwerk::Loader) -> void
113
105
  def register_inception(cpath, realpath, loader)
114
106
  inceptions[cpath] = [realpath, loader]
115
107
  end
116
108
 
117
109
  # @private
118
- # @param cpath [String]
119
- # @return [String, nil]
110
+ # @sig (String) -> String?
120
111
  def inception?(cpath)
121
112
  if pair = inceptions[cpath]
122
113
  pair.first
@@ -124,15 +115,13 @@ module Zeitwerk
124
115
  end
125
116
 
126
117
  # @private
127
- # @param path [String]
128
- # @return [Zeitwerk::Loader, nil]
118
+ # @sig (String) -> Zeitwerk::Loader?
129
119
  def loader_for(path)
130
120
  autoloads[path]
131
121
  end
132
122
 
133
123
  # @private
134
- # @param loader [Zeitwerk::Loader]
135
- # @return [void]
124
+ # @sig (Zeitwerk::Loader) -> void
136
125
  def on_unload(loader)
137
126
  autoloads.delete_if { |_path, object| object == loader }
138
127
  inceptions.delete_if { |_cpath, (_path, object)| object == loader }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "2.2.1"
4
+ VERSION = "2.4.1"
5
5
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeitwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zeitwerk implements constant autoloading with Ruby semantics. Each gem
15
15
  and application may have their own independent autoloader, with its own
16
- configuration, inflector, and logger. Supports autoloading, preloading,
16
+ configuration, inflector, and logger. Supports autoloading,
17
17
  reloading, and eager loading.
18
18
  email: fxn@hashref.com
19
19
  executables: []
@@ -36,8 +36,12 @@ files:
36
36
  homepage: https://github.com/fxn/zeitwerk
37
37
  licenses:
38
38
  - MIT
39
- metadata: {}
40
- post_install_message:
39
+ metadata:
40
+ homepage_uri: https://github.com/fxn/zeitwerk
41
+ changelog_uri: https://github.com/fxn/zeitwerk/blob/master/CHANGELOG.md
42
+ source_code_uri: https://github.com/fxn/zeitwerk
43
+ bug_tracker_uri: https://github.com/fxn/zeitwerk/issues
44
+ post_install_message:
41
45
  rdoc_options: []
42
46
  require_paths:
43
47
  - lib
@@ -52,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
56
  - !ruby/object:Gem::Version
53
57
  version: '0'
54
58
  requirements: []
55
- rubygems_version: 3.0.3
56
- signing_key:
59
+ rubygems_version: 3.1.2
60
+ signing_key:
57
61
  specification_version: 4
58
62
  summary: Efficient and thread-safe constant autoloader
59
63
  test_files: []