Class: SimpleCov::Formatter::AIFormatter::MarkdownBuilder::DeficitCompiler

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
SnippetFormatter
Defined in:
lib/simplecov-ai/markdown_builder/deficit_compiler.rb

Overview

Iterates through files with coverage deficits and coordinates their AST parsing and snippet generation.

Instance Method Summary collapse

Methods included from SnippetFormatter

#calculate_occurrence, #count_snippet_occurrences, #fetch_snippet_text, #truncate_snippet

Constructor Details

#initialize(result, config, builder) ⇒ DeficitCompiler

Returns a new instance of DeficitCompiler.



14
15
16
17
18
# File 'lib/simplecov-ai/markdown_builder/deficit_compiler.rb', line 14

def initialize(result, config, builder)
  @result = result
  @config = config
  @builder = builder
end

Instance Method Details

#write_deficits(buffer) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/simplecov-ai/markdown_builder/deficit_compiler.rb', line 21

def write_deficits(buffer)
  files = T.let(
    @result.files.reject { |f| f.covered_percent >= 100.0 }.sort_by { |f| [f.covered_percent, f.filename] },
    T::Array[SimpleCov::SourceFile]
  )
  return if files.empty?

  buffer.puts "## Coverage Deficits\n\n"
  files.each do |file|
    break if @builder.truncate_if_needed?

    process_file(buffer, file)
  end
end