Compare two versions of a text file and find additions/removals with Ruby? [duplicate]
I am tracking changes in a web-page using Ruby. After I removed all html tags and blank lines, I get an array of lines which needs to be checked for additions/removals assuming that there may be repetitions. Could you recommend a good gem if it has been done already?
I could make the array lines unique and then the problem is a开发者_如何学运维voided. But what if I need to track the repeated lines as well with respect to their position in the text?
Sounds like a textbook case of where you'd want to use the Diff algorithm.
There's a 'diff' gem, although to be fair I've never used it: http://rubygems.org/gems/diff
精彩评论