Class: Lookout::Equality::String

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

Instance Method Summary collapse

Methods inherited from Object

#equal?, #message

Instance Method Details

#diff(expected, actual) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/lookout/equality.rb', line 78

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