Class: EdifactConverter::Comparator

Inherits:
Object
  • Object
show all
Defined in:
lib/edifact_converter/comparator.rb

Instance Method Summary collapse

Constructor Details

#initializeComparator

Returns a new instance of Comparator.



9
10
11
# File 'lib/edifact_converter/comparator.rb', line 9

def initialize
  self.errors = []
end

Instance Method Details

#compare_docs(source, result, &proc) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/edifact_converter/comparator.rb', line 13

def compare_docs(source, result, &proc)
  source = source.dup
  result = result.dup
  self.error_proc = proc || Proc.new { |n| :errors << n }
  if source.root.name == result.root.name
    order_s12_ftxs(source)
    order_s12_ftxs(result)
    verify_texts(source, result)
    compare_children source.root, result.root
  else
    error_proc.call(
      Difference.new(
        source: source.root,
        facit: result.root,
        kind: :root,
        type: only_warn ? :warnings : :errors
      )
    )
  end
  errors
end