samg / diffy

Easy Diffing in Ruby
http://rubygems.org/gems/diffy
MIT License
1.27k stars 104 forks source link

Ignore 'No newline at end of file' warning message when comparing text strings #88

Open harmanbirdi opened 7 years ago

harmanbirdi commented 7 years ago

It does not make any sense for that message to show up on comparison of two strings. I have not seen the code, but seems like you are taking two strings, putting them in two files and comparing them. Could you provide an option to suppress that warning.

It would be nice to not be able to see that warning especially when comparing a lot of strings.

dannolan commented 7 years ago

It would be extremely great to have this btw

samg commented 7 years ago

I probably can't find time to work on this but would be happy to review/accept a PR for it.

On Wed, Sep 27, 2017 at 4:32 PM Dan Nolan notifications@github.com wrote:

It would be extremely great to have this btw

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/samg/diffy/issues/88#issuecomment-332684604, or mute the thread https://github.com/notifications/unsubscribe-auth/AABWhJSsswsLJDfA6Q2bIF0zgUoFRYF8ks5smtr_gaJpZM4OQRp6 .

bmaca commented 6 years ago

I agree. This would be nice to have

DannyBen commented 5 years ago

I also came here to look for a way to remove this warning, but since I see this is a long-running open issue, and since it seems to be the accepted behavior for the underlying diff command, I figured "if you can't beat them, join them". I am simply adding a newline to both compared strings before comparing:

def diff
  @diff ||= Diffy::Diff.new("#{expected}\n", "#{actual}\n", context: 2).to_s :color
end