opal-zeitwerk 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opal/zeitwerk/version.rb +1 -1
- data/opal/zeitwerk/explicit_namespace.rb +3 -3
- data/opal/zeitwerk/loader.rb +20 -14
- data/opal/zeitwerk/loader/callbacks.rb +3 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 926d4439591306fd785d55b4f69b3b60212c3db911255d9cfad96286f22c373b
|
4
|
+
data.tar.gz: f541fcfaac3eb639f070c11a8909835a5401669ce69e41c723b9a583c312e3ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccac14d70164bbfd729f56c3ef9eaf1cb50716d83b218845da396e83db85b9866f5520290e5b8d6bda32c2463c27d05e67ba11748630b1f817f4cbc6c5cf7224
|
7
|
+
data.tar.gz: df5c01643cd645039b5b7b51206dda6461b9c7e6312310c1538b86d5c7ed841b9738cb29d710a75abcd7f7151173459683a30b21ca8b9da8cd32d56be277d6d4
|
@@ -51,12 +51,12 @@ module Zeitwerk
|
|
51
51
|
# If the class is a singleton class, we won't do anything with it so we
|
52
52
|
# can bail out immediately. This is several orders of magnitude faster
|
53
53
|
# than accessing its name.
|
54
|
-
return if event.
|
54
|
+
return if event.singleton_class?
|
55
55
|
|
56
56
|
# Note that it makes sense to compute the hash code unconditionally,
|
57
57
|
# because the trace point is disabled if cpaths is empty.
|
58
|
-
if loader = cpaths.delete(real_mod_name(event
|
59
|
-
loader.on_namespace_loaded(event
|
58
|
+
if loader = cpaths.delete(real_mod_name(event))
|
59
|
+
loader.on_namespace_loaded(event)
|
60
60
|
disable_tracer_if_unneeded
|
61
61
|
end
|
62
62
|
end
|
data/opal/zeitwerk/loader.rb
CHANGED
@@ -153,7 +153,7 @@ module Zeitwerk
|
|
153
153
|
#
|
154
154
|
# @return [<String>]
|
155
155
|
def dirs
|
156
|
-
root_dirs.keys
|
156
|
+
root_dirs.keys
|
157
157
|
end
|
158
158
|
|
159
159
|
# Pushes `path` to the list of root directories.
|
@@ -288,6 +288,7 @@ module Zeitwerk
|
|
288
288
|
ExplicitNamespace.unregister(self)
|
289
289
|
|
290
290
|
@setup = false
|
291
|
+
@eager_loaded = false
|
291
292
|
end
|
292
293
|
|
293
294
|
# Unloads all loaded code, and calls setup again so that the loader is able
|
@@ -367,7 +368,7 @@ module Zeitwerk
|
|
367
368
|
#
|
368
369
|
# @return [<String>]
|
369
370
|
def unloadable_cpaths
|
370
|
-
to_unload.keys
|
371
|
+
to_unload.keys
|
371
372
|
end
|
372
373
|
|
373
374
|
# @private
|
@@ -401,7 +402,7 @@ module Zeitwerk
|
|
401
402
|
#
|
402
403
|
# @return [<String>]
|
403
404
|
def all_dirs
|
404
|
-
Registry.loaders.flat_map(&:dirs)
|
405
|
+
Registry.loaders.flat_map(&:dirs)
|
405
406
|
end
|
406
407
|
end
|
407
408
|
|
@@ -429,8 +430,7 @@ module Zeitwerk
|
|
429
430
|
end
|
430
431
|
rescue ::NameError => error
|
431
432
|
path_type = ruby?(abspath) ? "file" : "directory"
|
432
|
-
|
433
|
-
raise NameError, <<~MESSAGE
|
433
|
+
message = <<~MESSAGE
|
434
434
|
#{error.message} inferred by #{inflector.class} from #{path_type}
|
435
435
|
|
436
436
|
#{abspath}
|
@@ -442,6 +442,7 @@ module Zeitwerk
|
|
442
442
|
* Rename the #{path_type} to comply with the naming conventions.
|
443
443
|
* Modify the inflector to handle this case.
|
444
444
|
MESSAGE
|
445
|
+
raise NameError.new(message, error.name)
|
445
446
|
end
|
446
447
|
end
|
447
448
|
end
|
@@ -499,6 +500,17 @@ module Zeitwerk
|
|
499
500
|
# "file #{file} is ignored because #{cpath(parent, cname)} is already defined"
|
500
501
|
else
|
501
502
|
set_autoload(parent, cname, file)
|
503
|
+
if autoload_path = autoload_for?(parent, cname)
|
504
|
+
if dir?(autoload_path)
|
505
|
+
promote_namespace_from_implicit_to_explicit(
|
506
|
+
dir: autoload_path,
|
507
|
+
file: file,
|
508
|
+
parent: parent,
|
509
|
+
cname: cname
|
510
|
+
)
|
511
|
+
(lazy_subdirs[cpath(parent, cname)] ||= []) << autoload_path
|
512
|
+
end
|
513
|
+
end
|
502
514
|
end
|
503
515
|
end
|
504
516
|
|
@@ -561,14 +573,8 @@ module Zeitwerk
|
|
561
573
|
# @param parent [Module]
|
562
574
|
# @param cname [Symbol]
|
563
575
|
# @return [String, nil]
|
564
|
-
|
565
|
-
|
566
|
-
parent.autoload?(cname) if cdef?(parent, cname)
|
567
|
-
end
|
568
|
-
else
|
569
|
-
def strict_autoload_path(parent, cname)
|
570
|
-
parent.autoload?(cname, false)
|
571
|
-
end
|
576
|
+
def strict_autoload_path(parent, cname)
|
577
|
+
parent.autoload?(cname, false)
|
572
578
|
end
|
573
579
|
|
574
580
|
# This method is called this way because I prefer `preload` to be the method
|
@@ -629,7 +635,7 @@ module Zeitwerk
|
|
629
635
|
dir_first_char = dir[0]
|
630
636
|
path_start = dir.size + 1
|
631
637
|
path_parts = `[]`
|
632
|
-
basename =
|
638
|
+
basename = ''
|
633
639
|
@module_paths.each do |abspath|
|
634
640
|
%x{
|
635
641
|
if (abspath[0] === dir_first_char) {
|
@@ -13,7 +13,7 @@ module Zeitwerk::Loader::Callbacks
|
|
13
13
|
|
14
14
|
# "constant #{cpath(*cref)} loaded from file #{file}" if cdef?(*cref)
|
15
15
|
if !cdef?(*cref)
|
16
|
-
raise Zeitwerk::NameError
|
16
|
+
raise Zeitwerk::NameError.new("expected file #{file} to define constant #{cpath(*cref)}, but didn't", cref.last)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -25,11 +25,8 @@ module Zeitwerk::Loader::Callbacks
|
|
25
25
|
# @return [void]
|
26
26
|
def on_dir_autoloaded(dir)
|
27
27
|
if cref = autoloads.delete(dir)
|
28
|
-
autovivified_module =
|
29
|
-
|
30
|
-
else
|
31
|
-
cref[0].const_set(cref[1], Module.new)
|
32
|
-
end
|
28
|
+
autovivified_module = cref[0].const_set(cref[1], Module.new)
|
29
|
+
|
33
30
|
# "module #{autovivified_module.name} autovivified from directory #{dir}"
|
34
31
|
|
35
32
|
to_unload[autovivified_module.name] = [dir, cref] if reloading_enabled?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-zeitwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -52,7 +52,7 @@ licenses:
|
|
52
52
|
- MIT
|
53
53
|
metadata:
|
54
54
|
github_repo: ssh://github.com/isomorfeus/gems
|
55
|
-
post_install_message: "\nopal-zeitwerk 0.0
|
55
|
+
post_install_message: "\nopal-zeitwerk 0.1.0:\n \n opal-zeitwerk currently requires
|
56
56
|
the es6_modules_1_1 branch of opal, for the Gemfile:\n\n gem 'opal', github: 'janbiedermann/opal',
|
57
57
|
branch: 'es6_modules_1_1'\n\n"
|
58
58
|
rdoc_options: []
|