Class: Testprune::UI::ReportRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/testprune/ui/report_renderer.rb

Overview

Styled replacement for Report#render_text. Renders the analysis result as a rich, color-coded terminal report using lipgloss. Degrades to plain text when NO_COLOR=1 is set or when output is not a TTY (lipgloss handles this automatically).

Constant Summary collapse

GROUP_LABELS =
{
  identical:  'identical',
  subset:     'subset',
  structural: 'structural',
  overlap:    'overlap'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ ReportRenderer

Returns a new instance of ReportRenderer.



18
19
20
# File 'lib/testprune/ui/report_renderer.rb', line 18

def initialize(result)
  @result = result
end

Instance Method Details

#renderObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/testprune/ui/report_renderer.rb', line 22

def render
  parts = []
  parts << header_section
  parts << ''

  if @result.candidates.empty?
    parts << nothing_found_section
  else
    parts << confidence_section(:high,   'HIGH confidence — safe to remove',    Styles::HIGH_BADGE,   '')
    parts << confidence_section(:medium, 'MEDIUM confidence — review',           Styles::MEDIUM_BADGE, '')
    parts << confidence_section(:low,    'LOW confidence — review',              Styles::LOW_BADGE,    '')
    parts << savings_section unless @result.approved_removals.empty?
    parts << ''
    parts << cta_line
  end

  parts.compact.join("\n")
end