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

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Extracts plus: payload arrays from Mutant unified-diff format. Skips the "--- ", "+++ ", 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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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