GithubHelp home page GithubHelp logo

daltk / diff-lcs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from halostatue/diff-lcs

0.0 2.0 0.0 968 KB

Generate difference sets between Ruby sequences.

Home Page: http://halostatue.github.com/diff-lcs

License: Other

diff-lcs's Introduction

Diff::LCS

home

diff-lcs.rubyforge.org/

code

github.com/halostatue/diff-lcs

bugs

github.com/halostatue/diff-lcs/issues

rdoc

rubydoc.info/github/halostatue/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. Everyone is strongly encouraged to upgrade to this version as it fixes all known outstanding issues.

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.

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

Continuous Integration Status

<img src=“https://travis-ci.org/halostatue/diff-lcs.png” />

Contributing

If you’d like to hack on Diff::LCS, start by forking the repo on GitHub:

github.com/halostatue/diff-lcs

The best way to get your changes merged back into core is as follows:

  1. Clone down your fork.

  2. Create a thoughtfully named topic branch to contain your change.

  3. Hack away.

  4. Add tests and make sure everything still passes by running rake.

  5. If you are adding new functionality, document it in the README.

  6. Do not change the version number, we will do that on our end.

  7. If necessary, rebase your commits into logical chunks, without errors.

  8. Push the branch up to GitHub.

  9. Send a pull request for your branch

:include: Contributing.rdoc

:include: License.rdoc

diff-lcs's People

Contributors

ged avatar halostatue avatar kachick avatar voxik avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.