Class: SimpleCovMcp::Commands::RawCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/simplecov_mcp/commands/raw_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
# File 'lib/simplecov_mcp/commands/raw_command.rb', line 10

def execute(args)
  handle_with_path(args, 'raw') do |path|
    presenter = Presenters::CoverageRawPresenter.new(model: model, path: path)
    data = presenter.absolute_payload
    break if maybe_output_structured_format?(data, model)

    relative_path = presenter.relative_path
    puts "File: #{relative_path}"
    puts

    # Table format for raw coverage data
    headers = ['Line', 'Coverage']
    rows = data['lines'].each_with_index.map do |coverage, index|
      [
        (index + 1).to_s,
        coverage.nil? ? 'nil' : coverage.to_s
      ]
    end

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