Class: SimpleCovMcp::Commands::UncoveredCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/simplecov_mcp/commands/uncovered_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
39
40
41
42
# File 'lib/simplecov_mcp/commands/uncovered_command.rb', line 10

def execute(args)
  handle_with_path(args, 'uncovered') do |path|
    presenter = Presenters::CoverageUncoveredPresenter.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']

    puts "File: #{relative_path}"
    puts "Coverage: #{format('%.2f%%', summary['percentage'])} " \
         "(#{summary['covered']}/#{summary['total']} lines)"
    puts

    # Table format for uncovered lines
    uncovered_lines = data['uncovered']
    if uncovered_lines.empty?
      puts 'All lines covered!'
    else
      headers = ['Line']
      rows = uncovered_lines.map { |line| [line.to_s] }

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

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