diff-lcs-1.2.4/ 0000755 0000041 0000041 00000000000 12142203755 013236 5 ustar www-data www-data diff-lcs-1.2.4/.travis.yml 0000644 0000041 0000041 00000000515 12142203755 015350 0 ustar www-data www-data ---
after_script:
- rake travis:after -t
before_script:
- gem install hoe-travis --no-rdoc --no-ri
- rake travis:before -t
language: ruby
notifications:
email: true
rvm:
- 2.0.0
- 1.9.3
- 1.9.2
- ruby-head
- 1.8.7
- jruby-19mode
- jruby-head
- jruby-18mode
- rbx-19mode
- rbx-18mode
- ree
script: rake travis
diff-lcs-1.2.4/README.rdoc 0000644 0000041 0000041 00000006210 12142203755 015043 0 ustar www-data www-data = Diff::LCS
home :: http://diff-lcs.rubyforge.org/
code :: https://github.com/halostatue/diff-lcs
bugs :: https://github.com/halostatue/diff-lcs/issues
rdoc :: http://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.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}[https://github.com/rubinius/rubinius/issues/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:
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}[ftp://st.cs.uiuc.edu/pub/Smalltalk/MANCHESTER/manchester/4.0/diff.st]
(1993) and Ned Konz's Perl version
{Algorithm::Diff 1.15}[http://search.cpan.org/~nedkonz/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
{
}[https://travis-ci.org/halostatue/diff-lcs]
:include: Contributing.rdoc
:include: License.rdoc
diff-lcs-1.2.4/Rakefile 0000644 0000041 0000041 00000001715 12142203755 014707 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'rubygems'
require 'rspec'
require 'hoe'
Hoe.plugin :bundler
Hoe.plugin :doofus
Hoe.plugin :email
Hoe.plugin :gemspec2
Hoe.plugin :git
Hoe.plugin :rubyforge
Hoe.plugin :travis
Hoe.spec 'diff-lcs' do
developer('Austin Ziegler', 'austin@rubyforge.org')
self.remote_rdoc_dir = '.'
self.rsync_args << ' --exclude=statsvn/'
self.history_file = 'History.rdoc'
self.readme_file = 'README.rdoc'
self.extra_rdoc_files = FileList["*.rdoc"].to_a
self.extra_dev_deps << ['hoe-bundler', '~> 1.2']
self.extra_dev_deps << ['hoe-doofus', '~> 1.0']
self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
self.extra_dev_deps << ['hoe-git', '~> 1.5']
self.extra_dev_deps << ['hoe-rubygems', '~> 1.0']
self.extra_dev_deps << ['hoe-travis', '~> 1.2']
self.extra_dev_deps << ['rake', '~> 10.0']
self.extra_dev_deps << ['rspec', '~> 2.0']
end
unless Rake::Task.task_defined? :test
task :test => :spec
end
# vim: syntax=ruby
diff-lcs-1.2.4/Contributing.rdoc 0000644 0000041 0000041 00000004173 12142203755 016563 0 ustar www-data www-data == Contributing
I value any contribution to Diff::LCS you can provide: a bug report, a feature
request, or code contributions.
Code contributions to Diff::LCS are especially welcomeencouraged.
Because Diff::LCS is a complex codebase, there are a few guidelines:
* Changes will not be accepted without tests.
* The test suite is written with RSpec.‡
* Match my coding style.
* Use a thoughtfully-named topic branch that contains your change. Rebase your
commits into logical chunks as necessary.
* Use {quality commit messages}[http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html].
* Do not change the version number; when your patch is accepted and a release
is made, the version will be updated at that point.
* Submit a GitHub pull request with your changes.
* New features require new documentation.
=== Test Dependencies
To run the test suite, you will need to install the development dependencies
for Diff::LCS. If you have Bundler, you can accomplish this easily:
$ bundle install
Diff::LCS uses Ryan Davis’s excellent {Hoe}[https://github.com/seattlerb/hoe]
to manage the release process, and it adds a number of rake tasks. You will
mostly be interested in:
$ rake
which runs the tests the same way that:
$ rake spec
$ rake test
$ rake travis
will do.
=== Workflow
Here's the most direct way to get your work merged into the project:
* Fork the project.
* Clone down your fork (+git clone git://github.com//diff-lcs.git+).
* Create a topic branch to contain your change (+git checkout -b my\_awesome\_feature+).
* Hack away, add tests. Not necessarily in that order.
* Make sure everything still passes by running `rake`.
* If necessary, rebase your commits into logical chunks, without errors.
* Push the branch up (+git push origin my\_awesome\_feature+).
* Create a pull request against halostatue/diff-lcs and describe what your
change does and the why you think it should be merged.
=== Contributors
* Austin Ziegler created Diff::LCS.
Thanks to everyone else who has contributed to Diff::LCS:
* Kenichi Kamiya
* Michael Granger
* Vít Ondruch
* Jon Rowe
diff-lcs-1.2.4/spec/ 0000755 0000041 0000041 00000000000 12142203755 014170 5 ustar www-data www-data diff-lcs-1.2.4/spec/lcs_spec.rb 0000644 0000041 0000041 00000003241 12142203755 016310 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS::Internals.lcs" do
include Diff::LCS::SpecHelper::Matchers
it "should return a meaningful LCS array with (seq1, seq2)" do
res = Diff::LCS::Internals.lcs(seq1, seq2)
# The result of the LCS (less the +nil+ values) must be as long as the
# correct result.
res.compact.size.should == correct_lcs.size
res.should correctly_map_sequence(seq1).to_other_sequence(seq2)
# Compact these transformations and they should be the correct LCS.
x_seq1 = (0...res.size).map { |ix| res[ix] ? seq1[ix] : nil }.compact
x_seq2 = (0...res.size).map { |ix| res[ix] ? seq2[res[ix]] : nil }.compact
x_seq1.should == correct_lcs
x_seq2.should == correct_lcs
end
it "should return all indexes with (hello, hello)" do
Diff::LCS::Internals.lcs(hello, hello).should == (0...hello.size).to_a
end
it "should return all indexes with (hello_ary, hello_ary)" do
Diff::LCS::Internals.lcs(hello_ary, hello_ary).should == (0...hello_ary.size).to_a
end
end
describe "Diff::LCS.LCS" do
include Diff::LCS::SpecHelper::Matchers
it "should return the correct compacted values from Diff::LCS.LCS" do
res = Diff::LCS.LCS(seq1, seq2)
res.should == correct_lcs
res.compact.should == res
end
it "should be transitive" do
res = Diff::LCS.LCS(seq2, seq1)
res.should == correct_lcs
res.compact.should == res
end
it "should return %W(h e l l o) with (hello, hello)" do
Diff::LCS.LCS(hello, hello).should == hello.split(//)
end
it "should return hello_ary with (hello_ary, hello_ary)" do
Diff::LCS.LCS(hello_ary, hello_ary).should == hello_ary
end
end
diff-lcs-1.2.4/spec/traverse_sequences_spec.rb 0000644 0000041 0000041 00000011244 12142203755 021437 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS.traverse_sequences" do
describe "callback with no finishers" do
describe "over (seq1, seq2)" do
before(:each) do
@callback_s1_s2 = simple_callback_no_finishers
Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2)
@callback_s2_s1 = simple_callback_no_finishers
Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1)
end
it "should have the correct LCS result on left-matches" do
@callback_s1_s2.matched_a.should == correct_lcs
@callback_s2_s1.matched_a.should == correct_lcs
end
it "should have the correct LCS result on right-matches" do
@callback_s1_s2.matched_b.should == correct_lcs
@callback_s2_s1.matched_b.should == correct_lcs
end
it "should have the correct skipped sequences with the left sequence" do
@callback_s1_s2.discards_a.should == skipped_seq1
@callback_s2_s1.discards_a.should == skipped_seq2
end
it "should have the correct skipped sequences with the right sequence" do
@callback_s1_s2.discards_b.should == skipped_seq2
@callback_s2_s1.discards_b.should == skipped_seq1
end
it "should not have anything done markers from the left or right sequences" do
@callback_s1_s2.done_a.should be_empty
@callback_s1_s2.done_b.should be_empty
@callback_s2_s1.done_a.should be_empty
@callback_s2_s1.done_b.should be_empty
end
end
describe "over (hello, hello)" do
before(:each) do
@callback = simple_callback_no_finishers
Diff::LCS.traverse_sequences(hello, hello, @callback)
end
it "should have the correct LCS result on left-matches" do
@callback.matched_a.should == hello.split(//)
end
it "should have the correct LCS result on right-matches" do
@callback.matched_b.should == hello.split(//)
end
it "should have the correct skipped sequences with the left sequence", :only => true do
@callback.discards_a.should be_empty
end
it "should have the correct skipped sequences with the right sequence" do
@callback.discards_b.should be_empty
end
it "should not have anything done markers from the left or right sequences" do
@callback.done_a.should be_empty
@callback.done_b.should be_empty
end
end
describe "over (hello_ary, hello_ary)" do
before(:each) do
@callback = simple_callback_no_finishers
Diff::LCS.traverse_sequences(hello_ary, hello_ary, @callback)
end
it "should have the correct LCS result on left-matches" do
@callback.matched_a.should == hello_ary
end
it "should have the correct LCS result on right-matches" do
@callback.matched_b.should == hello_ary
end
it "should have the correct skipped sequences with the left sequence" do
@callback.discards_a.should be_empty
end
it "should have the correct skipped sequences with the right sequence" do
@callback.discards_b.should be_empty
end
it "should not have anything done markers from the left or right sequences" do
@callback.done_a.should be_empty
@callback.done_b.should be_empty
end
end
end
describe "callback with finisher" do
before(:each) do
@callback_s1_s2 = simple_callback
Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2)
@callback_s2_s1 = simple_callback
Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1)
end
it "should have the correct LCS result on left-matches" do
@callback_s1_s2.matched_a.should == correct_lcs
@callback_s2_s1.matched_a.should == correct_lcs
end
it "should have the correct LCS result on right-matches" do
@callback_s1_s2.matched_b.should == correct_lcs
@callback_s2_s1.matched_b.should == correct_lcs
end
it "should have the correct skipped sequences for the left sequence" do
@callback_s1_s2.discards_a.should == skipped_seq1
@callback_s2_s1.discards_a.should == skipped_seq2
end
it "should have the correct skipped sequences for the right sequence" do
@callback_s1_s2.discards_b.should == skipped_seq2
@callback_s2_s1.discards_b.should == skipped_seq1
end
it "should have done markers differently-sized sequences" do
@callback_s1_s2.done_a.should == [[ "p", 9, "s", 10 ]]
@callback_s1_s2.done_b.should be_empty
# 20110731 I don't yet understand why this particular behaviour
# isn't transitive.
@callback_s2_s1.done_a.should be_empty
@callback_s2_s1.done_b.should be_empty
end
end
end
diff-lcs-1.2.4/spec/hunk_spec.rb 0000644 0000041 0000041 00000004165 12142203755 016502 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
def h(v)
v.to_s.bytes.to_a.map { |e| "%02x" % e }.join
end
describe "Diff::LCS::Hunk" do
if String.method_defined?(:encoding)
let(:old_data) { ["Tu avec carté {count} itém has".encode('UTF-16LE')] }
let(:new_data) { ["Tu avec carte {count} item has".encode('UTF-16LE')] }
let(:pieces) { Diff::LCS.diff old_data, new_data }
let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
it 'should be able to produce a unified diff from the two pieces' do
expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
@@ -1,2 +1,2 @@
-Tu avec carté {count} itém has
+Tu avec carte {count} item has
EOD
expect(hunk.diff(:unified).to_s == expected).to eql true
end
it 'should be able to produce a context diff from the two pieces' do
expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
***************
*** 1,2 ****
!Tu avec carté {count} itém has
--- 1,2 ----
!Tu avec carte {count} item has
EOD
expect(hunk.diff(:context).to_s == expected).to eql true
end
it 'should be able to produce an old diff from the two pieces' do
expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
1,2c1,2
< Tu avec carté {count} itém has
---
> Tu avec carte {count} item has
EOD
expect(hunk.diff(:old).to_s == expected).to eql true
end
it 'should be able to produce a reverse ed diff from the two pieces' do
expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
c1,2
Tu avec carte {count} item has
.
EOD
expect(hunk.diff(:reverse_ed).to_s == expected).to eql true
end
context 'with empty first data set' do
let(:old_data) { [] }
it 'should be able to produce a unified diff' do
expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
@@ -1 +1,2 @@
+Tu avec carte {count} item has
EOD
expect(hunk.diff(:unified).to_s == expected).to eql true
end
end
end
end
diff-lcs-1.2.4/spec/sdiff_spec.rb 0000644 0000041 0000041 00000012142 12142203755 016622 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS.sdiff" do
include Diff::LCS::SpecHelper::Matchers
shared_examples "compare sequences correctly" do
it "should compare s1 -> s2 correctly" do
Diff::LCS.sdiff(s1, s2).should == context_diff(result)
end
it "should compare s2 -> s1 correctly" do
Diff::LCS.sdiff(s2, s1).should == context_diff(reverse_sdiff(result))
end
end
describe "using seq1 & seq2" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:result) { correct_forward_sdiff }
it_has_behavior "compare sequences correctly"
end
describe "using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)" do
let(:s1) { %w(abc def yyy xxx ghi jkl) }
let(:s2) { %w(abc dxf xxx ghi jkl) }
let(:result) {
[
[ '=', [ 0, 'abc' ], [ 0, 'abc' ] ],
[ '!', [ 1, 'def' ], [ 1, 'dxf' ] ],
[ '-', [ 2, 'yyy' ], [ 2, nil ] ],
[ '=', [ 3, 'xxx' ], [ 2, 'xxx' ] ],
[ '=', [ 4, 'ghi' ], [ 3, 'ghi' ] ],
[ '=', [ 5, 'jkl' ], [ 4, 'jkl' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(a b c d e) & %w(a e)" do
let(:s1) { %w(a b c d e) }
let(:s2) { %w(a e) }
let(:result) {
[
[ '=', [ 0, 'a' ], [ 0, 'a' ] ],
[ '-', [ 1, 'b' ], [ 1, nil ] ],
[ '-', [ 2, 'c' ], [ 1, nil ] ],
[ '-', [ 3, 'd' ], [ 1, nil ] ],
[ '=', [ 4, 'e' ], [ 1, 'e' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(a e) & %w(a b c d e)" do
let(:s1) { %w(a e) }
let(:s2) { %w(a b c d e) }
let(:result) {
[
[ '=', [ 0, 'a' ], [ 0, 'a' ] ],
[ '+', [ 1, nil ], [ 1, 'b' ] ],
[ '+', [ 1, nil ], [ 2, 'c' ] ],
[ '+', [ 1, nil ], [ 3, 'd' ] ],
[ '=', [ 1, 'e' ], [ 4, 'e' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(v x a e) & %w(w y a b c d e)" do
let(:s1) { %w(v x a e) }
let(:s2) { %w(w y a b c d e) }
let(:result) {
[
[ '!', [ 0, 'v' ], [ 0, 'w' ] ],
[ '!', [ 1, 'x' ], [ 1, 'y' ] ],
[ '=', [ 2, 'a' ], [ 2, 'a' ] ],
[ '+', [ 3, nil ], [ 3, 'b' ] ],
[ '+', [ 3, nil ], [ 4, 'c' ] ],
[ '+', [ 3, nil ], [ 5, 'd' ] ],
[ '=', [ 3, 'e' ], [ 6, 'e' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(x a e) & %w(a b c d e)" do
let(:s1) { %w(x a e) }
let(:s2) { %w(a b c d e) }
let(:result) {
[
[ '-', [ 0, 'x' ], [ 0, nil ] ],
[ '=', [ 1, 'a' ], [ 0, 'a' ] ],
[ '+', [ 2, nil ], [ 1, 'b' ] ],
[ '+', [ 2, nil ], [ 2, 'c' ] ],
[ '+', [ 2, nil ], [ 3, 'd' ] ],
[ '=', [ 2, 'e' ], [ 4, 'e' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(a e) & %w(x a b c d e)" do
let(:s1) { %w(a e) }
let(:s2) { %w(x a b c d e) }
let(:result) {
[
[ '+', [ 0, nil ], [ 0, 'x' ] ],
[ '=', [ 0, 'a' ], [ 1, 'a' ] ],
[ '+', [ 1, nil ], [ 2, 'b' ] ],
[ '+', [ 1, nil ], [ 3, 'c' ] ],
[ '+', [ 1, nil ], [ 4, 'd' ] ],
[ '=', [ 1, 'e' ], [ 5, 'e' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(a e v) & %w(x a b c d e w x)" do
let(:s1) { %w(a e v) }
let(:s2) { %w(x a b c d e w x) }
let(:result) {
[
[ '+', [ 0, nil ], [ 0, 'x' ] ],
[ '=', [ 0, 'a' ], [ 1, 'a' ] ],
[ '+', [ 1, nil ], [ 2, 'b' ] ],
[ '+', [ 1, nil ], [ 3, 'c' ] ],
[ '+', [ 1, nil ], [ 4, 'd' ] ],
[ '=', [ 1, 'e' ], [ 5, 'e' ] ],
[ '!', [ 2, 'v' ], [ 6, 'w' ] ],
[ '+', [ 3, nil ], [ 7, 'x' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w() & %w(a b c)" do
let(:s1) { %w() }
let(:s2) { %w(a b c) }
let(:result) {
[
[ '+', [ 0, nil ], [ 0, 'a' ] ],
[ '+', [ 0, nil ], [ 1, 'b' ] ],
[ '+', [ 0, nil ], [ 2, 'c' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(a b c) & %w(1)" do
let(:s1) { %w(a b c) }
let(:s2) { %w(1) }
let(:result) {
[
[ '!', [ 0, 'a' ], [ 0, '1' ] ],
[ '-', [ 1, 'b' ], [ 1, nil ] ],
[ '-', [ 2, 'c' ], [ 1, nil ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(a b c) & %w(c)" do
let(:s1) { %w(a b c) }
let(:s2) { %w(c) }
let(:result) {
[
[ '-', [ 0, 'a' ], [ 0, nil ] ],
[ '-', [ 1, 'b' ], [ 0, nil ] ],
[ '=', [ 2, 'c' ], [ 0, 'c' ] ]
]
}
it_has_behavior "compare sequences correctly"
end
describe "using %w(abcd efgh ijkl mnop) & []" do
let(:s1) { %w(abcd efgh ijkl mnop) }
let(:s2) { [] }
let(:result) {
[
[ '-', [ 0, 'abcd' ], [ 0, nil ] ],
[ '-', [ 1, 'efgh' ], [ 0, nil ] ],
[ '-', [ 2, 'ijkl' ], [ 0, nil ] ],
[ '-', [ 3, 'mnop' ], [ 0, nil ] ]
]
}
it_has_behavior "compare sequences correctly"
end
end
diff-lcs-1.2.4/spec/traverse_balanced_spec.rb 0000644 0000041 0000041 00000016345 12142203755 021204 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS.traverse_balanced" do
include Diff::LCS::SpecHelper::Matchers
shared_examples "with a #change callback" do |s1, s2, result|
it "should traverse s1 -> s2 correctly" do
traversal = balanced_traversal(s1, s2, :balanced_callback)
traversal.result.should == result
end
it "should traverse s2 -> s1 correctly" do
traversal = balanced_traversal(s2, s1, :balanced_callback)
traversal.result.should == balanced_reverse(result)
end
end
shared_examples "without a #change callback" do |s1, s2, result|
it "should traverse s1 -> s2 correctly" do
traversal = balanced_traversal(s1, s2, :balanced_callback_no_change)
traversal.result.should == map_to_no_change(result)
end
it "should traverse s2 -> s1 correctly" do
traversal = balanced_traversal(s2, s1, :balanced_callback_no_change)
traversal.result.should == map_to_no_change(balanced_reverse(result))
end
end
describe "identical string sequences ('abc')" do
s1 = s2 = "abc"
result = [
[ '=', 0, 0 ],
[ '=', 1, 1 ],
[ '=', 2, 2 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "identical array sequences %w(a b c)" do
s1 = s2 = %w(a b c)
result = [
[ '=', 0, 0 ],
[ '=', 1, 1 ],
[ '=', 2, 2 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(a b c) & %w(a x c)" do
s1 = %w(a b c)
s2 = %w(a x c)
result = [
[ '=', 0, 0 ],
[ '!', 1, 1 ],
[ '=', 2, 2 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(a x y c) & %w(a v w c)" do
s1 = %w(a x y c)
s2 = %w(a v w c)
result = [
[ '=', 0, 0 ],
[ '!', 1, 1 ],
[ '!', 2, 2 ],
[ '=', 3, 3 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(x y c) & %w(v w c)" do
s1 = %w(x y c)
s2 = %w(v w c)
result = [
[ '!', 0, 0 ],
[ '!', 1, 1 ],
[ '=', 2, 2 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(a x y z) & %w(b v w)" do
s1 = %w(a x y z)
s2 = %w(b v w)
result = [
[ '!', 0, 0 ],
[ '!', 1, 1 ],
[ '!', 2, 2 ],
[ '<', 3, 3 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(a z) & %w(a)" do
s1 = %w(a z)
s2 = %w(a)
result = [
[ '=', 0, 0 ],
[ '<', 1, 1 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(z a) & %w(a)" do
s1 = %w(z a)
s2 = %w(a)
result = [
[ '<', 0, 0 ],
[ '=', 1, 0 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(a b c) & %w(x y z)" do
s1 = %w(a b c)
s2 = %w(x y z)
result = [
[ '!', 0, 0 ],
[ '!', 1, 1 ],
[ '!', 2, 2 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "sequences %w(abcd efgh ijkl mnoopqrstuvwxyz) & []" do
s1 = %w(abcd efgh ijkl mnopqrstuvwxyz)
s2 = []
result = [
[ '<', 0, 0 ],
[ '<', 1, 0 ],
[ '<', 2, 0 ],
[ '<', 3, 0 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(a b c) & %Q(a x c)" do
s1 = %Q(a b c)
s2 = %Q(a x c)
result = [
[ '=', 0, 0 ],
[ '=', 1, 1 ],
[ '!', 2, 2 ],
[ '=', 3, 3 ],
[ '=', 4, 4 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(a x y c) & %Q(a v w c)" do
s1 = %Q(a x y c)
s2 = %Q(a v w c)
result = [
[ '=', 0, 0 ],
[ '=', 1, 1 ],
[ '!', 2, 2 ],
[ '=', 3, 3 ],
[ '!', 4, 4 ],
[ '=', 5, 5 ],
[ '=', 6, 6 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(x y c) & %Q(v w c)" do
s1 = %Q(x y c)
s2 = %Q(v w c)
result = [
[ '!', 0, 0 ],
[ '=', 1, 1 ],
[ '!', 2, 2 ],
[ '=', 3, 3 ],
[ '=', 4, 4 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(a x y z) & %Q(b v w)" do
s1 = %Q(a x y z)
s2 = %Q(b v w)
result = [
[ '!', 0, 0 ],
[ '=', 1, 1 ],
[ '!', 2, 2 ],
[ '=', 3, 3 ],
[ '!', 4, 4 ],
[ '<', 5, 5 ],
[ '<', 6, 5 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(a z) & %Q(a)" do
s1 = %Q(a z)
s2 = %Q(a)
result = [
[ '=', 0, 0 ],
[ '<', 1, 1 ],
[ '<', 2, 1 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(z a) & %Q(a)" do
s1 = %Q(z a)
s2 = %Q(a)
result = [
[ '<', 0, 0 ],
[ '<', 1, 0 ],
[ '=', 2, 0 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(a b c) & %Q(x y z)" do
s1 = %Q(a b c)
s2 = %Q(x y z)
result = [
[ '!', 0, 0 ],
[ '=', 1, 1 ],
[ '!', 2, 2 ],
[ '=', 3, 3 ],
[ '!', 4, 4 ]
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
describe "strings %Q(abcd efgh ijkl mnopqrstuvwxyz) & %Q()" do
s1 = %Q(abcd efgh ijkl mnopqrstuvwxyz)
s2 = ""
result = [
[ '<', 0, 0 ],
[ '<', 1, 0 ],
[ '<', 2, 0 ],
[ '<', 3, 0 ],
[ '<', 4, 0 ],
[ '<', 5, 0 ],
[ '<', 6, 0 ],
[ '<', 7, 0 ],
[ '<', 8, 0 ],
[ '<', 9, 0 ],
[ '<', 10, 0 ],
[ '<', 11, 0 ],
[ '<', 12, 0 ],
[ '<', 13, 0 ],
[ '<', 14, 0 ],
[ '<', 15, 0 ],
[ '<', 16, 0 ],
[ '<', 17, 0 ],
[ '<', 18, 0 ],
[ '<', 19, 0 ],
[ '<', 20, 0 ],
[ '<', 21, 0 ],
[ '<', 22, 0 ],
[ '<', 23, 0 ],
[ '<', 24, 0 ],
[ '<', 25, 0 ],
[ '<', 26, 0 ],
[ '<', 27, 0 ],
[ '<', 28, 0 ],
]
it_has_behavior "with a #change callback", s1, s2, result
it_has_behavior "without a #change callback", s1, s2, result
end
end
diff-lcs-1.2.4/spec/diff_spec.rb 0000644 0000041 0000041 00000002473 12142203755 016445 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS.diff" do
include Diff::LCS::SpecHelper::Matchers
it "should correctly diff seq1 to seq2" do
diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
change_diff(correct_forward_diff).should == diff_s1_s2
end
it "should correctly diff seq2 to seq1" do
diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
change_diff(correct_backward_diff).should == diff_s2_s1
end
it "should correctly diff against an empty sequence" do
diff = Diff::LCS.diff(word_sequence, [])
correct_diff = [
[ [ '-', 0, 'abcd' ],
[ '-', 1, 'efgh' ],
[ '-', 2, 'ijkl' ],
[ '-', 3, 'mnopqrstuvwxyz' ] ]
]
change_diff(correct_diff).should == diff
diff = Diff::LCS.diff([], word_sequence)
correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
change_diff(correct_diff).should == diff
end
it "should correctly diff 'xx' and 'xaxb'" do
left = 'xx'
right = 'xaxb'
Diff::LCS.patch(left, Diff::LCS.diff(left, right)).should == right
end
it "should return an empty diff with (hello, hello)" do
Diff::LCS.diff(hello, hello).should == []
end
it "should return an empty diff with (hello_ary, hello_ary)" do
Diff::LCS.diff(hello_ary, hello_ary).should == []
end
end
diff-lcs-1.2.4/spec/patch_spec.rb 0000644 0000041 0000041 00000035306 12142203755 016635 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS.patch" do
include Diff::LCS::SpecHelper::Matchers
shared_examples "patch sequences correctly" do
it "should correctly patch left-to-right (patch autodiscovery)" do
Diff::LCS.patch(s1, patch_set).should == s2
end
it "should correctly patch left-to-right (explicit patch)" do
Diff::LCS.patch(s1, patch_set, :patch).should == s2
Diff::LCS.patch!(s1, patch_set).should == s2
end
it "should correctly patch right-to-left (unpatch autodiscovery)" do
Diff::LCS.patch(s2, patch_set).should == s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(s2, patch_set, :unpatch).should == s1
Diff::LCS.unpatch!(s2, patch_set).should == s1
end
end
describe "using a Diff::LCS.diff patchset" do
describe "an empty patchset returns the source" do
it "works on a string (hello)" do
Diff::LCS::patch(hello, Diff::LCS.diff(hello, hello)).should == hello
end
it "works on an array %W(h e l l o)" do
Diff::LCS::patch(hello_ary, Diff::LCS.diff(hello_ary, hello_ary)).should == hello_ary
end
end
describe "with default diff callbacks (DiffCallbacks)" do
describe "forward (s1 -> s2)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) { Diff::LCS.diff(seq1, seq2) }
end
end
describe "reverse (s2 -> s1)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) { Diff::LCS.diff(seq2, seq1) }
end
end
end
describe "with context diff callbacks (ContextDiffCallbacks)" do
describe "forward (s1 -> s2)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
}
end
end
describe "reverse (s2 -> s1)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
Diff::LCS.diff(seq2, seq1, Diff::LCS::ContextDiffCallbacks)
}
end
end
end
describe "with sdiff callbacks (SDiffCallbacks)" do
describe "forward (s1 -> s2)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
Diff::LCS.diff(seq1, seq2, Diff::LCS::SDiffCallbacks)
}
end
end
describe "reverse (s2 -> s1)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
Diff::LCS.diff(seq2, seq1, Diff::LCS::SDiffCallbacks)
}
end
end
end
end
describe "using a Diff::LCS.sdiff patchset" do
describe "an empty patchset returns the source" do
it "works on a string (hello)" do
Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello)).should == hello
end
it "works on an array %W(h e l l o)" do
Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary)).should == hello_ary
end
end
describe "with default diff callbacks (DiffCallbacks)" do
describe "forward (s1 -> s2)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
Diff::LCS.sdiff(seq1, seq2, Diff::LCS::DiffCallbacks)
}
end
end
describe "reverse (s2 -> s1)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
Diff::LCS.sdiff(seq2, seq1, Diff::LCS::DiffCallbacks)
}
end
end
end
describe "with context diff callbacks (DiffCallbacks)" do
describe "forward (s1 -> s2)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
}
end
end
describe "reverse (s2 -> s1)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
Diff::LCS.sdiff(seq2, seq1, Diff::LCS::ContextDiffCallbacks)
}
end
end
end
describe "with sdiff callbacks (SDiffCallbacks)" do
describe "forward (s1 -> s2)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) }
end
end
describe "reverse (s2 -> s1)" do
it_has_behavior "patch sequences correctly" do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) }
end
end
end
end
# Note: because of the error in autodiscovery ("does not autodiscover s1
# to s2 patches"), this cannot use the "patch sequences correctly" shared
# set. Once the bug in autodiscovery is fixed, this can be converted as
# above.
describe "fix bug 891: patchsets do not contain the last equal part" do
before(:each) do
@s1 = %w(a b c d e f g h i j k)
@s2 = %w(a b c d D e f g h i j k)
end
describe "using Diff::LCS.diff with default diff callbacks" do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
end
it "should autodiscover s1 to s2 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 the left-to-right patches" do
Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
end
it "should correctly patch left-to-right (explicit patch)" do
Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
end
end
describe "using Diff::LCS.diff with context diff callbacks" do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
end
it "should autodiscover s1 to s2 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 the left-to-right patches" do
Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
end
it "should correctly patch left-to-right (explicit patch)" do
Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
end
end
describe "using Diff::LCS.diff with sdiff callbacks" do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
end
it "should autodiscover s1 to s2 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 the left-to-right patches" do
Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
end
it "should correctly patch left-to-right (explicit patch)" do
Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
end
end
describe "using Diff::LCS.sdiff with default sdiff callbacks" do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2)
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
end
it "should autodiscover s1 to s2 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 the left-to-right patches" do
Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
end
it "should correctly patch left-to-right (explicit patch)", :only => true do
Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
end
end
describe "using Diff::LCS.sdiff with context diff callbacks" do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
end
it "should autodiscover s1 to s2 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 the left-to-right patches" do
Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
end
it "should correctly patch left-to-right (explicit patch)" do
Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
end
end
describe "using Diff::LCS.sdiff with default diff callbacks" do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks)
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
end
it "should autodiscover s1 to s2 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 patches" do
expect do
Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
end.to_not raise_error(RuntimeError, /provided patchset/)
end
it "should autodiscover s2 to s1 the left-to-right patches" do
Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
end
it "should correctly patch left-to-right (explicit patch)" do
Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
end
it "should correctly patch right-to-left (explicit unpatch)" do
Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
end
end
end
end
diff-lcs-1.2.4/spec/spec_helper.rb 0000644 0000041 0000041 00000013573 12142203755 017017 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'rubygems'
require 'pathname'
file = Pathname.new(__FILE__).expand_path
path = file.parent
parent = path.parent
$:.unshift parent.join('lib')
require 'diff-lcs'
module Diff::LCS::SpecHelper
def hello
"hello"
end
def hello_ary
%W(h e l l o)
end
def seq1
%w(a b c e h j l m n p)
end
def skipped_seq1
%w(a h n p)
end
def seq2
%w(b c d e f j k l m r s t)
end
def skipped_seq2
%w(d f k r s t)
end
def word_sequence
%w(abcd efgh ijkl mnopqrstuvwxyz)
end
def correct_lcs
%w(b c e j l m)
end
def correct_forward_diff
[
[ [ '-', 0, 'a' ] ],
[ [ '+', 2, 'd' ] ],
[ [ '-', 4, 'h' ],
[ '+', 4, 'f' ] ],
[ [ '+', 6, 'k' ] ],
[ [ '-', 8, 'n' ],
[ '-', 9, 'p' ],
[ '+', 9, 'r' ],
[ '+', 10, 's' ],
[ '+', 11, 't' ] ]
]
end
def correct_backward_diff
[
[ [ '+', 0, 'a' ] ],
[ [ '-', 2, 'd' ] ],
[ [ '-', 4, 'f' ],
[ '+', 4, 'h' ] ],
[ [ '-', 6, 'k' ] ],
[
[ '-', 9, 'r' ],
[ '-', 10, 's' ],
[ '+', 8, 'n' ],
[ '-', 11, 't' ],
[ '+', 9, 'p' ] ]
]
end
def correct_forward_sdiff
[
[ '-', [ 0, 'a' ], [ 0, nil ] ],
[ '=', [ 1, 'b' ], [ 0, 'b' ] ],
[ '=', [ 2, 'c' ], [ 1, 'c' ] ],
[ '+', [ 3, nil ], [ 2, 'd' ] ],
[ '=', [ 3, 'e' ], [ 3, 'e' ] ],
[ '!', [ 4, 'h' ], [ 4, 'f' ] ],
[ '=', [ 5, 'j' ], [ 5, 'j' ] ],
[ '+', [ 6, nil ], [ 6, 'k' ] ],
[ '=', [ 6, 'l' ], [ 7, 'l' ] ],
[ '=', [ 7, 'm' ], [ 8, 'm' ] ],
[ '!', [ 8, 'n' ], [ 9, 'r' ] ],
[ '!', [ 9, 'p' ], [ 10, 's' ] ],
[ '+', [ 10, nil ], [ 11, 't' ] ]
]
end
def reverse_sdiff(forward_sdiff)
forward_sdiff.map { |line|
line[1], line[2] = line[2], line[1]
case line[0]
when '-' then line[0] = '+'
when '+' then line[0] = '-'
end
line
}
end
def change_diff(diff)
map_diffs(diff, Diff::LCS::Change)
end
def context_diff(diff)
map_diffs(diff, Diff::LCS::ContextChange)
end
def format_diffs(diffs)
diffs.map do |e|
if e.kind_of?(Array)
e.map { |f| f.to_a.join }.join(", ")
else
e.to_a.join
end
end.join("\n")
end
def map_diffs(diffs, klass = Diff::LCS::ContextChange)
diffs.map do |chunks|
if klass == Diff::LCS::ContextChange
klass.from_a(chunks)
else
chunks.map { |changes| klass.from_a(changes) }
end
end
end
def balanced_traversal(s1, s2, callback_type)
callback = __send__(callback_type)
Diff::LCS.traverse_balanced(s1, s2, callback)
callback
end
def balanced_reverse(change_result)
new_result = []
change_result.each { |line|
line = [ line[0], line[2], line[1] ]
case line[0]
when '<'
line[0] = '>'
when '>'
line[0] = '<'
end
new_result << line
}
new_result.sort_by { |line| [ line[1], line[2] ] }
end
def map_to_no_change(change_result)
new_result = []
change_result.each { |line|
case line[0]
when '!'
new_result << [ '<', line[1], line[2] ]
new_result << [ '>', line[1] + 1, line[2] ]
else
new_result << line
end
}
new_result
end
def simple_callback
callbacks = Object.new
class << callbacks
attr_reader :matched_a
attr_reader :matched_b
attr_reader :discards_a
attr_reader :discards_b
attr_reader :done_a
attr_reader :done_b
def reset
@matched_a = []
@matched_b = []
@discards_a = []
@discards_b = []
@done_a = []
@done_b = []
end
def match(event)
@matched_a << event.old_element
@matched_b << event.new_element
end
def discard_b(event)
@discards_b << event.new_element
end
def discard_a(event)
@discards_a << event.old_element
end
def finished_a(event)
@done_a << [event.old_element, event.old_position,
event.new_element, event.new_position]
end
def finished_b(event)
p "called #finished_b"
@done_b << [event.old_element, event.old_position,
event.new_element, event.new_position]
end
end
callbacks.reset
callbacks
end
def simple_callback_no_finishers
simple = simple_callback
class << simple
undef :finished_a
undef :finished_b
end
simple
end
def balanced_callback
cb = Object.new
class << cb
attr_reader :result
def reset
@result = []
end
def match(event)
@result << [ "=", event.old_position, event.new_position ]
end
def discard_a(event)
@result << [ "<", event.old_position, event.new_position ]
end
def discard_b(event)
@result << [ ">", event.old_position, event.new_position ]
end
def change(event)
@result << [ "!", event.old_position, event.new_position ]
end
end
cb.reset
cb
end
def balanced_callback_no_change
balanced = balanced_callback
class << balanced
undef :change
end
balanced
end
module Matchers
extend RSpec::Matchers::DSL
matcher :be_nil_or_match_values do |ii, s1, s2|
match do |ee|
ee.should satisfy { |vee| vee.nil? || s1[ii] == s2[ee] }
end
end
matcher :correctly_map_sequence do |s1|
match do |actual|
actual.each_with_index { |ee, ii|
ee.should be_nil_or_match_values(ii, s1, @s2)
}
end
chain :to_other_sequence do |s2|
@s2 = s2
end
end
end
end
RSpec.configure do |conf|
conf.include Diff::LCS::SpecHelper
conf.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
conf.filter_run_excluding :broken => true
end
diff-lcs-1.2.4/spec/issues_spec.rb 0000644 0000041 0000041 00000001237 12142203755 017045 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe "Diff::LCS Issues" do
include Diff::LCS::SpecHelper::Matchers
it "should not fail to provide a simple patchset (issue 1)" do
s1, s2 = *%W(aX bXaX)
correct_forward_diff = [
[ [ '+', 0, 'b' ],
[ '+', 1, 'X' ] ],
]
diff_s1_s2 = Diff::LCS.diff(s1, s2)
change_diff(correct_forward_diff).should == diff_s1_s2
expect do
Diff::LCS.patch(s1, diff_s1_s2).should == s2
end.to_not raise_error(RuntimeError, /provided patchset/)
expect do
Diff::LCS.patch(s2, diff_s1_s2).should == s1
end.to_not raise_error(RuntimeError, /provided patchset/)
end
end
diff-lcs-1.2.4/spec/change_spec.rb 0000644 0000041 0000041 00000003575 12142203755 016766 0 ustar www-data www-data # -*- ruby encoding: utf-8 -*-
require 'spec_helper'
describe Diff::LCS::Change do
describe "an add" do
subject { described_class.new('+', 0, 'element') }
it { should_not be_deleting }
it { should be_adding }
it { should_not be_unchanged }
it { should_not be_changed }
it { should_not be_finished_a }
it { should_not be_finished_b }
end
describe "a delete" do
subject { described_class.new('-', 0, 'element') }
it { should be_deleting }
it { should_not be_adding }
it { should_not be_unchanged }
it { should_not be_changed }
it { should_not be_finished_a }
it { should_not be_finished_b }
end
describe "an unchanged" do
subject { described_class.new('=', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
it { should be_unchanged }
it { should_not be_changed }
it { should_not be_finished_a }
it { should_not be_finished_b }
end
describe "a changed" do
subject { described_class.new('!', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
it { should_not be_unchanged }
it { should be_changed }
it { should_not be_finished_a }
it { should_not be_finished_b }
end
describe "a finished_a" do
subject { described_class.new('>', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
it { should_not be_unchanged }
it { should_not be_changed }
it { should be_finished_a }
it { should_not be_finished_b }
end
describe "a finished_b" do
subject { described_class.new('<', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
it { should_not be_unchanged }
it { should_not be_changed }
it { should_not be_finished_a }
it { should be_finished_b }
end
end
diff-lcs-1.2.4/.rspec 0000644 0000041 0000041 00000000040 12142203755 014345 0 ustar www-data www-data --colour
--format documentation
diff-lcs-1.2.4/docs/ 0000755 0000041 0000041 00000000000 12142203755 014166 5 ustar www-data www-data diff-lcs-1.2.4/docs/COPYING.txt 0000644 0000041 0000041 00000043254 12142203755 016047 0 ustar www-data www-data GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
diff-lcs-1.2.4/docs/artistic.txt 0000644 0000041 0000041 00000013727 12142203755 016563 0 ustar www-data www-data The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
diff-lcs-1.2.4/.hoerc 0000644 0000041 0000041 00000000161 12142203755 014335 0 ustar www-data www-data ---
exclude: !ruby/regexp /(tmp|swp)$|CVS|TAGS|\.(svn|git|hg|DS_Store|idea)|Gemfile\.lock|research\/|\.gemspec$/
diff-lcs-1.2.4/.gemtest 0000644 0000041 0000041 00000000000 12142203755 014675 0 ustar www-data www-data diff-lcs-1.2.4/autotest/ 0000755 0000041 0000041 00000000000 12142203755 015106 5 ustar www-data www-data diff-lcs-1.2.4/autotest/discover.rb 0000644 0000041 0000041 00000000044 12142203755 017247 0 ustar www-data www-data Autotest.add_discovery { "rspec2" }
diff-lcs-1.2.4/bin/ 0000755 0000041 0000041 00000000000 12142203755 014006 5 ustar www-data www-data diff-lcs-1.2.4/bin/ldiff 0000755 0000041 0000041 00000000130 12142203755 015012 0 ustar www-data www-data #!ruby -w
require 'diff/lcs'
require 'diff/lcs/ldiff'
exit Diff::LCS::Ldiff.run(ARGV)
diff-lcs-1.2.4/bin/htmldiff 0000755 0000041 0000041 00000001210 12142203755 015523 0 ustar www-data www-data #!ruby -w
require 'diff/lcs'
require 'diff/lcs/htmldiff'
begin
require 'text/format'
rescue LoadError
Diff::LCS::HTMLDiff.can_expand_tabs = false
end
if ARGV.size < 2 or ARGV.size > 3
$stderr.puts "usage: #{File.basename($0)} old new [output.html]"
$stderr.puts " #{File.basename($0)} old new > output.html"
exit 127
end
left = IO.read(ARGV[0]).split($/)
right = IO.read(ARGV[1]).split($/)
options = { :title => "diff #{ARGV[0]} #{ARGV[1]}" }
htmldiff = Diff::LCS::HTMLDiff.new(left, right, options)
if ARGV[2]
File.open(ARGV[2], "w") do |f|
htmldiff.options[:output] = f
htmldiff.run
end
else
htmldiff.run
end
diff-lcs-1.2.4/metadata.yml 0000644 0000041 0000041 00000017763 12142203755 015557 0 ustar www-data www-data --- !ruby/object:Gem::Specification
name: diff-lcs
version: !ruby/object:Gem::Version
version: 1.2.4
prerelease:
platform: ruby
authors:
- Austin Ziegler
autorequire:
bindir: bin
cert_chain:
- ! '-----BEGIN CERTIFICATE-----
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZhdXN0
aW4xGTAXBgoJkiaJk/IsZAEZFglydWJ5Zm9yZ2UxEzARBgoJkiaJk/IsZAEZFgNv
cmcwHhcNMTMwMjA0MDMzMzI3WhcNMTQwMjA0MDMzMzI3WjBBMQ8wDQYDVQQDDAZh
dXN0aW4xGTAXBgoJkiaJk/IsZAEZFglydWJ5Zm9yZ2UxEzARBgoJkiaJk/IsZAEZ
FgNvcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2mPNf4L37GhKI
SPCYsvYWXA2/R9u5+pyUnbJ2R1o2CiRq2ZA/AIzY6N3hGnsgoWnh5RzvgTN1Lt08
DNIrsIG2VDYk/JVt6f9J6zZ8EQHbznWa3cWYoCFaaICdk7jV1n/42hg70jEDYXl9
gDOl0k6JmyF/rtfFu/OIkFGWeFYIuFHvRuLyUbw66+QDTOzKb3t8o55Ihgy1GVwT
i6pkDs8LhZWXdOD+921l2Z1NZGZa9KNbJIg6vtgYKU98jQ5qr9iY3ikBAspHrFas
K6USvGgAg8fCD5YiotBEvCBMYtfqmfrhpdU2p+gvTgeLW1Kaevwqd7ngQmFUrFG1
eUJSURv5AgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFAtJKMp6YYNqlgR3
9TiZLWqvLagSMAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEApTPkvDm8
7gJlUT4FfumXPvtuqP67LxUtGE8syvR0A4As+0P/wylLJFUOsGTTdZYtThhxCSJG
+7KG2FfIcH4Zz2d97arZGAzBoi8iPht2/UtSl1fCcUI5vmJa1MiXZT2oqdW7Wydq
rAZcBPlrYYuiwtGI0yqIOgBfXSZCWWsJsuyTKELep6mCLgz0YZUfmvKr8W/Ab3ax
DuLzH92LSRjZJyjyAUpw/Vc2rM4giiP5jtByrb1Y1dGnQhHTMHf1GfucWm7Nw/V9
twEPVw8+0f88JQucxOTmTF1NbLFpiRwQUZ1zoZbNg2e7mShc/eexnVLWKFKxRoP6
KPj3WoD+spB8fA==
-----END CERTIFICATE-----
'
date: 2013-04-21 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rubyforge
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: 2.0.4
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: 2.0.4
- !ruby/object:Gem::Dependency
name: rdoc
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '4.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '4.0'
- !ruby/object:Gem::Dependency
name: hoe-bundler
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.2'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.2'
- !ruby/object:Gem::Dependency
name: hoe-doofus
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.0'
- !ruby/object:Gem::Dependency
name: hoe-gemspec2
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.1'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.1'
- !ruby/object:Gem::Dependency
name: hoe-git
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.5'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.5'
- !ruby/object:Gem::Dependency
name: hoe-rubygems
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.0'
- !ruby/object:Gem::Dependency
name: hoe-travis
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.2'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.2'
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '10.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '10.0'
- !ruby/object:Gem::Dependency
name: rspec
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '2.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '2.0'
- !ruby/object:Gem::Dependency
name: hoe
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '3.6'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '3.6'
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}[https://github.com/rubinius/rubinius/issues/2268]).
We are happy to report that this issue has been resolved.'
email:
- austin@rubyforge.org
executables:
- htmldiff
- ldiff
extensions: []
extra_rdoc_files:
- Contributing.rdoc
- History.rdoc
- License.rdoc
- Manifest.txt
- README.rdoc
- docs/COPYING.txt
- docs/artistic.txt
files:
- .autotest
- .gemtest
- .hoerc
- .rspec
- .travis.yml
- Contributing.rdoc
- Gemfile
- History.rdoc
- License.rdoc
- Manifest.txt
- README.rdoc
- Rakefile
- autotest/discover.rb
- bin/htmldiff
- bin/ldiff
- docs/COPYING.txt
- docs/artistic.txt
- lib/diff-lcs.rb
- lib/diff/lcs.rb
- lib/diff/lcs/array.rb
- lib/diff/lcs/block.rb
- lib/diff/lcs/callbacks.rb
- lib/diff/lcs/change.rb
- lib/diff/lcs/htmldiff.rb
- lib/diff/lcs/hunk.rb
- lib/diff/lcs/internals.rb
- lib/diff/lcs/ldiff.rb
- lib/diff/lcs/string.rb
- spec/change_spec.rb
- spec/diff_spec.rb
- spec/hunk_spec.rb
- spec/issues_spec.rb
- spec/lcs_spec.rb
- spec/patch_spec.rb
- spec/sdiff_spec.rb
- spec/spec_helper.rb
- spec/traverse_balanced_spec.rb
- spec/traverse_sequences_spec.rb
homepage: http://diff-lcs.rubyforge.org/
licenses: []
post_install_message:
rdoc_options:
- --main
- README.rdoc
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project: diff-lcs
rubygems_version: 1.8.25
signing_key:
specification_version: 3
summary: Diff::LCS computes the difference between two Enumerable sequences using
the McIlroy-Hunt longest common subsequence (LCS) algorithm
test_files: []
diff-lcs-1.2.4/metadata.gz.sig 0000644 0000041 0000041 00000000400 12142203755 016133 0 ustar www-data www-data M)jZڀ[T'FXHɪ0ǧo*Ҷ| ˌ0x~/i~oU/V$iP/;-EwfdzcoF>i'S@OWʄzJfAW,,qC
IY<ZS9wمERNw?OLs?X+%X`>|Ր diff-lcs-1.2.4/Gemfile 0000644 0000041 0000041 00000001414 12142203755 014531 0 ustar www-data www-data # -*- ruby -*-
# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
source "https://rubygems.org/"
gem "rubyforge", ">=2.0.4", :group => [:development, :test]
gem "rdoc", "~>4.0", :group => [:development, :test]
gem "hoe-bundler", "~>1.2", :group => [:development, :test]
gem "hoe-doofus", "~>1.0", :group => [:development, :test]
gem "hoe-gemspec2", "~>1.1", :group => [:development, :test]
gem "hoe-git", "~>1.5", :group => [:development, :test]
gem "hoe-rubygems", "~>1.0", :group => [:development, :test]
gem "hoe-travis", "~>1.2", :group => [:development, :test]
gem "rake", "~>10.0", :group => [:development, :test]
gem "rspec", "~>2.0", :group => [:development, :test]
gem "hoe", "~>3.6", :group => [:development, :test]
# vim: syntax=ruby
diff-lcs-1.2.4/Manifest.txt 0000644 0000041 0000041 00000001232 12142203755 015543 0 ustar www-data www-data .autotest
.gemtest
.hoerc
.rspec
.travis.yml
Contributing.rdoc
Gemfile
History.rdoc
License.rdoc
Manifest.txt
README.rdoc
Rakefile
autotest/discover.rb
bin/htmldiff
bin/ldiff
docs/COPYING.txt
docs/artistic.txt
lib/diff-lcs.rb
lib/diff/lcs.rb
lib/diff/lcs/array.rb
lib/diff/lcs/block.rb
lib/diff/lcs/callbacks.rb
lib/diff/lcs/change.rb
lib/diff/lcs/htmldiff.rb
lib/diff/lcs/hunk.rb
lib/diff/lcs/internals.rb
lib/diff/lcs/ldiff.rb
lib/diff/lcs/string.rb
spec/change_spec.rb
spec/diff_spec.rb
spec/hunk_spec.rb
spec/issues_spec.rb
spec/lcs_spec.rb
spec/patch_spec.rb
spec/sdiff_spec.rb
spec/spec_helper.rb
spec/traverse_balanced_spec.rb
spec/traverse_sequences_spec.rb
diff-lcs-1.2.4/data.tar.gz.sig 0000644 0000041 0000041 00000000400 12142203755 016051 0 ustar www-data www-data KT*VGݢpοyMb#ܝtᮣsE-zZo7=5+[Ŭ:ӾFwϮ-f߁S80sKuo2*HV]$F}+
=sJ?
{,Fm==كڀb2{dmɌBf_&t
FZU