Permalink
Browse files

This time, lets actually add diff-lcs

  • Loading branch information...
Caged committed Oct 17, 2008
1 parent 64cefa2 commit 2f4522c15c8f4734ea7db07f4c355ade06a3f619
View
@@ -3,7 +3,7 @@
require 'pathname'
require 'osx/cocoa'
libdir = OSX::NSBundle.mainBundle.resourcePath.stringByAppendingPathComponent("lib").fileSystemRepresentation
-$:.unshift(libdir, "#{libdir}/grit/lib", "#{libdir}/mime-types/lib", "#{libdir}/open4/lib")
+$:.unshift(libdir, "#{libdir}/grit/lib", "#{libdir}/mime-types/lib", "#{libdir}/open4/lib", "#{libdir}/diff-lcs/lib")
require 'grit'
require 'time_extensions'
require 'string_extensions'
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,21 @@
+#! /usr/env/bin ruby
+#--
+# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
+# adapted from:
+# Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
+# Smalltalk by Mario I. Wolczko <mario@wolczko.com>
+# implements McIlroy-Hunt diff algorithm
+#
+# This program is free software. It may be redistributed and/or modified under
+# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
+# Ruby licence.
+#
+# $Id: array.rb,v 1.3 2004/08/08 20:33:09 austin Exp $
+#++
+# Includes Diff::LCS into the Array built-in class.
+
+require 'diff/lcs'
+
+class Array
+ include Diff::LCS
+end
@@ -0,0 +1,51 @@
+#! /usr/env/bin ruby
+#--
+# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
+# adapted from:
+# Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
+# Smalltalk by Mario I. Wolczko <mario@wolczko.com>
+# implements McIlroy-Hunt diff algorithm
+#
+# This program is free software. It may be redistributed and/or modified under
+# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
+# Ruby licence.
+#
+# $Id: block.rb,v 1.3 2004/08/08 20:33:09 austin Exp $
+#++
+# Contains Diff::LCS::Block for bin/ldiff.
+
+ # A block is an operation removing, adding, or changing a group of items.
+ # Basically, this is just a list of changes, where each change adds or
+ # deletes a single item. Used by bin/ldiff.
+class Diff::LCS::Block
+ attr_reader :changes, :insert, :remove
+
+ def initialize(chunk)
+ @changes = []
+ @insert = []
+ @remove = []
+
+ chunk.each do |item|
+ @changes << item
+ @remove << item if item.deleting?
+ @insert << item if item.adding?
+ end
+ end
+
+ def diff_size
+ @insert.size - @remove.size
+ end
+
+ def op
+ case [@remove.empty?, @insert.empty?]
+ when [false, false]
+ '!'
+ when [false, true]
+ '-'
+ when [true, false]
+ '+'
+ else # [true, true]
+ '^'
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 2f4522c

Please sign in to comment.