Diff::LCS

Description

Diff::LCS computes the difference between two Enumerable sequences using
the McIlroy-Hunt longest common subsequence (LCS) algorithm. It includes
utilities to create a simple HTML diff output format and a standard
diff-like tool.

This is release 1.2.4, fixing a bug introduced after diff-lcs 1.1.3 that
did not properly prune common sequences at the beginning of a comparison
set. Thanks to Paul Kunysch for fixing this issue.

Coincident with the release of diff-lcs 1.2.3, we reported an issue with
Rubinius in 1.9 mode (rubinius/rubinius#2268).
We are happy to report that this issue has been resolved.

Synopsis

Using this module is quite simple. By default, Diff::LCS does not extend
objects with the Diff::LCS interface, but will be called as if it were a
function:

By requiring 'diff/lcs/array' or 'diff/lcs/string', Array
or String will be extended for use this way.

Note that Diff::LCS requires a sequenced enumerable container, which means
that the order of enumeration is both predictable and consistent for the
same set of data. While it is theoretically possible to generate a diff for
an unordered hash, it will only be meaningful if the enumeration of the
hashes is consistent. In general, this will mean that containers that
behave like String or Array will perform best.

History

Diff::LCS is a port of Perl's Algorithm::Diff that uses the
McIlroy-Hunt longest common subsequence (LCS) algorithm to compute
intelligent differences between two sequenced enumerable containers. The
implementation is based on Mario I. Wolczko's Smalltalk
version 1.2 (1993) and Ned Konz's Perl version Algorithm::Diff
1.15.

This library is called Diff::LCS because of an early version of
Algorithm::Diff which was restrictively licensed.