Class: RailsAiBridge::Tools::GetView::SpecificViewFormatter

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

Overview

Formats a detailed analysis of a specific view file.

Instance Method Summary collapse

Instance Method Details

#call(analysis) ⇒ String

Returns The formatted specific view output.

Parameters:

  • analysis (Hash)

    The detailed analysis of the view file.

Returns:

  • (String)

    The formatted specific view output.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails_ai_bridge/tools/get_view/specific_view_formatter.rb', line 10

def call(analysis)
  lines = ["# View: #{analysis[:path]}", '']
  lines << "- Template engine: #{analysis[:template_engine]}" if analysis[:template_engine]
  lines << "- Partial: #{analysis[:partial] ? 'yes' : 'no'}"
  lines << "- Renders: #{analysis[:renders].join(', ')}" if analysis[:renders].any?
  lines << "- Turbo frames: #{analysis[:turbo_frames].join(', ')}" if analysis[:turbo_frames].any?
  lines << "- Stimulus controllers: #{analysis[:stimulus_controllers].join(', ')}" if analysis[:stimulus_controllers].any?
  lines << "- Stimulus actions: #{analysis[:stimulus_actions].join(', ')}" if analysis[:stimulus_actions].any?
  lines << ''
  lines << '## Source'
  lines << '```erb'
  lines << analysis[:content].rstrip
  lines << '```'
  lines.join("\n")
end