Module: SimpleCov::Combine::MethodsCombiner
- Extended by:
- MethodsCombiner
- Included in:
- MethodsCombiner
- Defined in:
- lib/simplecov/combine/methods_combiner.rb
Instance Method Summary collapse
-
#absorb(target, coverage) ⇒ Object
A
niltargetstaysniluntil some resultset actually carries methods, so a merge can tell "no method data anywhere" apart from "method data that covers nothing". -
#combine(coverage_a, coverage_b) ⇒ Object
Method coverage maps
[class, name, start_line, start_col, end_line, end_col]keys to hit counts. - #identities ⇒ Object
- #materialize(target) ⇒ Object
- #source_identity(key) ⇒ Object
Instance Method Details
#absorb(target, coverage) ⇒ Object
A nil target stays nil until some resultset actually carries
methods, so a merge can tell "no method data anywhere" apart from "method
data that covers nothing".
27 28 29 30 31 32 |
# File 'lib/simplecov/combine/methods_combiner.rb', line 27 def absorb(target, coverage) return target unless coverage target ||= {} #: Hash[untyped, [untyped, Integer]] InternedCounts.absorb_counts(target, coverage, identities) end |
#combine(coverage_a, coverage_b) ⇒ Object
Method coverage maps [class, name, start_line, start_col, end_line, end_col] keys to hit counts. Keys are matched on their source identity,
the location alone, because Ruby records one entry per defined method: the
same define_method block defined onto different classes, or under
different names, in different processes arrives with different receivers
for the same source method, and matching on the full key would keep both,
letting a never-called copy's 0 shadow a covered method (#1234).
19 20 21 22 |
# File 'lib/simplecov/combine/methods_combiner.rb', line 19 def combine(coverage_a, coverage_b) merged = absorb({}, coverage_a) #: Hash[untyped, [untyped, Integer]] materialize(absorb(merged, coverage_b)) end |
#identities ⇒ Object
38 39 40 |
# File 'lib/simplecov/combine/methods_combiner.rb', line 38 def identities @identities ||= IdentityInterner.build { |key| source_identity(key) } end |
#materialize(target) ⇒ Object
34 35 36 |
# File 'lib/simplecov/combine/methods_combiner.rb', line 34 def materialize(target) target.values.to_h end |
#source_identity(key) ⇒ Object
42 43 44 45 |
# File 'lib/simplecov/combine/methods_combiner.rb', line 42 def source_identity(key) _class_name, _method_name, *location = SourceFile::RubyDataParser.call(key) location.freeze end |