Class: SimpleCov::SourceFile::BranchBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/source_file/branch_builder.rb

Overview

Builds the ‘SourceFile::Branch` objects for a source file from the raw branch data Ruby’s Coverage library reports. Applies the ‘ignore_branches :eval_generated` / `:implicit_else` filters and marks branches inside `# simplecov:disable` / `# :nocov:` chunks as skipped.

Instance Method Summary collapse

Constructor Details

#initialize(source_file) ⇒ BranchBuilder

Returns a new instance of BranchBuilder.



11
12
13
# File 'lib/simplecov/source_file/branch_builder.rb', line 11

def initialize(source_file)
  @source_file = source_file
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/simplecov/source_file/branch_builder.rb', line 15

def call
  coverage_branch_data = @source_file.coverage_data["branches"] || {}
  branches = coverage_branch_data.flat_map do |condition, coverage_branches|
    next [] if eval_generated_condition_to_ignore?(condition)

    build_branches_from(condition, coverage_branches)
  end

  process_skipped(branches)
end