Class: RailsAiBridge::Tools::GetView::StandardFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- RailsAiBridge::Tools::GetView::StandardFormatter
- Defined in:
- lib/rails_ai_bridge/tools/get_view/standard_formatter.rb
Overview
Formats a standard list of templates and partials.
Instance Method Summary collapse
-
#call ⇒ String
The formatted standard output.
Methods inherited from BaseFormatter
Constructor Details
This class inherits a constructor from RailsAiBridge::Tools::GetView::BaseFormatter
Instance Method Details
#call ⇒ String
Returns The formatted standard output.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rails_ai_bridge/tools/get_view/standard_formatter.rb', line 9 def call filtered = filter_view_data return "View introspection failed: #{filtered[:error]}" if filtered[:error] lines = [heading, ''] lines << "- Layouts: #{filtered[:layouts].join(', ')}" if filtered[:layouts].any? lines << "- Template engines: #{filtered[:template_engines].join(', ')}" if filtered[:template_engines].any? if filtered[:templates].any? && !(@partial.present? && @controller.blank?) lines << '' << '## Templates by controller' filtered[:templates].keys.sort.each do |name| lines << "- `#{name}/`: #{filtered[:templates][name].join(', ')}" end end if filtered[:shared_partials].any? lines << '' << '## Shared Partials' filtered[:shared_partials].each { |name| lines << "- `#{name}`" } end if filtered[:controller_partials].any? lines << '' << '## Controller Partials' filtered[:controller_partials].keys.sort.each do |name| lines << "- `#{name}/`: #{filtered[:controller_partials][name].join(', ')}" end end lines.join("\n") end |