Class: Evilution::Compare::DiffExtractor::Mutant

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/compare/diff_extractor/mutant.rb

Overview

Extracts plus: payload arrays from Mutant unified-diff format. Skips the “— <name>”, “+++ <name>”, and “@@ … @@” header lines and returns each remaining payload line with its single leading “-” or “+” marker stripped.

Header detection requires a trailing space after “—”/“+++” so that a payload line whose mutated source starts with “–” (emitted as “—var”) or “++” (emitted as “+++var”) is preserved rather than misclassified as a header.

Instance Method Summary collapse

Instance Method Details

#call(diff) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/evilution/compare/diff_extractor/mutant.rb', line 15

def call(diff)
  minus = []
  plus = []
  diff.to_s.each_line do |line|
    line = line.chomp
    next if line.start_with?("--- ", "+++ ", "@@")

    if line.start_with?("-")
      minus << line[1..]
    elsif line.start_with?("+")
      plus << line[1..]
    end
  end
  { minus: minus, plus: plus }
end