Class: SimpleCovMcp::Commands::DetailedCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/simplecov_mcp/commands/detailed_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



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
# File 'lib/simplecov_mcp/commands/detailed_command.rb', line 11

def execute(args)
  handle_with_path(args, 'detailed') do |path|
    presenter = Presenters::CoverageDetailedPresenter.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
    puts "File: #{relative_path}"
    puts

    # Table format with box-drawing
    headers = ['Line', 'Hits', 'Covered']
    rows = data['lines'].map do |r|
      [r['line'].to_s, r['hits'].to_s, r['covered'] ? 'yes' : 'no']
    end

    puts TableFormatter.format(
      headers: headers,
      rows: rows,
      alignments: [:right, :right, :center]
    )

    print_source_for(model, path) if config.source_mode
  end
end