ruby difference engine

懵懂的女人 提交于 2019-12-19 11:57:29

问题


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:

  1. String1
  2. String2
  3. String3

2nd set:

  1. String1
  2. String3
  3. 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 one before going further with this differ.


回答1:


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.



来源:https://stackoverflow.com/questions/3818959/ruby-difference-engine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!