docdiff 0.6.2 → 0.6.5
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 +4 -4
- data/Makefile +29 -52
- data/README.md +352 -0
- data/README_ja.md +352 -0
- data/Rakefile +2 -42
- data/bin/docdiff +1 -185
- data/{docdiff.conf.example → doc/example/docdiff.conf.example} +4 -3
- data/doc/man/docdiff.adoc +146 -0
- data/doc/news.md +189 -0
- data/doc/shell_completion/_docdiff.zsh +51 -0
- data/doc/shell_completion/docdiff.bash +68 -0
- data/docdiff.gemspec +2 -0
- data/lib/doc_diff.rb +19 -40
- data/lib/docdiff/cli.rb +281 -0
- data/lib/docdiff/version.rb +1 -1
- data/lib/docdiff/view.rb +22 -10
- data/test/charstring_test.rb +121 -121
- data/test/cli_test.rb +312 -0
- data/test/docdiff_test.rb +0 -23
- data/test/document_test.rb +109 -109
- data/test/fixture/01_ja_utf8_lf.txt +2 -0
- data/test/fixture/02_ja_utf8_lf.txt +2 -0
- data/test/fixture/format_wdiff.conf +1 -0
- data/test/fixture/simple.conf +9 -0
- data/test/view_test.rb +135 -111
- metadata +58 -37
- data/devutil/changelog.sh +0 -40
- data/index.html +0 -181
- data/langfilter.rb +0 -10
- data/readme.html +0 -750
- data/readme.md +0 -185
- /data/{docdiffwebui.cgi → doc/example/docdiffwebui.cgi} +0 -0
- /data/{docdiffwebui.html → doc/example/docdiffwebui.html} +0 -0
- /data/{img/docdiff-screenshot-format-html-digest-firefox.png → doc/img/screenshot-format-html-digest-firefox.png} +0 -0
- /data/{img/docdiff-screenshot-format-html-firefox.png → doc/img/screenshot-format-html-firefox.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-cmdexe-en.png → doc/img/screenshot-format-tty-cmdexe-en.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-cmdexe-ja.png → doc/img/screenshot-format-tty-cmdexe-ja.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-rxvtunicode-en.png → doc/img/screenshot-format-tty-rxvtunicode-en.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-rxvtunicode-ja.png → doc/img/screenshot-format-tty-rxvtunicode-ja.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-xterm-en.png → doc/img/screenshot-format-tty-xterm-en.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-xterm-ja.png → doc/img/screenshot-format-tty-xterm-ja.png} +0 -0
- /data/{img/docdiff-screenshot-resolution-linewordchar-xterm.png → doc/img/screenshot-resolution-linewordchar-xterm.png} +0 -0
- /data/{sample/01.en.ascii.cr → test/fixture/01_en_ascii_cr.txt} +0 -0
- /data/{sample/01.en.ascii.crlf → test/fixture/01_en_ascii_crlf.txt} +0 -0
- /data/{sample/01.en.ascii.lf → test/fixture/01_en_ascii_lf.txt} +0 -0
- /data/{sample/01.ja.eucjp.lf → test/fixture/01_ja_eucjp_lf.txt} +0 -0
- /data/{sample/01.ja.sjis.cr → test/fixture/01_ja_sjis_cr.txt} +0 -0
- /data/{sample/01.ja.sjis.crlf → test/fixture/01_ja_sjis_crlf.txt} +0 -0
- /data/{sample/01.ja.utf8.crlf → test/fixture/01_ja_utf8_crlf.txt} +0 -0
- /data/{sample/02.en.ascii.cr → test/fixture/02_en_ascii_cr.txt} +0 -0
- /data/{sample/02.en.ascii.crlf → test/fixture/02_en_ascii_crlf.txt} +0 -0
- /data/{sample/02.en.ascii.lf → test/fixture/02_en_ascii_lf.txt} +0 -0
- /data/{sample/02.ja.eucjp.lf → test/fixture/02_ja_eucjp_lf.txt} +0 -0
- /data/{sample/02.ja.sjis.cr → test/fixture/02_ja_sjis_cr.txt} +0 -0
- /data/{sample/02.ja.sjis.crlf → test/fixture/02_ja_sjis_crlf.txt} +0 -0
- /data/{sample/02.ja.utf8.crlf → test/fixture/02_ja_utf8_crlf.txt} +0 -0
- /data/{sample/humpty_dumpty01.ascii.lf → test/fixture/humpty_dumpty01_ascii_lf.txt} +0 -0
- /data/{sample/humpty_dumpty02.ascii.lf → test/fixture/humpty_dumpty02_ascii_lf.txt} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
= docdiff(1)
|
|
2
|
+
|
|
3
|
+
== NAME
|
|
4
|
+
|
|
5
|
+
docdiff - character/word-oriented diff
|
|
6
|
+
|
|
7
|
+
== SYNOPSIS
|
|
8
|
+
|
|
9
|
+
*docdiff* [_OPTIONS_] _FILE1_ _FILE2_
|
|
10
|
+
|
|
11
|
+
== DESCRIPTION
|
|
12
|
+
|
|
13
|
+
Compares two text files by word, by character, or by line
|
|
14
|
+
|
|
15
|
+
DocDiff compares two text files and shows the difference. It can compare files word by word, character by character, or line by line. It has several output formats such as HTML, tty, Manued, or user-defined markup.
|
|
16
|
+
|
|
17
|
+
It supports several encodings and end-of-line characters, including ASCII (and other single byte encodings such as ISO-8859-*), UTF-8, EUC-JP, Shift_JIS (Windows-31J), CR, LF, and CRLF.
|
|
18
|
+
|
|
19
|
+
== OPTIONS
|
|
20
|
+
|
|
21
|
+
*--resolution*=RESOLUTION::
|
|
22
|
+
specify resolution (granularity)
|
|
23
|
+
_line_|_word_|_char_ (default: _word_)
|
|
24
|
+
|
|
25
|
+
*--line*::
|
|
26
|
+
same as --resolution=_line_
|
|
27
|
+
|
|
28
|
+
*--word*::
|
|
29
|
+
same as --resolution=_word_
|
|
30
|
+
|
|
31
|
+
*--char*::
|
|
32
|
+
same as --resolution=_char_
|
|
33
|
+
|
|
34
|
+
*--encoding*=ENCODING::
|
|
35
|
+
specify character encoding
|
|
36
|
+
_ASCII_|_EUC-JP_|_Shift_JIS_|_CP932_|_UTF-8_|_auto_ (default: _auto_)
|
|
37
|
+
(try _ASCII_ for single byte encodings such as ISO-8859-X)
|
|
38
|
+
|
|
39
|
+
*--ascii*::
|
|
40
|
+
same as *--encoding*=_ASCII_
|
|
41
|
+
|
|
42
|
+
*--iso8859*::
|
|
43
|
+
same as *--encoding*=_ASCII_
|
|
44
|
+
|
|
45
|
+
*--iso8859x*::
|
|
46
|
+
same as *--encoding*=_ASCII_ (deprecated)
|
|
47
|
+
|
|
48
|
+
*--eucjp*::
|
|
49
|
+
same as *--encoding*=_EUC-JP_
|
|
50
|
+
|
|
51
|
+
*--sjis*::
|
|
52
|
+
same as *--encoding*=_Shift_JIS_
|
|
53
|
+
|
|
54
|
+
*--cp932*::
|
|
55
|
+
same as *--encoding*=_CP932_
|
|
56
|
+
|
|
57
|
+
*--utf8*::
|
|
58
|
+
same as *--encoding*=_UTF-8_
|
|
59
|
+
|
|
60
|
+
*--eol*=EOL::
|
|
61
|
+
specify end-of-line character
|
|
62
|
+
_CR_|_LF_|_CRLF_|_auto_ (default: _auto_)
|
|
63
|
+
|
|
64
|
+
*--cr*::
|
|
65
|
+
same as *--eol*=_CR_
|
|
66
|
+
|
|
67
|
+
*--lf*::
|
|
68
|
+
same as *--eol*=_LF_
|
|
69
|
+
|
|
70
|
+
*--crlf*::
|
|
71
|
+
same as *--eol*=_CRLF_
|
|
72
|
+
|
|
73
|
+
*--format*=FORMAT::
|
|
74
|
+
specify output format
|
|
75
|
+
_tty_|_manued_|_html_|_wdiff_|_stat_|_user_ (default: _html_) (_stat_ is deprecated)
|
|
76
|
+
(user tags can be defined in config file)
|
|
77
|
+
|
|
78
|
+
*--tty*::
|
|
79
|
+
same as *--format*=_tty_
|
|
80
|
+
|
|
81
|
+
*--manued*::
|
|
82
|
+
same as *--format*=_manued_
|
|
83
|
+
|
|
84
|
+
*--html*::
|
|
85
|
+
same as *--format*=_html_
|
|
86
|
+
|
|
87
|
+
*--wdiff*::
|
|
88
|
+
same as *--format*=_wdiff_
|
|
89
|
+
|
|
90
|
+
*--stat*::
|
|
91
|
+
same as *--format*=_stat_ (not implemented) (deprecated)
|
|
92
|
+
|
|
93
|
+
*-L*, *--label* LABEL::
|
|
94
|
+
use label instead of file name (not implemented; exists for compatibility with diff)
|
|
95
|
+
|
|
96
|
+
*--digest*::
|
|
97
|
+
digest output, do not show all
|
|
98
|
+
|
|
99
|
+
*--summary*::
|
|
100
|
+
same as *--digest*
|
|
101
|
+
|
|
102
|
+
*--display*=DISPLAY::
|
|
103
|
+
specify presentation type (effective only with digest; experimental feature)
|
|
104
|
+
_inline_|_block_|_multi_ (default: _inline_) (_multi_ is deprecated)
|
|
105
|
+
|
|
106
|
+
*--cache*::
|
|
107
|
+
use file cache (not implemented) (deprecated)
|
|
108
|
+
|
|
109
|
+
*--pager*=PAGER::
|
|
110
|
+
specify pager (if available, $_DOCDIFF_PAGER_ is used by default)
|
|
111
|
+
|
|
112
|
+
*--no-pager*::
|
|
113
|
+
do not use pager
|
|
114
|
+
|
|
115
|
+
*--config-file*=FILE::
|
|
116
|
+
specify config file to read
|
|
117
|
+
|
|
118
|
+
*--no-config-file*::
|
|
119
|
+
do not read config files
|
|
120
|
+
|
|
121
|
+
*--verbose*::
|
|
122
|
+
run verbosely (not well-supported) (deprecated)
|
|
123
|
+
|
|
124
|
+
*--help*::
|
|
125
|
+
show this message
|
|
126
|
+
|
|
127
|
+
*--version*::
|
|
128
|
+
show version
|
|
129
|
+
|
|
130
|
+
*--license*::
|
|
131
|
+
show license (deprecated)
|
|
132
|
+
|
|
133
|
+
*--author*::
|
|
134
|
+
show author(s) (deprecated)
|
|
135
|
+
|
|
136
|
+
When invoked as *worddiff* or *chardiff*, resolution will be set accordingly.
|
|
137
|
+
|
|
138
|
+
Config files: _/etc/docdiff/docdiff.conf_, _~/.config/docdiff/docdiff.conf_
|
|
139
|
+
|
|
140
|
+
== SEE ALSO
|
|
141
|
+
|
|
142
|
+
_/path/to/README.html_.
|
|
143
|
+
|
|
144
|
+
== AUTHOR
|
|
145
|
+
|
|
146
|
+
Hisashi Morita
|
data/doc/news.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# News
|
|
2
|
+
|
|
3
|
+
### 0.6.5 (2025-12-29)
|
|
4
|
+
|
|
5
|
+
* User-visible changes:
|
|
6
|
+
- Fixed label option not accumulating correctly.
|
|
7
|
+
- Fixed CRLF bug ([#57](https://github.com/hisashim/docdiff/issues/57)), where CRLFs in the input text are gobbled and not printed in the output when using `tty`, `wdiff`, and `user` formats. This problem seems to have existed since 0.3.
|
|
8
|
+
* Developer-related changes:
|
|
9
|
+
- Moved CLI-related stuff from `bin/docdiff` to `lib/docdiff/cli.rb`.
|
|
10
|
+
- Miscellaneous fixes and refactoring.
|
|
11
|
+
|
|
12
|
+
### 0.6.4 (2025-12-13)
|
|
13
|
+
|
|
14
|
+
* User-visible changes:
|
|
15
|
+
- Removed ChangeLog.
|
|
16
|
+
- Reorganized and updated documents: most documents are moved to `doc/`.
|
|
17
|
+
- `$XDG_CONFIG_HOME`-style user configuration file name (`~/.config/docdiff/docdiff.conf`) is supported and encouraged to use.
|
|
18
|
+
- Added a manual page (`doc/man/docdiff.1` will be generated from `.adoc` by `make docs`).
|
|
19
|
+
- Added shell completion scripts for Zsh and Bash.
|
|
20
|
+
- Cleaned up CLI help message a bit.
|
|
21
|
+
- Added pager support with `--pager=` and `--no-pager` options. `$DOCDIFF_PAGER` is consulted as well.
|
|
22
|
+
- Added `--iso8859` to supersede `--iso8859x`; ditto for `--display=block` and `--display=multi`.
|
|
23
|
+
- Marked to-be-deprecated features as deprecated, e.g.: `--format=stat`, `--stat`, `--cache`, `--iso8859x`, `--display=multi`, `--verbose`, `--license`, `--author`, `~/etc/docdiff/docdiff.conf`, and `~/.docdiff/docdiff.conf`.
|
|
24
|
+
* Developer-related changes:
|
|
25
|
+
- Removed test logging.
|
|
26
|
+
- Fixed erroneous tarball generation (`make dist`).
|
|
27
|
+
- Introduced additional development requirements: git, md2html, asciidoctor.
|
|
28
|
+
- Fixed irregular time stamps of gem members by setting `$SOURCE_DATE_EPOCH`.
|
|
29
|
+
- Converted EUC-JP code files to UTF-8.
|
|
30
|
+
|
|
31
|
+
### 0.6.3 (2025-12-13)
|
|
32
|
+
|
|
33
|
+
This version was revoked due to a mistake in the release procedure.
|
|
34
|
+
|
|
35
|
+
### 0.6.2 (2025-11-28)
|
|
36
|
+
|
|
37
|
+
* User-visible changes:
|
|
38
|
+
- Add support for stdin (`-`) in command line arguments (thanks to tamo)
|
|
39
|
+
- Add `--config-file` option (thanks to tamo)
|
|
40
|
+
- Fix incompatibility with Ruby 3.4 `Regexp` (thanks to yoshuki)
|
|
41
|
+
- Resolve frozen literal warnings introduced by Ruby 3.4.
|
|
42
|
+
* Developer-related changes:
|
|
43
|
+
- Remove unused files: ViewDiff and its tests.
|
|
44
|
+
- Update email address in `.gemspec`.
|
|
45
|
+
|
|
46
|
+
### 0.6.1 (2021-06-07)
|
|
47
|
+
|
|
48
|
+
* User-visible changes:
|
|
49
|
+
- none
|
|
50
|
+
* Developer-related changes:
|
|
51
|
+
- Update information in `.gemspec`. (Primary repository is now GitHub, etc.)
|
|
52
|
+
- Fix: Use `VERSION` from local library when building a gem.
|
|
53
|
+
|
|
54
|
+
### 0.6.0 (2020-07-10)
|
|
55
|
+
|
|
56
|
+
* User-visible changes:
|
|
57
|
+
- Drop support for Ruby 1.8 (thanks to takahashim).
|
|
58
|
+
- Fix various encoding problems (thanks to takahashim).
|
|
59
|
+
- Add CP932 (Windows-31J) support through a new option `--cp932` (thanks to emasaka).
|
|
60
|
+
- Introduce `readme.md`, which will obsolete `readme.html` eventually (thanks to takahashim).
|
|
61
|
+
* Developer-related changes:
|
|
62
|
+
- Use Mutex#synchronize instead of Thread.exclusive (thanks to hsbt).
|
|
63
|
+
- Remove `JIS0208.TXT` to comply with its terms of use (thanks to kmuto).
|
|
64
|
+
- Introduce top-level class `DocDiff` to avoid name conflict (thanks to hibariya).
|
|
65
|
+
|
|
66
|
+
### 0.5.0 (2011-08-12)
|
|
67
|
+
|
|
68
|
+
* Gemify. Now you can download docdiff via rubygems.org.
|
|
69
|
+
* Fix failing test on ruby1.9.2-p290.
|
|
70
|
+
|
|
71
|
+
### 0.4.0 (2011-02-23)
|
|
72
|
+
|
|
73
|
+
* Compatible with Ruby 1.9 (thanks to Kazuhiko).
|
|
74
|
+
|
|
75
|
+
### 0.3.4 (2007-12-10)
|
|
76
|
+
|
|
77
|
+
* Increased context length in digest mode from 16 to 32.
|
|
78
|
+
* Added `--display=inline|multi` option. With inline, things before change and things after change are displayed inline. With multi, they are displayed in separate blocks. Default is inline.
|
|
79
|
+
* Added `--iso8859x` option as an alias to `--encoding=ASCII`, so that users notice DocDiff can handle text in ISO-8859-* encoding.
|
|
80
|
+
|
|
81
|
+
### 0.3.3 (2006-02-03)
|
|
82
|
+
|
|
83
|
+
* Fixed arg test so that we can compare non-normal files, such as device files and named pipes (thanks to Shugo Maeda).
|
|
84
|
+
* Added DocDiff Web UI sample (experimental).
|
|
85
|
+
* Fixed HTML output to produce valid XHTML (thanks to Hiroshi OHKUBO). Note that CSS in HTML output is slightly changed.
|
|
86
|
+
* Replaced underscores(`_`) in CSS class names to hyphens(`-`) so that older UAs can understand them (thanks to Kazuhiro NISHIYAMA).
|
|
87
|
+
|
|
88
|
+
### 0.3.2 (2005-01-03)
|
|
89
|
+
|
|
90
|
+
* Readme is multilingualized (added partial Japanese translation). Try switching CSS between en and ja. Monolingual files are also available (`readme.en.html`, `readme.ja.html`).
|
|
91
|
+
* Outputs better error messages when it failed to auto-detect the encoding and/or eol, though the accuracy is the same.
|
|
92
|
+
* Switched revision control system from CVS to Subversion.
|
|
93
|
+
|
|
94
|
+
### 0.3.1 (2004-08-29)
|
|
95
|
+
|
|
96
|
+
* Added `-L` (`--label`) option place holder in order to be used as external diff program from Subversion.
|
|
97
|
+
|
|
98
|
+
### 0.3.0 (2004-05-29)
|
|
99
|
+
|
|
100
|
+
* Re-designed and re-written from scratch.
|
|
101
|
+
* Supports multiple encodings (ASCII, EUC-JP, Shift_JIS, UTF-8) and multiple eols (CR, LF, CRLF).
|
|
102
|
+
* Supports more output formats (tty, HTML, Manued, wdiff-like, user-defined markup text).
|
|
103
|
+
* Supports configuration files (`/etc/docdiff/docdiff.conf`, `~/etc/docdiff/docdiff.conf` (or `~/.docdiff/docdiff.conf`)).
|
|
104
|
+
* Introduced digest (summary) mode.
|
|
105
|
+
* Approximately 200% faster than older versions, thanks to akr's diff library.
|
|
106
|
+
* Better documentation and help message.
|
|
107
|
+
* License changed from Ruby's to modified BSD style.
|
|
108
|
+
* Pure Ruby. Does not require external diff program such as GNU diff, or morphological analyzer such as ChaSen.
|
|
109
|
+
* Runs on both Unix and Windows (tested on Debian GNU/Linux and Cygwin).
|
|
110
|
+
* Unit tests introduced to decrease bugs and to encourage faster development.
|
|
111
|
+
* Makefile introduced.
|
|
112
|
+
|
|
113
|
+
### 0.1.8 (2003-12-14)
|
|
114
|
+
|
|
115
|
+
* Displays warning when `--bymorpheme` is specified but ChaSen is not available (patch by Akira YAMADA: Debian bug #192258).
|
|
116
|
+
* Supports system-wide configuration file (if `~/.chasenrc.docdiff` does not exist, reads `/etc/docdiff/chasenrc`) (patch by Akira YAMADA: Debian bug #192261).
|
|
117
|
+
|
|
118
|
+
### 0.1.7 (2003-11-21)
|
|
119
|
+
|
|
120
|
+
* HTML output retains spaces (` ` patch by Akira YAMADA).
|
|
121
|
+
* Manued output is added. Use `--manued` command line option to get result in Manued-like format.
|
|
122
|
+
* Fixed `.chasenrc.docdiff` to be compatible with the latest ChaSen, so that it does not cause error.
|
|
123
|
+
* Alphabet words in the output may look ugly, since ChaSen does not keep spaces between alphabetical words recently.
|
|
124
|
+
* Other minor bug fixes and code cleanup.
|
|
125
|
+
|
|
126
|
+
### 0.2.0b2 (2001-08-31)
|
|
127
|
+
|
|
128
|
+
* Code cleanup.
|
|
129
|
+
|
|
130
|
+
### 0.2.0b1 (2001-08-31)
|
|
131
|
+
|
|
132
|
+
* A bit faster than 0.1.x, using file cache.
|
|
133
|
+
* A bit cleaner code.
|
|
134
|
+
|
|
135
|
+
### 0.1.6 (2001-05-16)
|
|
136
|
+
|
|
137
|
+
* Increased diff option number from 100000 to 1000000 in order to support 900KB+ text files.
|
|
138
|
+
|
|
139
|
+
### 0.1.5 (2001-01-17)
|
|
140
|
+
|
|
141
|
+
* Erased useless old code which were already commented out.
|
|
142
|
+
* Added documentation. (Updated README, more comments)
|
|
143
|
+
* First public release. Registered to RAA.
|
|
144
|
+
|
|
145
|
+
### 0.1.4 (2001-01-16)
|
|
146
|
+
|
|
147
|
+
* Output is like `<tag>ab</tag>`, instead of ugly `<tag>a</tag><tag>b</tag>` (thanks again to Masatoshi Seki for suggestion).
|
|
148
|
+
* Fixed hidden bug (`puts` was used to output result).
|
|
149
|
+
* Some code clean-up, though still hairy enough.
|
|
150
|
+
|
|
151
|
+
### 0.1.3 (2001-01-09)
|
|
152
|
+
|
|
153
|
+
* Tested with Ruby 1.6.2.
|
|
154
|
+
* Fixed `meth(a,b,)` bug (thanks to Masatoshi Seki).
|
|
155
|
+
* Switched development platform from Windows to Linux, but it should work fine on Windows too, except for ChaSen stuff.
|
|
156
|
+
|
|
157
|
+
### 0.1.2 (2000-12-28)
|
|
158
|
+
|
|
159
|
+
* Mostly bug fix.
|
|
160
|
+
|
|
161
|
+
### 0.1.1 (2000-12-25)
|
|
162
|
+
|
|
163
|
+
* Bug fix and some cleanup.
|
|
164
|
+
* Quotes some of HTML special characters (`<>&`) when output in HTML.
|
|
165
|
+
* Added support for tty output using escape sequence.
|
|
166
|
+
|
|
167
|
+
### 0.1.0 (2000-12-19)
|
|
168
|
+
|
|
169
|
+
* ChaSen works fine now.
|
|
170
|
+
* GetOptLong was introduced to support command line options.
|
|
171
|
+
|
|
172
|
+
### 0.1.0a1 (2000-12-16)
|
|
173
|
+
|
|
174
|
+
* Added ChaSen support. Japanese word by word comparison requires ChaSen.
|
|
175
|
+
* Converted scripts from Shift_JIS/CRLF to EUC-JP/LF.
|
|
176
|
+
|
|
177
|
+
### 0.0.2 (2000-12-10)
|
|
178
|
+
|
|
179
|
+
* Rewritten to use class.
|
|
180
|
+
|
|
181
|
+
### 0.0.1 (2000-12-09)
|
|
182
|
+
|
|
183
|
+
* First version. Proof-of-concept.
|
|
184
|
+
* Supports ASCII, EUC-JP, LF only.
|
|
185
|
+
* Supports HTML output only.
|
|
186
|
+
* Requires GNU diff.
|
|
187
|
+
* Distributed under the same license as Ruby's.
|
|
188
|
+
|
|
189
|
+
See the source repository for detail.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#compdef docdiff
|
|
2
|
+
|
|
3
|
+
# Zsh completion for DocDiff
|
|
4
|
+
|
|
5
|
+
_docdiff() {
|
|
6
|
+
integer ret=1
|
|
7
|
+
local -a args
|
|
8
|
+
args+=(
|
|
9
|
+
'--resolution=[specify resolution (granularity)]:resolution:(line word char)'
|
|
10
|
+
'--line[same as --resolution=line]'
|
|
11
|
+
'--word[same as --resolution=word]'
|
|
12
|
+
'--char[same as --resolution=char]'
|
|
13
|
+
'--encoding=[specify character encoding]:encoding:(ASCII EUC-JP Shift_JIS CP932 UTF-8 auto)'
|
|
14
|
+
'--ascii[same as --encoding=ASCII]'
|
|
15
|
+
'--iso8859[same as --encoding=ASCII]'
|
|
16
|
+
'--iso8859x[same as --encoding=ASCII (deprecated)]'
|
|
17
|
+
'--eucjp[same as --encoding=EUC-JP]'
|
|
18
|
+
'--sjis[same as --encoding=Shift_JIS]'
|
|
19
|
+
'--cp932[same as --encoding=CP932]'
|
|
20
|
+
'--utf8[same as --encoding=UTF-8]'
|
|
21
|
+
'--eol=[specify end-of-line character]:eol:(CR LF CRLF auto)'
|
|
22
|
+
'--cr[same as --eol=CR]'
|
|
23
|
+
'--lf[same as --eol=LF]'
|
|
24
|
+
'--crlf[same as --eol=CRLF]'
|
|
25
|
+
'--format=[specify output format]:format:(tty manued html wdiff stat user)'
|
|
26
|
+
'--tty[same as --format=tty]'
|
|
27
|
+
'--manued[same as --format=manued]'
|
|
28
|
+
'--html[same as --format=html]'
|
|
29
|
+
'--wdiff[same as --format=wdiff]'
|
|
30
|
+
'--stat[same as --format=stat (not implemented) (deprecated)]'
|
|
31
|
+
'(--label= -L)'{--label=,-L}'[use label instead of file name (not implemented)]:label'
|
|
32
|
+
'--digest[digest output, do not show all]'
|
|
33
|
+
'--summary[same as --digest]'
|
|
34
|
+
'--display=[specify presentation type (effective only with digest)]:type:(inline block multi)'
|
|
35
|
+
'--cache[use file cache (not implemented) (deprecated)]'
|
|
36
|
+
'--pager=[specify pager]:pager:_command_names'
|
|
37
|
+
'--no-pager[do not use pager]'
|
|
38
|
+
'--config-file=[specify config file to read]:config_file:_files'
|
|
39
|
+
'--no-config-file[do not read config files]'
|
|
40
|
+
'--verbose[run verbosely (not well-supported) (deprecated)]'
|
|
41
|
+
'(- *)--help[show this message]'
|
|
42
|
+
'(- *)--version[show version]'
|
|
43
|
+
'(- *)--license[show license (deprecated)]'
|
|
44
|
+
'(- *)--author[show author(s) (deprecated)]'
|
|
45
|
+
'*:file:_files'
|
|
46
|
+
)
|
|
47
|
+
_arguments $args[@] && ret=0
|
|
48
|
+
return ret
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_docdiff
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Bash completion for DocDiff
|
|
2
|
+
|
|
3
|
+
_docdiff_completions()
|
|
4
|
+
{
|
|
5
|
+
local cur prev opts
|
|
6
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
7
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
8
|
+
opts="\
|
|
9
|
+
--resolution \
|
|
10
|
+
--line --word --char \
|
|
11
|
+
--encoding \
|
|
12
|
+
--ascii --iso8859 --iso8859x --eucjp --sjis --cp932 --utf8 \
|
|
13
|
+
--eol \
|
|
14
|
+
--cr --lf --crlf \
|
|
15
|
+
--format \
|
|
16
|
+
--tty --manued --html --wdiff --stat \
|
|
17
|
+
-L --label \
|
|
18
|
+
--digest --summary \
|
|
19
|
+
--display \
|
|
20
|
+
--cache \
|
|
21
|
+
--pager \
|
|
22
|
+
--no-pager \
|
|
23
|
+
--config-file \
|
|
24
|
+
--no-config-file \
|
|
25
|
+
--verbose \
|
|
26
|
+
--help \
|
|
27
|
+
--version \
|
|
28
|
+
--license \
|
|
29
|
+
--author\
|
|
30
|
+
"
|
|
31
|
+
COMPREPLY=()
|
|
32
|
+
|
|
33
|
+
case ${prev} in
|
|
34
|
+
--resolution)
|
|
35
|
+
COMPREPLY=( $(compgen -W 'line word char' -- "${cur}") )
|
|
36
|
+
return 0
|
|
37
|
+
;;
|
|
38
|
+
--encoding)
|
|
39
|
+
COMPREPLY=( $(compgen -W 'ASCII EUC-JP Shift_JIS CP932 UTF-8 auto' -- "${cur}") )
|
|
40
|
+
return 0
|
|
41
|
+
;;
|
|
42
|
+
--eol)
|
|
43
|
+
COMPREPLY=( $(compgen -W 'CR LF CRLF auto' -- "${cur}") )
|
|
44
|
+
return 0
|
|
45
|
+
;;
|
|
46
|
+
--format)
|
|
47
|
+
COMPREPLY=( $(compgen -W 'tty manued html wdiff stat user' -- "${cur}") )
|
|
48
|
+
return 0
|
|
49
|
+
;;
|
|
50
|
+
--display)
|
|
51
|
+
COMPREPLY=( $(compgen -W 'inline block multi' -- "${cur}") )
|
|
52
|
+
return 0
|
|
53
|
+
;;
|
|
54
|
+
--config-file)
|
|
55
|
+
COMPREPLY=( $(compgen -A file -- "${cur}") )
|
|
56
|
+
return 0
|
|
57
|
+
;;
|
|
58
|
+
--help | --version | --license | --author)
|
|
59
|
+
return 0
|
|
60
|
+
;;
|
|
61
|
+
esac
|
|
62
|
+
|
|
63
|
+
if [[ ${cur} == -* ]]; then
|
|
64
|
+
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
65
|
+
return
|
|
66
|
+
fi
|
|
67
|
+
} &&
|
|
68
|
+
complete -o bashdefault -o default -F _docdiff_completions docdiff
|
data/docdiff.gemspec
CHANGED
|
@@ -20,4 +20,6 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
22
22
|
s.require_paths = ["lib"]
|
|
23
|
+
s.required_ruby_version = '>= 3.0'
|
|
24
|
+
s.add_development_dependency "test-unit", "~> 3"
|
|
23
25
|
end
|
data/lib/doc_diff.rb
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
require 'docdiff/difference'
|
|
5
5
|
require 'docdiff/document'
|
|
6
6
|
require 'docdiff/view'
|
|
7
|
+
require 'docdiff/cli'
|
|
7
8
|
|
|
8
9
|
class DocDiff
|
|
9
10
|
|
|
10
|
-
AppVersion = Docdiff::VERSION
|
|
11
11
|
Author = "Copyright (C) 2002-2011 Hisashi MORITA.\n" +
|
|
12
12
|
"diff library originates from Ruby/CVS by TANAKA Akira.\n"
|
|
13
13
|
License = "This software is licensed under so-called modified BSD license.\n" +
|
|
@@ -15,34 +15,28 @@ class DocDiff
|
|
|
15
15
|
SystemConfigFileName = File.join(File::Separator, "etc", "docdiff", "docdiff.conf")
|
|
16
16
|
UserConfigFileName = File.join(ENV['HOME'], "etc", "docdiff", "docdiff.conf")
|
|
17
17
|
AltUserConfigFileName = File.join(ENV['HOME'], ".docdiff", "docdiff.conf")
|
|
18
|
+
XDGUserConfigFileName =
|
|
19
|
+
if xdg_config_home = ENV['XDG_CONFIG_HOME'] && !xdg_config_home.empty?
|
|
20
|
+
File.join(ENV['HOME'], xdg_config_home, "docdiff", "docdiff.conf")
|
|
21
|
+
else
|
|
22
|
+
File.join(ENV['HOME'], ".config", "docdiff", "docdiff.conf")
|
|
23
|
+
end
|
|
24
|
+
DEFAULT_CONFIG = {
|
|
25
|
+
:resolution => "word",
|
|
26
|
+
:encoding => "auto",
|
|
27
|
+
:eol => "auto",
|
|
28
|
+
:format => "html",
|
|
29
|
+
:cache => true,
|
|
30
|
+
:digest => false,
|
|
31
|
+
:pager => nil,
|
|
32
|
+
:verbose => false
|
|
33
|
+
}
|
|
18
34
|
|
|
19
|
-
def initialize()
|
|
20
|
-
@config =
|
|
35
|
+
def initialize(config: {})
|
|
36
|
+
@config = config
|
|
21
37
|
end
|
|
22
38
|
attr_accessor :config
|
|
23
39
|
|
|
24
|
-
def DocDiff.parse_config_file_content(content)
|
|
25
|
-
result = {}
|
|
26
|
-
return result if content.size <= 0
|
|
27
|
-
lines = content.dup.split(/\r\n|\r|\n/).compact
|
|
28
|
-
lines.collect!{|line| line.sub(/#.*$/, '')}
|
|
29
|
-
lines.collect!{|line| line.strip}
|
|
30
|
-
lines.delete_if{|line| line == ""}
|
|
31
|
-
lines.each{|line|
|
|
32
|
-
raise 'line does not include " = ".' unless /[\s]+=[\s]+/.match line
|
|
33
|
-
name_src, value_src = line.split(/[\s]+=[\s]+/)
|
|
34
|
-
raise "Invalid name: #{name_src.inspect}" if (/\s/.match name_src)
|
|
35
|
-
raise "Invalid value: #{value_src.inspect}" unless value_src.kind_of?(String)
|
|
36
|
-
name = name_src.intern
|
|
37
|
-
value = value_src
|
|
38
|
-
value = true if ['on','yes','true'].include? value_src.downcase
|
|
39
|
-
value = false if ['off','no','false'].include? value_src.downcase
|
|
40
|
-
value = value_src.to_i if /^[0-9]+$/.match value_src
|
|
41
|
-
result[name] = value
|
|
42
|
-
}
|
|
43
|
-
result
|
|
44
|
-
end
|
|
45
|
-
|
|
46
40
|
def compare_by_line(doc1, doc2)
|
|
47
41
|
Difference.new(doc1.split_to_line, doc2.split_to_line)
|
|
48
42
|
end
|
|
@@ -156,19 +150,4 @@ class DocDiff
|
|
|
156
150
|
end
|
|
157
151
|
result.join
|
|
158
152
|
end
|
|
159
|
-
|
|
160
|
-
def process_config_file(filename)
|
|
161
|
-
file_content = nil
|
|
162
|
-
begin
|
|
163
|
-
File.open(filename, "r"){|f| file_content = f.read}
|
|
164
|
-
rescue Errno::ENOENT
|
|
165
|
-
message = "config file not found so not read."
|
|
166
|
-
ensure
|
|
167
|
-
if file_content != nil
|
|
168
|
-
self.config.update(DocDiff.parse_config_file_content(file_content))
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
message
|
|
172
|
-
end
|
|
173
|
-
|
|
174
153
|
end # class DocDiff
|