Class: SimpleCovMcp::Commands::SummaryCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/simplecov_mcp/commands/summary_command.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#cli, #config, #source_formatter

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from SimpleCovMcp::Commands::BaseCommand

Instance Method Details

#execute(args) ⇒ Object



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
38
# File 'lib/simplecov_mcp/commands/summary_command.rb', line 10

def execute(args)
  handle_with_path(args, 'summary') do |path|
    presenter = Presenters::CoverageSummaryPresenter.new(model: model, path: path)
    data = presenter.absolute_payload
    break if emit_structured_format_with_optional_source?(data, model, path)

    relative_path = presenter.relative_path
    summary = data['summary']

    # Table format with box-drawing
    headers = ['File', '%', 'Covered', 'Total', 'Stale']
    stale_marker = data['stale'] ? 'Yes' : ''
    rows = [[
      relative_path,
      format('%.2f%%', summary['percentage']),
      summary['covered'].to_s,
      summary['total'].to_s,
      stale_marker
    ]]

    puts TableFormatter.format(
      headers: headers,
      rows: rows,
      alignments: [:left, :right, :right, :right, :center]
    )
    puts
    print_source_for(model, path) if config.source_mode
  end
end