Class: SimpleCov::Combine::CoverageAccumulator::MergedFile
- Inherits:
-
Object
- Object
- SimpleCov::Combine::CoverageAccumulator::MergedFile
- Defined in:
- lib/simplecov/combine/coverage_accumulator.rb
Overview
One file's accumulated coverage.
A criterion is carried for this file when the data carries it, not when
this process happens to measure it: simplecov merge never ran
SimpleCov.start at all, and dropping a table it did not ask for would
lose branch data the producers did measure. A nil table means nobody
measured that criterion, an empty one means it was measured and the
file has none.
Instance Method Summary collapse
- #absorb(coverage) ⇒ Object
-
#initialize(coverage, branches:, methods:) ⇒ MergedFile
constructor
A new instance of MergedFile.
- #to_h ⇒ Object
Constructor Details
#initialize(coverage, branches:, methods:) ⇒ MergedFile
Returns a new instance of MergedFile.
92 93 94 95 96 97 98 99 |
# File 'lib/simplecov/combine/coverage_accumulator.rb', line 92 def initialize(coverage, branches:, methods:) @branch_coverage = branches @method_coverage = methods @lines = LinesCombiner.merge_into(nil, coverage["lines"]) branches_table = coverage["branches"] @branches = BranchesCombiner.absorb(new_table, branches_table) if branches || branches_table @methods = MethodsCombiner.absorb(nil, coverage["methods"]) end |
Instance Method Details
#absorb(coverage) ⇒ Object
101 102 103 104 105 |
# File 'lib/simplecov/combine/coverage_accumulator.rb', line 101 def absorb(coverage) reconcile_synthesized(coverage) @lines = LinesCombiner.merge_into(@lines, coverage["lines"]) self end |
#to_h ⇒ Object
107 108 109 110 111 112 |
# File 'lib/simplecov/combine/coverage_accumulator.rb', line 107 def to_h merged = {"lines" => @lines} #: Hash[String, untyped] merged["branches"] = BranchesCombiner.materialize(@branches) if @branches merged["methods"] = MethodsCombiner.materialize(@methods) if @methods merged end |