Class: SimcovAiFormatter::SuiteMerger

Inherits:
Object
  • Object
show all
Defined in:
lib/simcov_ai_formatter/suite_merger.rb

Overview

Merges multiple suites in a resultset into a single coverage Hash, or selects one when –suite NAME is given.

Line merge rules per (file, index):

- one nil and one Integer → take the Integer
- both Integer            → take max(hit)
- both nil                → nil

Branches: hit counts are summed for matching keys; missing keys are added.

Instance Method Summary collapse

Constructor Details

#initialize(resultset, suite: nil) ⇒ SuiteMerger

Returns a new instance of SuiteMerger.



11
12
13
14
# File 'lib/simcov_ai_formatter/suite_merger.rb', line 11

def initialize(resultset, suite: nil)
  @resultset = resultset
  @suite = suite
end

Instance Method Details

#selectArray(String, Hash)

Returns the selected suite label and the merged coverage hash.

Returns:

  • (Array(String, Hash))

    the selected suite label and the merged coverage hash



17
18
19
20
21
# File 'lib/simcov_ai_formatter/suite_merger.rb', line 17

def select
  return select_specified_suite if @suite
  return select_sole_suite if @resultset.size == 1
  select_merged_suites
end