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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fed32b704fbb88b1f720e1aafae81f3506c822e6b09f5c957e14ecd37b0babc4
4
- data.tar.gz: e61778d14005fbcb78a34572d1deec98e215b2268237b4ee172adb160f80dab0
3
+ metadata.gz: bcdfaf9dcb7b659b3a5020ffbec2f27b96b3d73f7bc463b21231fcdd4fde6c9d
4
+ data.tar.gz: 8a22d7cbba16b3293b389b9737e8c8aa4b21bea872d5a4ee09d02a97d896569e
5
5
  SHA512:
6
- metadata.gz: ba9344fea803705ec42432f0036feb6617bad8c38b6d20722d38c647febde9d7438cf9432a695d84987c2458344ad12d175e78fd1f34c2d008df2360b660cf52
7
- data.tar.gz: 072b525018aade519119370d651191f8fa206f82583d80528532ee547c3c793d873590a339da0adaad321eaa85dce4ff4f72a71115544c7afa50cf40dd8164d6
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
@@ -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}); continuing with models loaded so far. " \
41
- "If this points at lib/, consider config.autoload_lib(ignore: %w[assets tasks generators])."
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telm
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siddharth Arun