Class: RailsAiContext::Introspectors::ViewTemplateIntrospector
- Inherits:
-
Object
- Object
- RailsAiContext::Introspectors::ViewTemplateIntrospector
- Extended by:
- StaticTier
- Defined in:
- lib/rails_ai_context/introspectors/view_template_introspector.rb
Overview
Reads actual view template contents and extracts metadata: partial references, Stimulus controller usage, line counts. Separate from ViewIntrospector which focuses on structural discovery.
Every extractor here is regex by design. The same matcher runs over ERB,
HAML, Slim and Phlex .rb views, and only the last of those has a Ruby
AST. Splitting the Phlex path onto listeners would mean two definitions
of "what a partial reference is" that could drift apart.
Constant Summary
Constants included from StaticTier
StaticTier::ALTERNATE_SOURCE, StaticTier::FILES_ONLY, StaticTier::KINDS, StaticTier::RUNTIME_ONLY
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(app) ⇒ ViewTemplateIntrospector
constructor
A new instance of ViewTemplateIntrospector.
Methods included from StaticTier
answers_statically?, static_tier, static_tier_declared?, unavailable_reason, validate_static_tier!
Constructor Details
#initialize(app) ⇒ ViewTemplateIntrospector
Returns a new instance of ViewTemplateIntrospector.
19 20 21 |
# File 'lib/rails_ai_context/introspectors/view_template_introspector.rb', line 19 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
17 18 19 |
# File 'lib/rails_ai_context/introspectors/view_template_introspector.rb', line 17 def app @app end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_ai_context/introspectors/view_template_introspector.rb', line 23 def call views_dir = File.join(app.root.to_s, "app", "views") return { templates: {}, partials: {} } unless Dir.exist?(views_dir) { templates: scan_templates(views_dir), partials: scan_partials(views_dir) } rescue => e { error: e. } end |