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, applying the ignore_branches filters and marking branches inside disabled chunks as skipped.

Instance Method Summary collapse

Constructor Details

#initialize(source_file) ⇒ BranchBuilder

Returns a new instance of BranchBuilder.



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

def initialize(source_file)
  @source_file = source_file
end

Instance Method Details

#callObject



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

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