Class: Similatron::ComparisonEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/similatron/comparison_engine.rb

Defined Under Namespace

Classes: Open3Result

Instance Method Summary collapse

Constructor Details

#initialize(executable_path: nil, diffs_path:) ⇒ ComparisonEngine

Returns a new instance of ComparisonEngine.



3
4
5
6
# File 'lib/similatron/comparison_engine.rb', line 3

def initialize(executable_path: nil, diffs_path:)
  @given_executable_path = executable_path
  @diffs_path = diffs_path
end

Instance Method Details

#compare(expected:, actual:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/similatron/comparison_engine.rb', line 8

def compare(expected:, actual:)
  increase_diff_index

  command = command(expected, actual, diff_path)

  exec_result = run(command)

  Comparison.new(
    expected: expected,
    actual: actual,
    score: score(exec_result),
    diff: diff(exec_result)
  )
end