Class: Lookout::Equalities::String

Inherits:
Object show all
Defined in:
lib/lookout/equalities/string.rb

Direct Known Subclasses

Warning

Instance Method Summary collapse

Methods inherited from Object

#equal?, #message

Instance Method Details

#diff(expected, actual) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/lookout/equalities/string.rb', line 6

def diff(expected, actual)
  return unless String === actual
  (expected.include? "\n" or actual.include? "\n") ?
   Lookout::Diff::Formats::Unified.
     new(Lookout::Diff::Groups.
           new(Lookout::Diff::Operations.
                 new(Lookout::Diff::Algorithms::Difflib.
                       new(actual.split("\n"),
                           expected.split("\n"))))).to_a.join("\n") :
   Lookout::Diff::Formats::Inline.
     new(Lookout::Diff::Operations.
           new(Lookout::Diff::Algorithms::Difflib.new(actual, expected))).to_s
end