telm 0.1.3 → 0.1.4
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 +9 -0
- data/lib/telm/core/schema.rb +30 -2
- data/lib/telm/version.rb +1 -1
- 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: bcdfaf9dcb7b659b3a5020ffbec2f27b96b3d73f7bc463b21231fcdd4fde6c9d
|
|
4
|
+
data.tar.gz: 8a22d7cbba16b3293b389b9737e8c8aa4b21bea872d5a4ee09d02a97d896569e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a0178addcefe14ca4e98102089ff6415c3d4b13446ea440f1a658bbc97652267e537dc3989dd5ac2058fb12a10eb482bcd859b84e09ffe3cc6522746b6628df
|
|
7
|
+
data.tar.gz: 9806e01020e3b7412e071baa438ccc6f019ac1d0838132ddf1ed5e82784208b603a685deba221eee6945a2680d596a4d620ac03dea6f67bf211e8b27845c6d80
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.4] - 2026-07-04
|
|
4
|
+
|
|
5
|
+
- Fix: the console could show "No browsable tables" in development when the
|
|
6
|
+
host's full eager load failed partway (e.g. autoload_lib + lib/generators)
|
|
7
|
+
before app/models was reached. telm now eager loads every app/models
|
|
8
|
+
directory (app + engines) directly via Zeitwerk's eager_load_dir first;
|
|
9
|
+
the full eager load is a best-effort follow-up for models living
|
|
10
|
+
elsewhere.
|
|
11
|
+
|
|
3
12
|
## [0.1.3] - 2026-07-04
|
|
4
13
|
|
|
5
14
|
- Fix: visiting the console 500ed ("uninitialized constant
|
data/lib/telm/core/schema.rb
CHANGED
|
@@ -28,6 +28,15 @@ module Telm
|
|
|
28
28
|
return unless defined?(Rails) && Rails.respond_to?(:application) && Rails.application
|
|
29
29
|
return if Rails.application.config.eager_load # already loaded at boot
|
|
30
30
|
|
|
31
|
+
# Models are what introspection needs, so load them directly and
|
|
32
|
+
# first — a host whose lib/ or app/misc fails to eager load must
|
|
33
|
+
# not cost us the schema.
|
|
34
|
+
eager_load_model_dirs!
|
|
35
|
+
full_eager_load!
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Best-effort pass for models living outside app/models.
|
|
39
|
+
def full_eager_load!
|
|
31
40
|
# Host apps with config.autoload_lib often have lib/generators/**
|
|
32
41
|
# files that reference Rails::Generators without requiring it —
|
|
33
42
|
# `rails g` normally loads it first. We're about to eager load them
|
|
@@ -37,11 +46,30 @@ module Telm
|
|
|
37
46
|
Rails.application.eager_load!
|
|
38
47
|
rescue StandardError => e
|
|
39
48
|
log_warning(
|
|
40
|
-
"eager load failed (#{e.class}: #{e.message});
|
|
41
|
-
"If this points at lib/, consider
|
|
49
|
+
"full eager load failed (#{e.class}: #{e.message}); model directories were loaded " \
|
|
50
|
+
"directly, so the schema is intact. If this points at lib/, consider " \
|
|
51
|
+
"config.autoload_lib(ignore: %w[assets tasks generators])."
|
|
42
52
|
)
|
|
43
53
|
end
|
|
44
54
|
|
|
55
|
+
def eager_load_model_dirs!
|
|
56
|
+
loader = Rails.autoloaders.main
|
|
57
|
+
return unless loader.respond_to?(:eager_load_dir) # zeitwerk >= 2.6.2
|
|
58
|
+
|
|
59
|
+
model_dirs.each do |dir|
|
|
60
|
+
loader.eager_load_dir(dir)
|
|
61
|
+
rescue StandardError => e
|
|
62
|
+
log_warning("could not eager load #{dir}: #{e.class}: #{e.message}")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def model_dirs
|
|
67
|
+
railties = [Rails.application, *Rails.application.railties]
|
|
68
|
+
railties.select { |railtie| railtie.respond_to?(:paths) }
|
|
69
|
+
.flat_map { |railtie| railtie.paths["app/models"]&.existent || [] }
|
|
70
|
+
.uniq
|
|
71
|
+
end
|
|
72
|
+
|
|
45
73
|
# One broken model must never take down the console: any error during
|
|
46
74
|
# introspection excludes that model, logged, and the walk continues.
|
|
47
75
|
def resource_for(model, excluded)
|
data/lib/telm/version.rb
CHANGED