Module: ActiveMutator::BaselineHooks
- Defined in:
- lib/active_mutator/baseline_hooks.rb
Constant Summary collapse
- RECORDS =
{}
- TIMES =
{}
Class Method Summary collapse
Class Method Details
.build_payload(records, times) ⇒ Object
35 36 37 |
# File 'lib/active_mutator/baseline_hooks.rb', line 35 def self.build_payload(records, times) { "version" => 2, "records" => records, "times" => times } end |
.diff_coverage(before, after, root) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/active_mutator/baseline_hooks.rb', line 12 def self.diff_coverage(before, after, root) hits = [] after.each do |path, data| next unless path.start_with?(root) # Relative to root, not a global substring check: `root` itself may # contain "/spec/" (e.g. a fixture nested under this gem's own # spec/fixtures/ tree), which would otherwise falsely exclude every # file under it. relative = path.delete_prefix(root) next if relative.start_with?("/spec/") before_lines = before.dig(path, :lines) data[:lines].each_with_index do |count, idx| next if count.nil? previous = before_lines ? before_lines[idx].to_i : 0 hits << [path, idx + 1] if count > previous end end hits end |