Class: RailsAiBridge::Introspectors::ViewIntrospector

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/introspectors/view_introspector.rb

Overview

Scans view layer: layouts, templates, partials, helpers, view components, and template engine detection.

Constant Summary collapse

PROVENANCE =

Evidence origin of each listing. Files found on disk are observed live, helper methods are scanned with a regex, and template engines are inferred from file extensions.

{
  layouts: :live,
  templates: :live,
  partials: :live,
  helpers: :regex,
  view_components: :live,
  template_engines: :heuristic
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ViewIntrospector

Initializes the view introspector and path resolver.

Parameters:

  • app (Rails::Application) —

    host Rails application



95
96
97
98
# File 'lib/rails_ai_bridge/introspectors/view_introspector.rb', line 95

def initialize(app)
  @app = app
  @path_resolver = PathResolver.new(app)
end

Instance Attribute Details

#app ⇒ Object (readonly)

Returns the value of attribute app.



19
20
21
# File 'lib/rails_ai_bridge/introspectors/view_introspector.rb', line 19

def app
  @app
end

Instance Method Details

#call ⇒ Hash

Builds a read-only summary of layouts, templates, partials, helpers, components, and template engines discovered through configured Rails paths.

Returns:

  • (Hash) —

    view-layer metadata with a :provenance map per listing, or an :error key when detection fails



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/rails_ai_bridge/introspectors/view_introspector.rb', line 105

def call
  {
    layouts: extract_layouts,
    templates: extract_templates,
    partials: extract_partials,
    helpers: extract_helpers,
    view_components: extract_view_components,
    template_engines: detect_template_engines,
    provenance: PROVENANCE
  }
rescue StandardError => error
  { error: error.message }
end