Module: Polyrun::Coverage::ExampleDiff::Snapshot
- Defined in:
- lib/polyrun/coverage/example_diff_snapshot.rb
Overview
Sparse line-hit snapshots for per-example diff storage.
Class Method Summary collapse
- .dense_hits_map(lines) ⇒ Object
- .hits_map(entry) ⇒ Object
- .snapshot_line_value(value) ⇒ Object
- .sparse_snapshot_lines(lines) ⇒ Object
Class Method Details
.dense_hits_map(lines) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/polyrun/coverage/example_diff_snapshot.rb', line 22 def dense_hits_map(lines) hits = {} lines.each_with_index do |value, index| stored = snapshot_line_value(value) hits[index] = stored unless stored.nil? end hits end |
.hits_map(entry) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/polyrun/coverage/example_diff_snapshot.rb', line 12 def hits_map(entry) return {} if entry.nil? if entry.is_a?(Hash) && entry["sparse"] entry["hits"] || {} else dense_hits_map(ExampleDiff.line_array(entry)) end end |
.snapshot_line_value(value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/polyrun/coverage/example_diff_snapshot.rb', line 31 def snapshot_line_value(value) case value when nil then nil when "ignored" then "ignored" when Integer then value else parsed = Integer(value, exception: false) parsed.nil? ? value : parsed end end |
.sparse_snapshot_lines(lines) ⇒ Object
8 9 10 |
# File 'lib/polyrun/coverage/example_diff_snapshot.rb', line 8 def sparse_snapshot_lines(lines) {"sparse" => true, "hits" => dense_hits_map(lines)} end |