Class: Evilution::Compare::Fingerprint Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/compare/fingerprint.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.

Composes a stable SHA256 fingerprint from a mutation diff for cross-tool matching (Evilution vs Mutant). Orchestrates two collaborators along distinct change axes:

- extractor: parses a tool-specific diff format into {minus:, plus:}
- normalizer: collapses whitespace per line so cosmetic differences
            don't perturb the hash

Instance Method Summary collapse

Constructor Details

#initialize(extractor:, normalizer:) ⇒ Fingerprint

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.

Returns a new instance of Fingerprint.



14
15
16
17
# File 'lib/evilution/compare/fingerprint.rb', line 14

def initialize(extractor:, normalizer:)
  @extractor = extractor
  @normalizer = normalizer
end

Instance Method Details

#call(diff:, file_path:, line:) ⇒ 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.



19
20
21
22
23
24
25
# File 'lib/evilution/compare/fingerprint.rb', line 19

def call(diff:, file_path:, line:)
  body = @extractor.call(diff)
  minus = body[:minus].map { |l| @normalizer.call(l) }
  plus  = body[:plus].map  { |l| @normalizer.call(l) }
  payload = [file_path, line.to_s, minus.join("\n"), plus.join("\n")].join("\x00")
  Digest::SHA256.hexdigest(payload)
end