ruby difference engine
Looking for a Ruby differencing engine. So you can do some of the same things meld viewer does.
For example you have this first set of code per line:
- String1
- String2
- String3
2nd set:
- String1
- String3
- String4
The diff would come out to show lines 2 and 3 are different.
I already am using this one: http://github.com/pvande/differ, but it's definitely not perfect but pretty good. I would like to add on to it, however I'm trying to find some knowledge on another开发者_StackOverflow中文版 one before going further with this differ.
The "standard" solution is Austin Ziegler's diff-lcs
library, which – as the name implies – implements a longest common subsequence algorithm. More precisely, the LCS algorithm by McIlroy and Hunt. This library is a port of Mario I. Wolczko's Smalltalk implementation of the McIlroy-Hunt algorithm from 1993 as well es the Algorithm::Diff
Perl library.
Unfortunately, there hasn't been a release since 2004. Which wouldn't be that bad, since the McIlroy-Hunt algorithm hasn't changed since 1976, but String
handling in Ruby has changed significantly in Ruby 1.9.
精彩评论