diff-lcs 1.3

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.3, providing a tentative fix to a long-standing issue related to incorrect detection of a patch direction. Also modernizes the gem infrastructure, testing infrastructure, and provides a warning-free experience to Ruby 2.4 users.

Homepage: https://github.com/halostatue/diff-lcs

Platform: Rubygems

Language: Ruby

Licenses: MIT/Artistic-2.0/GPL-2.0+

View on registry: https://rubygems.org/gems/diff-lcs/versions/1.3

Documentation: http://www.rubydoc.info/gems/diff-lcs/1.3

Direct download link: https://rubygems.org/downloads/diff-lcs-1.3.gem

Install: gem install diff-lcs -v 1.3


Diff::LCS

home

github.com/halostatue/diff-lcs

code

github.com/halostatue/diff-lcs

bugs

github.com/halostatue/diff-lcs/issues

rdoc

rubydoc.info/github/halostatue/diff-lcs

continuous integration

test coverage

Coverage Status

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.3, providing a tentative fix to a long-standing issue related to incorrect detection of a patch direction. Also modernizes the gem infrastructure, testing infrastructure, and provides a warning-free experience to Ruby 2.4 users.

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:

require 'diff/lcs'

seq1 = %w(a b c e h j l m n p)
seq2 = %w(b c d e f j k l m r s t)

lcs = Diff::LCS.LCS(seq1, seq2)
diffs = Diff::LCS.diff(seq1, seq2)
sdiff = Diff::LCS.sdiff(seq1, seq2)
seq = Diff::LCS.traverse_sequences(seq1, seq2, callback_obj)
bal = Diff::LCS.traverse_balanced(seq1, seq2, callback_obj)
seq2 == Diff::LCS.patch!(seq1, diffs)
seq1 == Diff::LCS.unpatch!(seq2, diffs)
seq2 == Diff::LCS.patch!(seq1, sdiff)
seq1 == Diff::LCS.unpatch!(seq2, sdiff)

Objects can be extended with Diff::LCS:

seq1.extend(Diff::LCS)
lcs = seq1.lcs(seq2)
diffs = seq1.diff(seq2)
sdiff = seq1.sdiff(seq2)
seq = seq1.traverse_sequences(seq2, callback_obj)
bal = seq1.traverse_balanced(seq2, callback_obj)
seq2 == seq1.patch!(diffs)
seq1 == seq2.unpatch!(diffs)
seq2 == seq1.patch!(sdiff)
seq1 == seq2.unpatch!(sdiff)

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. Diff::LCS#sdiff and Diff::LCS#traverse_balanced were originally written for the Perl version by Mike Schilli.

The algorithm is described in A Fast Algorithm for Computing Longest Common Subsequences, CACM, vol.20, no.5, pp.350-353, May 1977, with a few minor improvements to improve the speed. A simplified description of the algorithm, originally written for the Perl version, was written by Mark-Jason Dominus.

:include: Contributing.rdoc

:include: License.rdoc

Releases

  • 1.3 - January 18, 2017 23:44
  • 1.2.5 - November 08, 2013 03:40
  • 1.2.4 - April 21, 2013 00:08
  • 1.2.3 - April 12, 2013 02:30
  • 1.2.2 - March 30, 2013 21:32
  • 1.2.1 - February 09, 2013 16:28
  • 1.2.0 - January 21, 2013 06:36
  • 1.1.3 - August 28, 2011 02:01
  • 1.1.2 - July 25, 2009 18:27
  • 1.1.1 - July 25, 2009 18:27

Project Statistics

SourceRank 20
Dependencies 0
Dependent projects 268
Dependent repositories 126K
Total releases 10
Latest release
First release
Stars 125
Forks 31
Watchers 5
Contributors 12
Repo Size: 972 KB

Top Contributors See all

Austin Ziegler Jon Rowe Vít Ondruch Philippe Lafoucrière Mark Friedgan Michael Granger Paul Kunysch ginriki joshbronson Josep kevinmook Kenichi Kamiya

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2017-01-19 00:01:40 UTC

Login to resync this project