Class: RailsAiBridge::Tools::GetView::FullFormatter

Inherits:
BaseFormatter
  • Object
show all
Defined in:
lib/rails_ai_bridge/tools/get_view/full_formatter.rb

Overview

Formats full view details including templates, partials, helpers, and components.

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize

Constructor Details

This class inherits a constructor from RailsAiBridge::Tools::GetView::BaseFormatter

Instance Method Details

#callString

Returns The formatted full output.

Returns:

  • (String)

    The formatted full output.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_ai_bridge/tools/get_view/full_formatter.rb', line 9

def call
  filtered = filter_view_data
  return "View introspection failed: #{filtered[:error]}" if filtered[:error]

  lines = [StandardFormatter.new(context: @context, controller: @controller, partial: @partial).call]

  if filtered[:helpers].any?
    lines << '' << '## Helpers'
    filtered[:helpers].each do |helper|
      methods = Array(helper[:methods]).join(', ')
      lines << "- `#{helper[:file]}`: #{methods}"
    end
  end

  if filtered[:view_components].any?
    lines << '' << '## View Components'
    filtered[:view_components].each { |component| lines << "- `#{component}`" }
  end

  lines.join("\n")
end