difflcs 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -165
- data/README.md +69 -0
- data/Rakefile +6 -89
- data/difflcs.gemspec +23 -0
- data/lib/diff_l_c_s.rb +4 -22
- data/lib/diff_l_c_s/counter.rb +0 -13
- data/lib/diff_l_c_s/string.rb +0 -13
- data/lib/diff_l_c_s/version.rb +1 -7
- data/lib/diff_l_c_s/word_split_array.rb +0 -14
- data/test/helper.rb +3 -0
- data/test/{counter_test.rb → test_counter.rb} +2 -14
- data/test/{diff_l_c_s_test.rb → test_diff_l_c_s.rb} +4 -16
- data/test/{word_split_array_test.rb → test_word_split_array.rb} +2 -14
- metadata +84 -24
- data/README +0 -92
- data/install.rb +0 -30
- data/test/test_helper.rb +0 -3
data/CHANGELOG
CHANGED
data/Gemfile
ADDED
data/LICENSE
CHANGED
@@ -1,165 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
of this
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
by the Library, but which is not otherwise based on the Library.
|
24
|
-
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
-
of using an interface provided by the Library.
|
26
|
-
|
27
|
-
A "Combined Work" is a work produced by combining or linking an
|
28
|
-
Application with the Library. The particular version of the Library
|
29
|
-
with which the Combined Work was made is also called the "Linked
|
30
|
-
Version".
|
31
|
-
|
32
|
-
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
-
Corresponding Source for the Combined Work, excluding any source code
|
34
|
-
for portions of the Combined Work that, considered in isolation, are
|
35
|
-
based on the Application, and not on the Linked Version.
|
36
|
-
|
37
|
-
The "Corresponding Application Code" for a Combined Work means the
|
38
|
-
object code and/or source code for the Application, including any data
|
39
|
-
and utility programs needed for reproducing the Combined Work from the
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
41
|
-
|
42
|
-
1. Exception to Section 3 of the GNU GPL.
|
43
|
-
|
44
|
-
You may convey a covered work under sections 3 and 4 of this License
|
45
|
-
without being bound by section 3 of the GNU GPL.
|
46
|
-
|
47
|
-
2. Conveying Modified Versions.
|
48
|
-
|
49
|
-
If you modify a copy of the Library, and, in your modifications, a
|
50
|
-
facility refers to a function or data to be supplied by an Application
|
51
|
-
that uses the facility (other than as an argument passed when the
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
53
|
-
version:
|
54
|
-
|
55
|
-
a) under this License, provided that you make a good faith effort to
|
56
|
-
ensure that, in the event an Application does not supply the
|
57
|
-
function or data, the facility still operates, and performs
|
58
|
-
whatever part of its purpose remains meaningful, or
|
59
|
-
|
60
|
-
b) under the GNU GPL, with none of the additional permissions of
|
61
|
-
this License applicable to that copy.
|
62
|
-
|
63
|
-
3. Object Code Incorporating Material from Library Header Files.
|
64
|
-
|
65
|
-
The object code form of an Application may incorporate material from
|
66
|
-
a header file that is part of the Library. You may convey such object
|
67
|
-
code under terms of your choice, provided that, if the incorporated
|
68
|
-
material is not limited to numerical parameters, data structure
|
69
|
-
layouts and accessors, or small macros, inline functions and templates
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
71
|
-
|
72
|
-
a) Give prominent notice with each copy of the object code that the
|
73
|
-
Library is used in it and that the Library and its use are
|
74
|
-
covered by this License.
|
75
|
-
|
76
|
-
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
-
document.
|
78
|
-
|
79
|
-
4. Combined Works.
|
80
|
-
|
81
|
-
You may convey a Combined Work under terms of your choice that,
|
82
|
-
taken together, effectively do not restrict modification of the
|
83
|
-
portions of the Library contained in the Combined Work and reverse
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
85
|
-
the following:
|
86
|
-
|
87
|
-
a) Give prominent notice with each copy of the Combined Work that
|
88
|
-
the Library is used in it and that the Library and its use are
|
89
|
-
covered by this License.
|
90
|
-
|
91
|
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
-
document.
|
93
|
-
|
94
|
-
c) For a Combined Work that displays copyright notices during
|
95
|
-
execution, include the copyright notice for the Library among
|
96
|
-
these notices, as well as a reference directing the user to the
|
97
|
-
copies of the GNU GPL and this license document.
|
98
|
-
|
99
|
-
d) Do one of the following:
|
100
|
-
|
101
|
-
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
-
License, and the Corresponding Application Code in a form
|
103
|
-
suitable for, and under terms that permit, the user to
|
104
|
-
recombine or relink the Application with a modified version of
|
105
|
-
the Linked Version to produce a modified Combined Work, in the
|
106
|
-
manner specified by section 6 of the GNU GPL for conveying
|
107
|
-
Corresponding Source.
|
108
|
-
|
109
|
-
1) Use a suitable shared library mechanism for linking with the
|
110
|
-
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
-
a copy of the Library already present on the user's computer
|
112
|
-
system, and (b) will operate properly with a modified version
|
113
|
-
of the Library that is interface-compatible with the Linked
|
114
|
-
Version.
|
115
|
-
|
116
|
-
e) Provide Installation Information, but only if you would otherwise
|
117
|
-
be required to provide such information under section 6 of the
|
118
|
-
GNU GPL, and only to the extent that such information is
|
119
|
-
necessary to install and execute a modified version of the
|
120
|
-
Combined Work produced by recombining or relinking the
|
121
|
-
Application with a modified version of the Linked Version. (If
|
122
|
-
you use option 4d0, the Installation Information must accompany
|
123
|
-
the Minimal Corresponding Source and Corresponding Application
|
124
|
-
Code. If you use option 4d1, you must provide the Installation
|
125
|
-
Information in the manner specified by section 6 of the GNU GPL
|
126
|
-
for conveying Corresponding Source.)
|
127
|
-
|
128
|
-
5. Combined Libraries.
|
129
|
-
|
130
|
-
You may place library facilities that are a work based on the
|
131
|
-
Library side by side in a single library together with other library
|
132
|
-
facilities that are not Applications and are not covered by this
|
133
|
-
License, and convey such a combined library under terms of your
|
134
|
-
choice, if you do both of the following:
|
135
|
-
|
136
|
-
a) Accompany the combined library with a copy of the same work based
|
137
|
-
on the Library, uncombined with any other library facilities,
|
138
|
-
conveyed under the terms of this License.
|
139
|
-
|
140
|
-
b) Give prominent notice with the combined library that part of it
|
141
|
-
is a work based on the Library, and explaining where to find the
|
142
|
-
accompanying uncombined form of the same work.
|
143
|
-
|
144
|
-
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
-
|
146
|
-
The Free Software Foundation may publish revised and/or new versions
|
147
|
-
of the GNU Lesser General Public License from time to time. Such new
|
148
|
-
versions will be similar in spirit to the present version, but may
|
149
|
-
differ in detail to address new problems or concerns.
|
150
|
-
|
151
|
-
Each version is given a distinguishing version number. If the
|
152
|
-
Library as you received it specifies that a certain numbered version
|
153
|
-
of the GNU Lesser General Public License "or any later version"
|
154
|
-
applies to it, you have the option of following the terms and
|
155
|
-
conditions either of that published version or of any later version
|
156
|
-
published by the Free Software Foundation. If the Library as you
|
157
|
-
received it does not specify a version number of the GNU Lesser
|
158
|
-
General Public License, you may choose any version of the GNU Lesser
|
159
|
-
General Public License ever published by the Free Software Foundation.
|
160
|
-
|
161
|
-
If the Library as you received it specifies that a proxy can decide
|
162
|
-
whether future versions of the GNU Lesser General Public License shall
|
163
|
-
apply, that proxy's public statement of acceptance of any version is
|
164
|
-
permanent authorization for you to choose that version for the
|
165
|
-
Library.
|
1
|
+
Copyright: (c) 2006-2012 Wybo Wiersma <mail@wybowiersma.net>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Diff Longest Common Sub String
|
2
|
+
"The diff sniffing out texts every move"
|
3
|
+
|
4
|
+
A resonably fast diff algoritm using longest common substrings that
|
5
|
+
can also detect text that has moved.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
First require it.
|
10
|
+
|
11
|
+
$ irb
|
12
|
+
|
13
|
+
> require 'rubygems'
|
14
|
+
> require 'difflcs'
|
15
|
+
|
16
|
+
Then it can be used on any set of arrays, in this example 123456789
|
17
|
+
and 120678934, of which the first '12' overlaps, '0' is new, '34' has
|
18
|
+
moved to the end, and '6789' overlaps too, but moved 2 positions to
|
19
|
+
the left.
|
20
|
+
|
21
|
+
NOTE: They are arrays, not strings.
|
22
|
+
|
23
|
+
> DiffLCS.diff('123456789'.split(''), '120678934'.split(''))
|
24
|
+
=> {
|
25
|
+
:matched_old=>[0...2, 5...9, 2...4],
|
26
|
+
:matched_new=>[0...2, 3...7, 7...9]
|
27
|
+
}
|
28
|
+
|
29
|
+
As you see it can sniff out text that has moved too.
|
30
|
+
|
31
|
+
A minimum overlap size can be provided for speed purposes, and to
|
32
|
+
prevent too many matches;
|
33
|
+
|
34
|
+
> DiffLCS.diff('123456789'.split(''), '120678934'.split(''), :minimum_lcs_size => 3)
|
35
|
+
=> {
|
36
|
+
:matched_old => PositionRange::List.from_s('5,9'),
|
37
|
+
:matched_new => PositionRange::List.from_s('3,7')
|
38
|
+
}
|
39
|
+
|
40
|
+
Diff can be called directly on strings too, if 'diff_l_c_s/string' is required.
|
41
|
+
|
42
|
+
> require 'diff_l_c_s/string'
|
43
|
+
> '123'.diff('321')
|
44
|
+
=> {
|
45
|
+
:matched_old=>[2...3, 1...2, 0...1],
|
46
|
+
:matched_new=>[0...1, 1...2, 2...3]
|
47
|
+
}
|
48
|
+
|
49
|
+
## Installation
|
50
|
+
|
51
|
+
Add this line to your application's Gemfile:
|
52
|
+
|
53
|
+
gem 'difflcs'
|
54
|
+
|
55
|
+
And then execute:
|
56
|
+
|
57
|
+
$ bundle
|
58
|
+
|
59
|
+
Or install it yourself as:
|
60
|
+
|
61
|
+
$ gem install difflcs
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,93 +1,10 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
3
|
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
require 'rake/packagetask'
|
6
|
-
require 'rake/gempackagetask'
|
7
|
-
require 'rake/contrib/sshpublisher'
|
8
|
-
require File.join(File.dirname(__FILE__), 'lib', 'diff_l_c_s', 'version')
|
9
4
|
|
10
|
-
|
11
|
-
PKG_NAME = 'difflcs'
|
12
|
-
PKG_VERSION = DiffLCS::VERSION::STRING + PKG_BUILD
|
13
|
-
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
5
|
+
task :default => :test
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
RUBY_FORGE_USER = "wybo"
|
19
|
-
|
20
|
-
desc "Default Task"
|
21
|
-
task :default => [ :test ]
|
22
|
-
|
23
|
-
# Run the unit tests
|
24
|
-
Rake::TestTask.new { |t|
|
25
|
-
t.libs << "test"
|
26
|
-
t.pattern = 'test/*_test.rb'
|
27
|
-
t.verbose = true
|
28
|
-
t.warning = false
|
29
|
-
}
|
30
|
-
|
31
|
-
# Generate the RDoc documentation
|
32
|
-
Rake::RDocTask.new { |rdoc|
|
33
|
-
rdoc.rdoc_dir = 'doc'
|
34
|
-
rdoc.title = "Diff Longest Common Substring -- The diff sniffing out every move"
|
35
|
-
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
36
|
-
rdoc.options << '--charset' << 'utf-8'
|
37
|
-
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
38
|
-
rdoc.rdoc_files.include('lib/diff_l_c_s.rb')
|
39
|
-
rdoc.rdoc_files.include('lib/diff_l_c_s/*.rb')
|
40
|
-
}
|
41
|
-
|
42
|
-
# Create compressed packages
|
43
|
-
spec = Gem::Specification.new do |s|
|
44
|
-
s.platform = Gem::Platform::RUBY
|
45
|
-
s.name = PKG_NAME
|
46
|
-
s.summary = "Diffing that sniffs out moved text."
|
47
|
-
s.description = %q{A diff algoritm using longest common substrings that can also find text that has moved.}
|
48
|
-
s.version = PKG_VERSION
|
49
|
-
|
50
|
-
s.author = "Wybo Wiersma"
|
51
|
-
s.email = "wybo@logilogi.org"
|
52
|
-
s.rubyforge_project = "difflcs"
|
53
|
-
s.homepage = "http://difflcs.rubyforge.org"
|
54
|
-
|
55
|
-
s.add_dependency('positionrange', '>= 0.6.0' + PKG_BUILD)
|
56
|
-
|
57
|
-
s.has_rdoc = true
|
58
|
-
s.requirements << 'none'
|
59
|
-
s.require_path = 'lib'
|
60
|
-
|
61
|
-
s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG", "LICENSE" ]
|
62
|
-
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
63
|
-
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
64
|
-
end
|
65
|
-
|
66
|
-
Rake::GemPackageTask.new(spec) do |p|
|
67
|
-
p.gem_spec = spec
|
68
|
-
p.need_tar = true
|
69
|
-
p.need_zip = true
|
70
|
-
end
|
71
|
-
|
72
|
-
desc "Publish the docs, gem, and release files"
|
73
|
-
task :deploy => [:release, :pdoc] do
|
74
|
-
puts 'Published gem'
|
75
|
-
end
|
76
|
-
|
77
|
-
desc "Publish the API documentation"
|
78
|
-
task :pdoc => [:rdoc] do
|
79
|
-
sh "rsync -azv --no-perms --no-times doc/*" +
|
80
|
-
" rubyforge.org:/var/www/gforge-projects/difflcs"
|
81
|
-
end
|
82
|
-
|
83
|
-
desc "Publish the release files to RubyForge."
|
84
|
-
task :release => [ :package ] do
|
85
|
-
require 'rubyforge'
|
86
|
-
require 'rake/contrib/rubyforgepublisher'
|
87
|
-
|
88
|
-
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
89
|
-
|
90
|
-
rubyforge = RubyForge.new.configure
|
91
|
-
rubyforge.login
|
92
|
-
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
7
|
+
require 'rake/testtask'
|
8
|
+
Rake::TestTask.new do |test|
|
9
|
+
test.libs << 'lib' << 'test'
|
93
10
|
end
|
data/difflcs.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/diff_l_c_s/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Wybo Wiersma"]
|
6
|
+
gem.email = ["mail@wybowiersma.net"]
|
7
|
+
gem.description = "A resonably fast diff algoritm using longest common substrings that can also detect text that has moved"
|
8
|
+
gem.summary = "Diff algoritm that can detect text that has moved"
|
9
|
+
gem.homepage = "https://github.com/wybo/difflcs"
|
10
|
+
gem.rubyforge_project = "difflcs"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.test_files = gem.files.grep(%r{^test/.*_test.rb})
|
14
|
+
gem.name = "difflcs"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = DiffLCS::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rake"
|
19
|
+
gem.add_development_dependency "test-unit"
|
20
|
+
|
21
|
+
gem.add_dependency "positionrange"
|
22
|
+
gem.add_dependency "require_relative"
|
23
|
+
end
|
data/lib/diff_l_c_s.rb
CHANGED
@@ -1,29 +1,11 @@
|
|
1
1
|
#--#
|
2
|
-
# Copyright: (c) 2006-
|
2
|
+
# Copyright: (c) 2006-2012 Wybo Wiersma <mail@wybowiersma.net>
|
3
3
|
#
|
4
|
-
#
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
4
|
+
# MIT Licensed
|
12
5
|
#++#
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
unless defined?(PositionRange)
|
18
|
-
begin
|
19
|
-
$:.unshift(File.dirname(__FILE__) + "/../../positionrange/lib")
|
20
|
-
require 'position_range'
|
21
|
-
rescue LoadError
|
22
|
-
require 'rubygems'
|
23
|
-
gem 'positionrange'
|
24
|
-
require 'position_range'
|
25
|
-
end
|
26
|
-
end
|
7
|
+
require "diff_l_c_s/version"
|
8
|
+
require 'position_range'
|
27
9
|
|
28
10
|
module DiffLCS
|
29
11
|
# Diffs self with other, see DiffLCS#diff
|
data/lib/diff_l_c_s/counter.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
#--#
|
2
|
-
# Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
-
#
|
4
|
-
# License:
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
12
|
-
#++#
|
13
|
-
|
14
1
|
class DiffLCS::Counter
|
15
2
|
include Comparable
|
16
3
|
|
data/lib/diff_l_c_s/string.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
#--#
|
2
|
-
# Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
-
#
|
4
|
-
# License:
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
12
|
-
#++#
|
13
|
-
|
14
1
|
require 'diff_l_c_s'
|
15
2
|
|
16
3
|
class String
|
data/lib/diff_l_c_s/version.rb
CHANGED
@@ -1,18 +1,4 @@
|
|
1
|
-
#--#
|
2
|
-
# Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
-
#
|
4
|
-
# License:
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
12
|
-
#++#
|
13
|
-
|
14
1
|
class DiffLCS::WordSplitArray < Array
|
15
|
-
|
16
2
|
### Constants
|
17
3
|
|
18
4
|
# Used as a separator
|
data/test/helper.rb
ADDED
@@ -1,17 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
# License:
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
12
|
-
#++#
|
13
|
-
|
14
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
1
|
+
['rubygems', 'require_relative'].each {|g| require g} if RUBY_VERSION =~ /1\.8/
|
2
|
+
require_relative "helper"
|
15
3
|
|
16
4
|
class CounterTest < Test::Unit::TestCase
|
17
5
|
|
@@ -1,19 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
12
|
-
#++#
|
13
|
-
|
14
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
15
|
-
|
16
|
-
require 'diff_l_c_s/string'
|
1
|
+
['rubygems', 'require_relative'].each {|g| require g} if RUBY_VERSION =~ /1\.8/
|
2
|
+
require_relative "helper"
|
3
|
+
|
4
|
+
require "diff_l_c_s/string"
|
17
5
|
|
18
6
|
class DiffLCSTest < Test::Unit::TestCase
|
19
7
|
### Class methods
|
@@ -1,17 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
# License:
|
5
|
-
# This file is part of the DiffLCS library. DiffLCS is Free Software.
|
6
|
-
# You can run/distribute/modify DiffLCS under the terms of the GNU Affero
|
7
|
-
# General Public License version 3. The Affero GPL states that running a
|
8
|
-
# modified version or a derivative work also requires you to make the
|
9
|
-
# sourcecode of that work available to everyone that can interact with it.
|
10
|
-
# We chose the Affero GPL to ensure that DiffLCS remains open and libre
|
11
|
-
# (LICENSE.txt contains the full text of the legally binding license).
|
12
|
-
#++#
|
13
|
-
|
14
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
1
|
+
['rubygems', 'require_relative'].each {|g| require g} if RUBY_VERSION =~ /1\.8/
|
2
|
+
require_relative "helper"
|
15
3
|
|
16
4
|
class WordSplitArrayTest < Test::Unit::TestCase
|
17
5
|
### Initialization
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: difflcs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Wybo Wiersma
|
@@ -9,21 +15,68 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2012-06-24 00:00:00 -07:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: rake
|
33
|
+
prerelease: false
|
34
|
+
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
version_requirements: *id002
|
46
|
+
name: test-unit
|
47
|
+
prerelease: false
|
48
|
+
type: :development
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
version_requirements: *id003
|
16
60
|
name: positionrange
|
61
|
+
prerelease: false
|
17
62
|
type: :runtime
|
18
|
-
|
19
|
-
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
20
66
|
requirements:
|
21
67
|
- - ">="
|
22
68
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
version_requirements: *id004
|
74
|
+
name: require_relative
|
75
|
+
prerelease: false
|
76
|
+
type: :runtime
|
77
|
+
description: A resonably fast diff algoritm using longest common substrings that can also detect text that has moved
|
78
|
+
email:
|
79
|
+
- mail@wybowiersma.net
|
27
80
|
executables: []
|
28
81
|
|
29
82
|
extensions: []
|
@@ -31,23 +84,24 @@ extensions: []
|
|
31
84
|
extra_rdoc_files: []
|
32
85
|
|
33
86
|
files:
|
34
|
-
- Rakefile
|
35
|
-
- install.rb
|
36
|
-
- README
|
37
87
|
- CHANGELOG
|
88
|
+
- Gemfile
|
38
89
|
- LICENSE
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- difflcs.gemspec
|
39
93
|
- lib/diff_l_c_s.rb
|
40
|
-
- lib/diff_l_c_s/version.rb
|
41
|
-
- lib/diff_l_c_s/string.rb
|
42
94
|
- lib/diff_l_c_s/counter.rb
|
95
|
+
- lib/diff_l_c_s/string.rb
|
96
|
+
- lib/diff_l_c_s/version.rb
|
43
97
|
- lib/diff_l_c_s/word_split_array.rb
|
44
98
|
- lib/difflcs.rb
|
45
|
-
- test/
|
46
|
-
- test/
|
47
|
-
- test/
|
48
|
-
- test/
|
99
|
+
- test/helper.rb
|
100
|
+
- test/test_counter.rb
|
101
|
+
- test/test_diff_l_c_s.rb
|
102
|
+
- test/test_word_split_array.rb
|
49
103
|
has_rdoc: true
|
50
|
-
homepage:
|
104
|
+
homepage: https://github.com/wybo/difflcs
|
51
105
|
licenses: []
|
52
106
|
|
53
107
|
post_install_message:
|
@@ -56,23 +110,29 @@ rdoc_options: []
|
|
56
110
|
require_paths:
|
57
111
|
- lib
|
58
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
59
114
|
requirements:
|
60
115
|
- - ">="
|
61
116
|
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
119
|
+
- 0
|
62
120
|
version: "0"
|
63
|
-
version:
|
64
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
65
123
|
requirements:
|
66
124
|
- - ">="
|
67
125
|
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
68
129
|
version: "0"
|
69
|
-
|
70
|
-
|
71
|
-
- none
|
130
|
+
requirements: []
|
131
|
+
|
72
132
|
rubyforge_project: difflcs
|
73
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.6.2
|
74
134
|
signing_key:
|
75
135
|
specification_version: 3
|
76
|
-
summary:
|
136
|
+
summary: Diff algoritm that can detect text that has moved
|
77
137
|
test_files: []
|
78
138
|
|
data/README
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
= Diff Longest Common Sub String Gem documentation
|
2
|
-
"The diff sniffing out texts every move"
|
3
|
-
|
4
|
-
A resonably fast diff algoritm using longest common substrings that
|
5
|
-
can also find text that has moved.
|
6
|
-
|
7
|
-
PositionRange is a library by the LogiLogi Foundation, extracted from
|
8
|
-
http://www.logilogi.org (http://foundation.logilogi.org).
|
9
|
-
|
10
|
-
== Usage
|
11
|
-
|
12
|
-
First require it.
|
13
|
-
|
14
|
-
$ irb
|
15
|
-
|
16
|
-
> require 'rubygems'
|
17
|
-
> require 'difflcs'
|
18
|
-
|
19
|
-
Then it can be used on any set of arrays, in this example 123456789
|
20
|
-
and 120678934, of which the first '12' overlaps, '0' is new, '34' has
|
21
|
-
moved to the end, and '6789' overlaps too, but moved 2 positions to
|
22
|
-
the left.
|
23
|
-
|
24
|
-
NOTE: They are arrays, not strings.
|
25
|
-
|
26
|
-
> DiffLCS.diff('123456789'.split(''), '120678934'.split(''))
|
27
|
-
=> {
|
28
|
-
:matched_old=>[0...2, 5...9, 2...4],
|
29
|
-
:matched_new=>[0...2, 3...7, 7...9]
|
30
|
-
}
|
31
|
-
|
32
|
-
As you see it can sniff out text that has moved too.
|
33
|
-
|
34
|
-
A minimum overlap size can be provided for speed purposes, and to
|
35
|
-
prevent too many matches;
|
36
|
-
|
37
|
-
> DiffLCS.diff('123456789'.split(''), '120678934'.split(''), :minimum_lcs_size => 3)
|
38
|
-
=> {
|
39
|
-
:matched_old => PositionRange::List.from_s('5,9'),
|
40
|
-
:matched_new => PositionRange::List.from_s('3,7')
|
41
|
-
}
|
42
|
-
|
43
|
-
Diff can be called directly on strings too, if 'diff_l_c_s/string' is required.
|
44
|
-
|
45
|
-
> require 'diff_l_c_s/string'
|
46
|
-
> '123'.diff('321')
|
47
|
-
=> {
|
48
|
-
:matched_old=>[2...3, 1...2, 0...1],
|
49
|
-
:matched_new=>[0...1, 1...2, 2...3]
|
50
|
-
}
|
51
|
-
|
52
|
-
== Installation
|
53
|
-
|
54
|
-
You can install Diff LCS with the following command:
|
55
|
-
|
56
|
-
% [sudo] gem install difflcs
|
57
|
-
|
58
|
-
The latest version of Diff LCS can also be downloaded at:
|
59
|
-
|
60
|
-
* http://rubyforge.org/frs/?group_id=7565
|
61
|
-
|
62
|
-
And then from its distribution directory installed with:
|
63
|
-
|
64
|
-
% [sudo] ruby install.rb
|
65
|
-
|
66
|
-
== Support
|
67
|
-
|
68
|
-
The Diff LCS homepage is http://difflcs.rubyforge.org.
|
69
|
-
|
70
|
-
For the latest news on Diff LCS:
|
71
|
-
|
72
|
-
* http://foundation.logilogi.org/tags/DiffLCS
|
73
|
-
|
74
|
-
Feel free to submit commits or feature requests. If you send a patch,
|
75
|
-
remember to update the corresponding unit tests.
|
76
|
-
|
77
|
-
== This Documentation
|
78
|
-
|
79
|
-
This documentation can be browsed online at:
|
80
|
-
|
81
|
-
* http://difflcs.rubyforge.org
|
82
|
-
|
83
|
-
== Copyrights
|
84
|
-
|
85
|
-
Diff LCS and these docs are Copyright (c) 2006-2009 The LogiLogi
|
86
|
-
Foundation. Diff LCS is licensed under the {GNU Lesser General
|
87
|
-
Public License}[http://www.gnu.org/licenses/lgpl-3.0-standalone.html].
|
88
|
-
These docs are available under the {Creative Commons Attribution-Share
|
89
|
-
Alike License}[http://creativecommons.org/licenses/by-sa/3.0/].
|
90
|
-
|
91
|
-
You can use Diff LCS in an application that is not Free Software
|
92
|
-
but Diff LCS itself remains Free Software.
|
data/install.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'find'
|
3
|
-
require 'ftools'
|
4
|
-
|
5
|
-
include Config
|
6
|
-
|
7
|
-
# this was adapted from rdoc's install.rb by way of Log4r
|
8
|
-
|
9
|
-
$sitedir = CONFIG["sitelibdir"]
|
10
|
-
unless $sitedir
|
11
|
-
version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
|
12
|
-
$libdir = File.join(CONFIG["libdir"], "ruby", version)
|
13
|
-
$sitedir = $:.find {|x| x =~ /site_ruby/ }
|
14
|
-
if !$sitedir
|
15
|
-
$sitedir = File.join($libdir, "site_ruby")
|
16
|
-
elsif $sitedir !~ Regexp.quote(version)
|
17
|
-
$sitedir = File.join($sitedir, version)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# the actual gruntwork
|
22
|
-
Dir.chdir("lib")
|
23
|
-
|
24
|
-
Find.find("diff_l_c_s", "diff_l_c_s.rb") { |f|
|
25
|
-
if f[-3..-1] == ".rb"
|
26
|
-
File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
|
27
|
-
else
|
28
|
-
File::makedirs(File.join($sitedir, *f.split(/\//)))
|
29
|
-
end
|
30
|
-
}
|
data/test/test_helper.rb
DELETED