onload 1.1.0 → 1.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/onload/core_ext/kernel_zeitwerk.rb +24 -8
- data/lib/onload/ext/zeitwerk/loader.rb +63 -32
- data/lib/onload/version.rb +1 -1
- data/lib/onload.rb +6 -0
- data/spec/rails/dummy/log/test.log +1593 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f174cf5ba8b7da4a2a70310c1adffc4a5e4b15c7f2c37cfba8a28e341b6c2c77
|
|
4
|
+
data.tar.gz: d3c95deea100141f9cb797c805361cbadc8803a3d129fdae08d4a755e5cee713
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c5ffdbe3816eb9c410cdb9749feb160d67a16da6be7fa7fff77a11f1a16091eb7b47e6dbd1bdd0613cb2d6524b0579cd1c0ece2b19a1ab8e33177857caa3a8fe
|
|
7
|
+
data.tar.gz: 744a1ace552ca478f69fc24cc68dbdbd42ea13e3368bf633f1c0c56b14358f5cbc7343c23d017dfee9e01808fb424655c286c3b7768dc97dbc84594578d496fc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 1.1.1
|
|
2
|
+
* Fix issues with Zeitwerk v2.8 and later.
|
|
3
|
+
* Add support for Rails 8.1.
|
|
4
|
+
|
|
1
5
|
## 1.1.0
|
|
2
6
|
* Automatically add generated files to the specified ignore file, eg. `.gitignore`, when they are written.
|
|
3
7
|
- Specify an ignore file by setting `Onload.config.ignore_path` to the path to the ignore file you'd like to use.
|
|
@@ -15,18 +15,34 @@ module Kernel
|
|
|
15
15
|
# in order to load the resulting file. Otherwise you get an error about
|
|
16
16
|
# an uninitialized constant, and it's like... yeah, I _know_ it's
|
|
17
17
|
# uninitialized, that's why I'm loading this file. Whatevs.
|
|
18
|
-
loader = if Zeitwerk::Registry.respond_to?(:
|
|
18
|
+
loader = if Zeitwerk::Registry.respond_to?(:autoloads)
|
|
19
|
+
autoloads = Zeitwerk::Registry.autoloads
|
|
20
|
+
|
|
21
|
+
if autoloads.respond_to?(:registered?)
|
|
22
|
+
autoloads.registered?(file)
|
|
23
|
+
else
|
|
24
|
+
autoloads[file]
|
|
25
|
+
end
|
|
26
|
+
elsif Zeitwerk::Registry.respond_to?(:loader_for)
|
|
19
27
|
Zeitwerk::Registry.loader_for(file)
|
|
20
|
-
else
|
|
21
|
-
Zeitwerk::Registry.autoloads.registered?(file)
|
|
22
28
|
end
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
autoload_entry = if loader && loader.respond_to?(:autoloads, true)
|
|
31
|
+
loader.send(:autoloads)[file]
|
|
32
|
+
end
|
|
25
33
|
|
|
26
|
-
if
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
if autoload_entry
|
|
35
|
+
if defined?(Zeitwerk::Cref) && autoload_entry.is_a?(Zeitwerk::Cref)
|
|
36
|
+
autoload_entry.remove
|
|
37
|
+
else
|
|
38
|
+
parent, cname = autoload_entry
|
|
39
|
+
|
|
40
|
+
if defined?(Zeitwerk::Cref) && parent.is_a?(Zeitwerk::Cref)
|
|
41
|
+
parent.remove
|
|
42
|
+
else
|
|
43
|
+
parent.send(:remove_const, cname)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
30
46
|
end
|
|
31
47
|
|
|
32
48
|
return onload_orig_load(f.outfile, *args)
|
|
@@ -4,40 +4,63 @@ require "zeitwerk"
|
|
|
4
4
|
require "zeitwerk/loader"
|
|
5
5
|
|
|
6
6
|
module Onload
|
|
7
|
+
module ZeitwerkLoaderHelpers
|
|
8
|
+
class << self
|
|
9
|
+
def method_exists?(method_name)
|
|
10
|
+
Zeitwerk::Loader.method_defined?(method_name) ||
|
|
11
|
+
Zeitwerk::Loader.private_method_defined?(method_name)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
7
16
|
module ZeitwerkLoaderPatch
|
|
8
17
|
private
|
|
9
18
|
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
if Onload::ZeitwerkLoaderHelpers.method_exists?(:ruby?)
|
|
20
|
+
def ruby?(path)
|
|
21
|
+
super || Onload.process?(path)
|
|
22
|
+
end
|
|
12
23
|
end
|
|
13
24
|
|
|
14
|
-
if
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if
|
|
18
|
-
|
|
25
|
+
if Onload::ZeitwerkLoaderHelpers.method_exists?(:autoload_file)
|
|
26
|
+
if Zeitwerk::Loader.instance_method(:autoload_file).arity == 2
|
|
27
|
+
def autoload_file(cref, file)
|
|
28
|
+
if !Onload.process?(file)
|
|
29
|
+
if (unprocessed_file = Onload.unprocessed_file_for(file))
|
|
30
|
+
file = unprocessed_file
|
|
31
|
+
end
|
|
19
32
|
end
|
|
33
|
+
|
|
34
|
+
super
|
|
20
35
|
end
|
|
36
|
+
else
|
|
37
|
+
def autoload_file(parent, cname, file)
|
|
38
|
+
if Onload.process?(file)
|
|
39
|
+
# Some older versions of Zeitwerk very naively try to remove only the
|
|
40
|
+
# last 3 characters in an attempt to strip off the .rb file extension,
|
|
41
|
+
# while newer ones only remove it if it's actually there. This line is
|
|
42
|
+
# necessary to remove the trailing leftover period for older versions,
|
|
43
|
+
# and remove the entire extension for newer versions. Although cname
|
|
44
|
+
# means "constant name," we use Onload.basename to remove all residual
|
|
45
|
+
# file extensions that were left over from the conversion from a file
|
|
46
|
+
# name to a cname.
|
|
47
|
+
cname = Onload.basename(cname.to_s).to_sym
|
|
48
|
+
else
|
|
49
|
+
# if there is a corresponding unprocessed file, autoload it instead of
|
|
50
|
+
# the .rb file
|
|
51
|
+
if (unprocessed_file = Onload.unprocessed_file_for(file))
|
|
52
|
+
file = unprocessed_file
|
|
53
|
+
end
|
|
54
|
+
end
|
|
21
55
|
|
|
22
|
-
|
|
56
|
+
super
|
|
57
|
+
end
|
|
23
58
|
end
|
|
24
|
-
|
|
25
|
-
def
|
|
26
|
-
if Onload.process?(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# while newer ones only remove it if it's actually there. This line is
|
|
30
|
-
# necessary to remove the trailing leftover period for older versions,
|
|
31
|
-
# and remove the entire extension for newer versions. Although cname
|
|
32
|
-
# means "constant name," we use Onload.basename to remove all residual
|
|
33
|
-
# file extensions that were left over from the conversion from a file
|
|
34
|
-
# name to a cname.
|
|
35
|
-
cname = Onload.basename(cname.to_s).to_sym
|
|
36
|
-
else
|
|
37
|
-
# if there is a corresponding unprocessed file, autoload it instead of
|
|
38
|
-
# the .rb file
|
|
39
|
-
if (unprocessed_file = Onload.unprocessed_file_for(file))
|
|
40
|
-
file = unprocessed_file
|
|
59
|
+
elsif Onload::ZeitwerkLoaderHelpers.method_exists?(:define_autoload)
|
|
60
|
+
def define_autoload(cref, abspath)
|
|
61
|
+
if !::File.directory?(abspath) && !Onload.process?(abspath)
|
|
62
|
+
if (unprocessed_file = Onload.unprocessed_file_for(abspath))
|
|
63
|
+
abspath = unprocessed_file
|
|
41
64
|
end
|
|
42
65
|
end
|
|
43
66
|
|
|
@@ -45,15 +68,23 @@ module Onload
|
|
|
45
68
|
end
|
|
46
69
|
end
|
|
47
70
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
if Onload::ZeitwerkLoaderHelpers.method_exists?(:cname_for)
|
|
72
|
+
# introduced in Zeitwerk v2.6.10
|
|
73
|
+
def cname_for(basename, abspath)
|
|
74
|
+
super(Onload.basename(basename), abspath)
|
|
75
|
+
end
|
|
51
76
|
end
|
|
52
77
|
end
|
|
53
|
-
end
|
|
54
78
|
|
|
55
|
-
module
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
module ZeitwerkFileSystemPatch
|
|
80
|
+
def rb_extension?(path)
|
|
81
|
+
super || Onload.process?(path)
|
|
82
|
+
end
|
|
58
83
|
end
|
|
59
84
|
end
|
|
85
|
+
|
|
86
|
+
Zeitwerk::Loader.prepend(Onload::ZeitwerkLoaderPatch)
|
|
87
|
+
|
|
88
|
+
if defined?(Zeitwerk::Loader::FileSystem)
|
|
89
|
+
Zeitwerk::Loader::FileSystem.prepend(Onload::ZeitwerkFileSystemPatch)
|
|
90
|
+
end
|
data/lib/onload/version.rb
CHANGED
data/lib/onload.rb
CHANGED
|
@@ -11,6 +11,9 @@ module Onload
|
|
|
11
11
|
attr_accessor :enabled
|
|
12
12
|
alias enabled? enabled
|
|
13
13
|
|
|
14
|
+
attr_reader :installed
|
|
15
|
+
alias installed? installed
|
|
16
|
+
|
|
14
17
|
def register(extension, processor_klass)
|
|
15
18
|
processors[extension] = processor_klass
|
|
16
19
|
end
|
|
@@ -43,6 +46,8 @@ module Onload
|
|
|
43
46
|
else
|
|
44
47
|
require "onload/ext/bootsnap/autoload"
|
|
45
48
|
end
|
|
49
|
+
|
|
50
|
+
@installed = true
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
def process?(path)
|
|
@@ -136,6 +141,7 @@ module Onload
|
|
|
136
141
|
end
|
|
137
142
|
|
|
138
143
|
self.enabled = true
|
|
144
|
+
@installed = false
|
|
139
145
|
end
|
|
140
146
|
|
|
141
147
|
if Kernel.const_defined?(:Rails)
|