docdiff 0.5.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +5 -3
- data/Gemfile +1 -1
- data/Makefile +15 -19
- data/Rakefile +45 -10
- data/bin/docdiff +25 -13
- data/devutil/Rakefile +9 -0
- data/devutil/changelog.sh +40 -0
- data/docdiff.gemspec +4 -4
- data/docdiffwebui.cgi +1 -1
- data/langfilter.rb +1 -5
- data/lib/doc_diff.rb +5 -1
- data/lib/docdiff/charstring.rb +10 -285
- data/lib/docdiff/diff/contours.rb +2 -1
- data/lib/docdiff/diff/editscript.rb +2 -0
- data/lib/docdiff/diff/rcsdiff.rb +2 -0
- data/lib/docdiff/diff/shortestpath.rb +2 -0
- data/lib/docdiff/diff/speculative.rb +6 -3
- data/lib/docdiff/diff/subsequence.rb +2 -0
- data/lib/docdiff/diff/unidiff.rb +2 -1
- data/lib/docdiff/diff.rb +2 -0
- data/lib/docdiff/difference.rb +2 -0
- data/lib/docdiff/document.rb +2 -0
- data/lib/docdiff/encoding/en_ascii.rb +15 -40
- data/lib/docdiff/encoding/ja_eucjp.rb +15 -40
- data/lib/docdiff/encoding/ja_sjis.rb +15 -40
- data/lib/docdiff/encoding/ja_utf8.rb +15 -40
- data/lib/docdiff/version.rb +1 -1
- data/lib/docdiff/view.rb +16 -14
- data/lib/docdiff.rb +1 -1
- data/readme.html +41 -4
- data/readme.md +185 -0
- data/test/charstring_test.rb +16 -26
- data/test/diff_test.rb +2 -1
- data/test/difference_test.rb +2 -1
- data/test/docdiff_test.rb +12 -3
- data/test/document_test.rb +7 -6
- data/test/view_test.rb +3 -1
- metadata +23 -34
- data/devutil/JIS0208.TXT +0 -6952
- data/lib/viewdiff.rb +0 -375
- data/test/viewdiff_test.rb +0 -908
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 75d0326eaf0ebe880d161beb18ccf549b7965ac0e31131b5ed860b942616d66c
|
|
4
|
+
data.tar.gz: c30d0a6a0a5cb1520d91ebdae8a0997b3ac364072c212a2be5f651b94f7b458b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 970b172f3c9e00967a7cb79113367b7036cf900afdf122f25fc36224dc31550626d7f6f8408ad12ff7fff58e0b91d2ff730b26d58f7603d040a8302d399d78b1
|
|
7
|
+
data.tar.gz: ac729648506f82b4a462d3657247dce15579a26aa247f9166408f8da9b40ff9567df8dc66f1d56fb4f215c82ffcaaac4940cfdd368adb49b57f05f5ff679e4c0
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Makefile
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
# Warning: this Makefile is obsolete, use Rakefile instead
|
|
2
|
+
|
|
1
3
|
PRODUCT = docdiff
|
|
2
|
-
VERSION =
|
|
4
|
+
VERSION = $(shell $(RUBY) -r./lib/docdiff/version.rb -e 'Docdiff::VERSION.display')
|
|
3
5
|
RUBY = ruby
|
|
4
6
|
TAR_XVCS = tar --exclude=.svn --exclude=.git
|
|
5
7
|
|
|
6
8
|
DOCS = ChangeLog readme.en.html readme.ja.html \
|
|
7
9
|
index.en.html index.ja.html
|
|
8
10
|
DOCSRC = readme.html index.html img sample
|
|
9
|
-
TESTS =
|
|
10
|
-
|
|
11
|
-
DIST = Makefile devutil docdiff docdiff.conf.example docdiff.rb \
|
|
11
|
+
TESTS = test/*_test.rb
|
|
12
|
+
DIST = Makefile devutil lib docdiff.conf.example bin/docdiff \
|
|
12
13
|
docdiff.gemspec \
|
|
13
14
|
docdiffwebui.html docdiffwebui.cgi \
|
|
14
15
|
$(DOCSRC) $(DOCS) $(TESTS)
|
|
15
|
-
TESTLOGS =
|
|
16
|
-
|
|
16
|
+
TESTLOGS = $(foreach t,\
|
|
17
|
+
$(wildcard test/*_test.rb),\
|
|
18
|
+
$(t:test/%_test.rb=%_test.log)) \
|
|
17
19
|
|
|
18
20
|
WWWUSER = hisashim,docdiff
|
|
19
21
|
WWWSITE = web.sourceforge.net
|
|
@@ -28,22 +30,16 @@ all: $(DOCS)
|
|
|
28
30
|
|
|
29
31
|
testall:
|
|
30
32
|
$(MAKE) test RUBY=ruby1.9.1
|
|
31
|
-
$(MAKE) test RUBY=ruby1.8
|
|
32
33
|
|
|
33
34
|
test: $(TESTLOGS)
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
$(RUBY) -I
|
|
36
|
+
%_test.log:
|
|
37
|
+
$(RUBY) -I./lib test/$*_test.rb | tee $@
|
|
37
38
|
|
|
38
39
|
docs: $(DOCS)
|
|
39
40
|
|
|
40
41
|
ChangeLog:
|
|
41
|
-
|
|
42
|
-
if [ -d .svn ] ; then \
|
|
43
|
-
svn log -rHEAD:0 -v > ChangeLog ; \
|
|
44
|
-
else \
|
|
45
|
-
git svn log > ChangeLog ; \
|
|
46
|
-
fi
|
|
42
|
+
devutil/changelog.sh > $@
|
|
47
43
|
|
|
48
44
|
readme.%.html: readme.html
|
|
49
45
|
$(RUBY) -Ku langfilter.rb --$* $< > $@
|
|
@@ -54,13 +50,13 @@ install: $(DIST)
|
|
|
54
50
|
@if [ ! -d $(DESTDIR)$(PREFIX)/bin ]; then \
|
|
55
51
|
mkdir -p $(DESTDIR)$(PREFIX)/bin; \
|
|
56
52
|
fi
|
|
57
|
-
cp -Ppv docdiff
|
|
53
|
+
cp -Ppv bin/docdiff $(DESTDIR)$(PREFIX)/bin/
|
|
58
54
|
chmod +x $(DESTDIR)$(PREFIX)/bin/docdiff
|
|
59
55
|
|
|
60
|
-
@if [ ! -d $(datadir)
|
|
61
|
-
mkdir -p $(datadir)
|
|
56
|
+
@if [ ! -d $(datadir)/$(PRODUCT) ]; then \
|
|
57
|
+
mkdir -p $(datadir)/$(PRODUCT); \
|
|
62
58
|
fi
|
|
63
|
-
($(TAR_XVCS) -cf -
|
|
59
|
+
(cd lib && $(TAR_XVCS) -cf - *) | (cd $(datadir)/$(PRODUCT) && tar -xpf -)
|
|
64
60
|
|
|
65
61
|
@if [ ! -d $(DESTDIR)/etc/$(PRODUCT) ]; then \
|
|
66
62
|
mkdir -p $(DESTDIR)/etc/$(PRODUCT); \
|
data/Rakefile
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
|
+
require 'rake/clean'
|
|
2
|
+
require 'rake/testtask'
|
|
1
3
|
require 'bundler/gem_tasks'
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
RUBY = ENV['RUBY'] ||= 'ruby'
|
|
6
|
+
DOCS = FileList['ChangeLog', 'readme.en.html', 'readme.ja.html',
|
|
7
|
+
'index.en.html', 'index.ja.html']
|
|
8
|
+
DOCSRC = FileList['readme.html', 'index.html', 'img', 'sample']
|
|
9
|
+
TESTS = FileList['test/*_test.rb']
|
|
10
|
+
TESTLOGS = Dir.glob('test/*_test.rb').map{|f|
|
|
11
|
+
File.basename(f).ext('log')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
WWWUSER = ENV['WWWUSER'] ||= 'hisashim,docdiff'
|
|
15
|
+
WWWSITE = ENV['WWWSITE'] ||= 'web.sourceforge.net'
|
|
16
|
+
WWWSITEPATH = ENV['WWWSITEPATH'] ||= 'htdocs/'
|
|
17
|
+
WWWDRYRUN = ENV['WWWDRYRUN'] ||= '--dry-run'
|
|
18
|
+
|
|
4
19
|
Rake::TestTask.new do |t|
|
|
5
|
-
t.test_files =
|
|
20
|
+
t.test_files = TESTS
|
|
6
21
|
t.verbose = true
|
|
7
22
|
end
|
|
8
23
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
24
|
+
task :default => :test
|
|
25
|
+
|
|
26
|
+
desc "generate documents"
|
|
27
|
+
task :docs => DOCS
|
|
28
|
+
|
|
29
|
+
file 'ChangeLog' do |t|
|
|
30
|
+
sh "devutil/changelog.sh > #{t.name}"
|
|
17
31
|
end
|
|
32
|
+
|
|
33
|
+
rule(/.*\.(?:en|ja)\.html/ => proc{|tn| tn.gsub(/\.(?:en|ja)/, '')}) do |t|
|
|
34
|
+
sh "#{RUBY} -E UTF-8 langfilter.rb" +
|
|
35
|
+
" --#{t.name.gsub(/.*?\.(en|ja)\.html/){$1}}" +
|
|
36
|
+
" #{t.prerequisites.first} > #{t.name}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc "force to rsync web contents"
|
|
40
|
+
task :wwwupload do |t|
|
|
41
|
+
sh "rake www WWWDRYRUN="
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "rsync web contents"
|
|
45
|
+
task :www => DOCSRC + DOCS do |t|
|
|
46
|
+
sh "rsync #{WWWDRYRUN} -auv -e ssh --delete" +
|
|
47
|
+
" --exclude='.svn' --exclude='.git'" +
|
|
48
|
+
t.prerequisites.join(' ') +
|
|
49
|
+
" #{WWWUSER}@#{WWWSITE}:#{WWWSITEPATH}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
CLEAN.include(DOCS, TESTLOGS)
|
data/bin/docdiff
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# DocDiff: word/character-oriented text comparison utility
|
|
3
3
|
# Copyright (C) 2002-2011 Hisashi MORITA
|
|
4
|
-
# Requirements: Ruby (>=
|
|
4
|
+
# Requirements: Ruby (>= 2.0)
|
|
5
5
|
require 'docdiff'
|
|
6
|
-
require 'docdiff/difference'
|
|
7
|
-
require 'docdiff/document'
|
|
8
|
-
require 'docdiff/view'
|
|
9
6
|
require 'optparse'
|
|
10
7
|
|
|
11
8
|
# do_config_stuff
|
|
@@ -40,7 +37,7 @@ ARGV.options {|o|
|
|
|
40
37
|
o.def_option('--char', 'set resolution to char'){clo[:resolution] = "char"}
|
|
41
38
|
|
|
42
39
|
o.def_option('--encoding=ENCODING',
|
|
43
|
-
possible_encodings = ['ASCII','EUC-JP','Shift_JIS','UTF-8','auto'],
|
|
40
|
+
possible_encodings = ['ASCII','EUC-JP','Shift_JIS','CP932','UTF-8','auto'],
|
|
44
41
|
'specify character encoding',
|
|
45
42
|
possible_encodings.join('|'), "(default is auto. try ASCII for single byte encodings such as ISO-8859-X)"
|
|
46
43
|
){|s| clo[:encoding] = (s || "auto")}
|
|
@@ -48,6 +45,7 @@ ARGV.options {|o|
|
|
|
48
45
|
o.def_option('--iso8859x', 'same as --encoding=ASCII'){clo[:encoding] = "ASCII"}
|
|
49
46
|
o.def_option('--eucjp', 'same as --encoding=EUC-JP'){clo[:encoding] = "EUC-JP"}
|
|
50
47
|
o.def_option('--sjis', 'same as --encoding=Shift_JIS'){clo[:encoding] = "Shift_JIS"}
|
|
48
|
+
o.def_option('--cp932', 'same as --encoding=CP932'){clo[:encoding] = "CP932"}
|
|
51
49
|
o.def_option('--utf8', 'same as --encoding=UTF-8'){clo[:encoding] = "UTF-8"}
|
|
52
50
|
|
|
53
51
|
o.def_option('--eol=EOL',
|
|
@@ -86,6 +84,8 @@ ARGV.options {|o|
|
|
|
86
84
|
o.def_option('--cache', 'use file cache (not supported yet)'){clo[:cache] = true}
|
|
87
85
|
o.def_option('--no-config-file',
|
|
88
86
|
'do not read config files'){clo[:no_config_file] = true}
|
|
87
|
+
o.def_option('--config-file=FILE',
|
|
88
|
+
'specify config file to read'){|s| clo[:config_file] = s}
|
|
89
89
|
o.def_option('--verbose', 'run verbosely (not supported yet)'){clo[:verbose] = true}
|
|
90
90
|
|
|
91
91
|
o.def_option('--help', 'show this message'){puts o; exit(0)}
|
|
@@ -119,6 +119,16 @@ unless clo[:no_config_file] == true # process_commandline_option
|
|
|
119
119
|
STDERR.print message
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
|
+
unless clo[:config_file].nil?
|
|
123
|
+
if File.exist?(clo[:config_file])
|
|
124
|
+
message = docdiff.process_config_file(clo[:config_file])
|
|
125
|
+
else
|
|
126
|
+
raise "#{clo[:config_file]} does not exist."
|
|
127
|
+
end
|
|
128
|
+
if clo[:verbose] == true || docdiff.config[:verbose] == true
|
|
129
|
+
STDERR.pring message
|
|
130
|
+
end
|
|
131
|
+
end
|
|
122
132
|
docdiff.config.update(clo)
|
|
123
133
|
|
|
124
134
|
# config stuff done
|
|
@@ -129,10 +139,12 @@ file1_content = nil
|
|
|
129
139
|
file2_content = nil
|
|
130
140
|
raise "Try `#{File.basename($0)} --help' for more information." if ARGV[0].nil?
|
|
131
141
|
raise "Specify at least 2 target files." unless ARGV[0] && ARGV[1]
|
|
142
|
+
ARGV[0] = "/dev/stdin" if ARGV[0] == "-"
|
|
143
|
+
ARGV[1] = "/dev/stdin" if ARGV[1] == "-"
|
|
132
144
|
raise "No such file: #{ARGV[0]}." unless FileTest.exist?(ARGV[0])
|
|
133
145
|
raise "No such file: #{ARGV[1]}." unless FileTest.exist?(ARGV[1])
|
|
134
|
-
raise "#{ARGV[0]} is not
|
|
135
|
-
raise "#{ARGV[1]} is not
|
|
146
|
+
raise "#{ARGV[0]} is not readable." unless FileTest.readable?(ARGV[0])
|
|
147
|
+
raise "#{ARGV[1]} is not readable." unless FileTest.readable?(ARGV[1])
|
|
136
148
|
File.open(ARGV[0], "r"){|f| file1_content = f.read}
|
|
137
149
|
File.open(ARGV[1], "r"){|f| file2_content = f.read}
|
|
138
150
|
|
|
@@ -145,8 +157,8 @@ eol1 = docdiff.config[:eol]
|
|
|
145
157
|
eol2 = docdiff.config[:eol]
|
|
146
158
|
|
|
147
159
|
if docdiff.config[:encoding] == "auto"
|
|
148
|
-
encoding1 = CharString.guess_encoding(file1_content)
|
|
149
|
-
encoding2 = CharString.guess_encoding(file2_content)
|
|
160
|
+
encoding1 = DocDiff::CharString.guess_encoding(file1_content)
|
|
161
|
+
encoding2 = DocDiff::CharString.guess_encoding(file2_content)
|
|
150
162
|
case
|
|
151
163
|
when (encoding1 == "UNKNOWN" or encoding2 == "UNKNOWN")
|
|
152
164
|
raise "Document encoding unknown (#{encoding1}, #{encoding2})."
|
|
@@ -156,8 +168,8 @@ if docdiff.config[:encoding] == "auto"
|
|
|
156
168
|
end
|
|
157
169
|
|
|
158
170
|
if docdiff.config[:eol] == "auto"
|
|
159
|
-
eol1 = CharString.guess_eol(file1_content)
|
|
160
|
-
eol2 = CharString.guess_eol(file2_content)
|
|
171
|
+
eol1 = DocDiff::CharString.guess_eol(file1_content)
|
|
172
|
+
eol2 = DocDiff::CharString.guess_eol(file2_content)
|
|
161
173
|
case
|
|
162
174
|
when (eol1.nil? or eol2.nil?)
|
|
163
175
|
raise "Document eol is nil (#{eol1.inspect}, #{eol2.inspect}). The document might be empty."
|
|
@@ -168,8 +180,8 @@ if docdiff.config[:eol] == "auto"
|
|
|
168
180
|
end
|
|
169
181
|
end
|
|
170
182
|
|
|
171
|
-
doc1 = Document.new(file1_content, encoding1, eol1)
|
|
172
|
-
doc2 = Document.new(file2_content, encoding2, eol2)
|
|
183
|
+
doc1 = DocDiff::Document.new(file1_content, encoding1, eol1)
|
|
184
|
+
doc2 = DocDiff::Document.new(file2_content, encoding2, eol2)
|
|
173
185
|
|
|
174
186
|
output = docdiff.run(doc1, doc2,
|
|
175
187
|
{:resolution => docdiff.config[:resolution],
|
data/devutil/Rakefile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ChangeLog Generator
|
|
3
|
+
# Copyright 2011 Hisashi Morita
|
|
4
|
+
# License: Public Domain
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# changelog.sh [WORKING_DIR] > ChangeLog
|
|
8
|
+
|
|
9
|
+
if [ "$1" ]; then
|
|
10
|
+
WD="$1"
|
|
11
|
+
else
|
|
12
|
+
WD="."
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
# Subversion
|
|
16
|
+
which svn >/dev/null
|
|
17
|
+
if [ x"$?" = x0 ]; then
|
|
18
|
+
(svn info "${WD}" >/dev/null 2>&1) && SVN=TRUE
|
|
19
|
+
if [ x"${SVN}" = xTRUE ]; then
|
|
20
|
+
(cd "${WD}"; svn log -rBASE:0 -v)
|
|
21
|
+
fi
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# Git
|
|
25
|
+
which git >/dev/null
|
|
26
|
+
if [ x"$?" = x0 ]; then
|
|
27
|
+
(cd "${WD}" && git status --porcelain >/dev/null 2>&1) && GIT=TRUE
|
|
28
|
+
if [ x"${GIT}" = xTRUE ]; then
|
|
29
|
+
(cd "${WD}"; git log | cat)
|
|
30
|
+
fi
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Mercurial
|
|
34
|
+
which hg >/dev/null
|
|
35
|
+
if [ x"$?" = x0 ]; then
|
|
36
|
+
(hg status "${WD}" >/dev/null 2>&1) && HG=TRUE
|
|
37
|
+
if [ x"${HG}" = xTRUE ]; then
|
|
38
|
+
(cd "${WD}"; hg log --rev tip:0)
|
|
39
|
+
fi
|
|
40
|
+
fi
|
data/docdiff.gemspec
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
$:.
|
|
2
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
|
3
3
|
require "docdiff/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
6
|
s.name = "docdiff"
|
|
7
7
|
s.version = Docdiff::VERSION
|
|
8
|
+
s.license = "BSD-3-Clause"
|
|
8
9
|
s.authors = ["Hisashi Morita"]
|
|
9
|
-
s.email = ["hisashim
|
|
10
|
-
s.homepage = "
|
|
10
|
+
s.email = ["hisashim@icloud.com"]
|
|
11
|
+
s.homepage = "https://github.com/hisashim/docdiff"
|
|
11
12
|
s.summary = %q{Word-by-word diff}
|
|
12
13
|
s.description = %q{DocDiff compares two text files and shows the
|
|
13
14
|
difference. It can compare files word by word,
|
|
14
15
|
character by character, or line by line. It has
|
|
15
16
|
several output formats such as HTML, tty, Manued,
|
|
16
17
|
or user-defined markup.}
|
|
17
|
-
s.rubyforge_project = "docdiff"
|
|
18
18
|
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/docdiffwebui.cgi
CHANGED
data/langfilter.rb
CHANGED
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
# language filter
|
|
3
3
|
# usage: langfilter.rb --en <infile >outfile
|
|
4
4
|
|
|
5
|
-
def ruby_m17n?
|
|
6
|
-
return true if "".respond_to? :encoding
|
|
7
|
-
end
|
|
8
|
-
|
|
9
5
|
lang_to_include = ARGV.shift.gsub(/-+/, "")
|
|
10
6
|
lang_to_exclude = {"en"=>"ja", "ja"=>"en"}[lang_to_include]
|
|
11
7
|
re = /<([a-z]+) +(?:(?:lang|title)="#{lang_to_exclude}").*?>.*?<\/\1>[\r\n]?/m
|
|
12
8
|
|
|
13
|
-
ARGF.set_encoding("UTF-8")
|
|
9
|
+
ARGF.set_encoding("UTF-8")
|
|
14
10
|
ARGF.read.gsub(re, "").display
|
data/lib/doc_diff.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# DocDiff: word/character-oriented text comparison utility
|
|
2
2
|
# Copyright (C) 2002-2011 Hisashi MORITA
|
|
3
|
-
# Requirements: Ruby (>=
|
|
3
|
+
# Requirements: Ruby (>= 2.0)
|
|
4
|
+
require 'docdiff/difference'
|
|
5
|
+
require 'docdiff/document'
|
|
6
|
+
require 'docdiff/view'
|
|
7
|
+
|
|
4
8
|
class DocDiff
|
|
5
9
|
|
|
6
10
|
AppVersion = Docdiff::VERSION
|