docdiff 0.6.7 → 0.7.0
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/README.md +69 -36
- data/README_ja.md +70 -37
- data/doc/example/docdiff.conf.example +3 -0
- data/doc/img/screenshot-html.png +0 -0
- data/doc/img/screenshot-tty-char.png +0 -0
- data/doc/img/screenshot-tty-digest-block.png +0 -0
- data/doc/img/screenshot-tty-digest-license-block.png +0 -0
- data/doc/img/screenshot-tty-digest-license.png +0 -0
- data/doc/img/screenshot-tty-digest.png +0 -0
- data/doc/img/screenshot-tty-en-ja.png +0 -0
- data/doc/img/screenshot-tty-manued.png +0 -0
- data/doc/img/screenshot-tty-wdiff.png +0 -0
- data/doc/img/screenshot-tty-word-char.png +0 -0
- data/doc/man/docdiff.adoc +3 -3
- data/doc/news.md +11 -0
- data/docdiff.gemspec +1 -1
- data/lib/doc_diff.rb +5 -5
- data/lib/docdiff/charstring.rb +36 -40
- data/lib/docdiff/cli.rb +23 -10
- data/lib/docdiff/document.rb +44 -44
- data/lib/docdiff/encoding/en_ascii.rb +4 -4
- data/lib/docdiff/version.rb +1 -1
- data/lib/docdiff/view.rb +27 -13
- data/test/charstring_test.rb +221 -221
- data/test/cli_test.rb +12 -12
- data/test/document_test.rb +223 -223
- data/test/fixture/humpty_dumpty_01_en.txt +4 -0
- data/test/fixture/humpty_dumpty_01_ja.txt +4 -0
- data/test/fixture/{humpty_dumpty01_ascii_lf.txt → humpty_dumpty_02_en.txt} +2 -2
- data/test/fixture/humpty_dumpty_02_ja.txt +4 -0
- data/test/view_test.rb +38 -31
- metadata +26 -14
- data/test/fixture/humpty_dumpty02_ascii_lf.txt +0 -4
- /data/doc/img/{screenshot-format-html-digest-firefox.png → old/screenshot-format-html-digest-firefox.png} +0 -0
- /data/doc/img/{screenshot-format-html-firefox.png → old/screenshot-format-html-firefox.png} +0 -0
- /data/doc/img/{screenshot-format-tty-cmdexe-en.png → old/screenshot-format-tty-cmdexe-en.png} +0 -0
- /data/doc/img/{screenshot-format-tty-cmdexe-ja.png → old/screenshot-format-tty-cmdexe-ja.png} +0 -0
- /data/doc/img/{screenshot-format-tty-rxvtunicode-en.png → old/screenshot-format-tty-rxvtunicode-en.png} +0 -0
- /data/doc/img/{screenshot-format-tty-rxvtunicode-ja.png → old/screenshot-format-tty-rxvtunicode-ja.png} +0 -0
- /data/doc/img/{screenshot-format-tty-xterm-en.png → old/screenshot-format-tty-xterm-en.png} +0 -0
- /data/doc/img/{screenshot-format-tty-xterm-ja.png → old/screenshot-format-tty-xterm-ja.png} +0 -0
- /data/doc/img/{screenshot-resolution-linewordchar-xterm.png → old/screenshot-resolution-linewordchar-xterm.png} +0 -0
data/test/view_test.rb
CHANGED
|
@@ -13,6 +13,13 @@ class TestView < Test::Unit::TestCase
|
|
|
13
13
|
def setup
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def test_format_line_number
|
|
17
|
+
view = Difference.new([], []).to_view("US-ASCII", nil)
|
|
18
|
+
assert_equal("L1", view.format_line_number(1, nil))
|
|
19
|
+
assert_equal("(L1)", view.format_line_number(1, nil, paren: true))
|
|
20
|
+
assert_equal("LL1-2", view.format_line_number(1, 2))
|
|
21
|
+
end
|
|
22
|
+
|
|
16
23
|
def test_scan_lines_cr
|
|
17
24
|
str = "A\r\rA\n\nA\r\n\r\nA\n\r\n\rA"
|
|
18
25
|
expected = ["A\r", "\r", "A\n\nA\r", "\n\r", "\nA\n\r", "\n\r", "A"]
|
|
@@ -239,9 +246,9 @@ class TestView < Test::Unit::TestCase
|
|
|
239
246
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
240
247
|
expected = [
|
|
241
248
|
"----\n",
|
|
242
|
-
"
|
|
243
|
-
"(
|
|
244
|
-
"
|
|
249
|
+
"LL1-2, (L1)\n\033[7;4;31ma\nb\033[0mcd\n----\n",
|
|
250
|
+
"(L2), LL1-2\ncd\033[7;1;34mX\nY\033[0me\n\n----\n",
|
|
251
|
+
"L3, L3\ne\n\033[7;4;33mf\033[0m\033[7;1;32mF\033[0m\n\n----\n",
|
|
245
252
|
]
|
|
246
253
|
view = View.new(Difference.new(array1, array2), "US-ASCII", "LF")
|
|
247
254
|
assert_equal(expected, view.to_tty_digest(nil, false))
|
|
@@ -252,9 +259,9 @@ class TestView < Test::Unit::TestCase
|
|
|
252
259
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
253
260
|
expected = [
|
|
254
261
|
"----\n",
|
|
255
|
-
"
|
|
256
|
-
"(
|
|
257
|
-
"
|
|
262
|
+
"LL1-2, (L1)\na\nbcd\n\033[7;4;31ma\nb\033[0mcd\n----\n",
|
|
263
|
+
"(L2), LL1-2\ncde\n\ncd\033[7;1;34mX\nY\033[0me\n\n----\n",
|
|
264
|
+
"L3, L3\ne\n\033[7;4;33mf\033[0m\n\ne\n\033[7;1;32mF\033[0m\n\n----\n",
|
|
258
265
|
]
|
|
259
266
|
view = View.new(Difference.new(array1, array2), "US-ASCII", "LF")
|
|
260
267
|
assert_equal(expected, view.to_tty_digest({ display: "block" }, false))
|
|
@@ -297,9 +304,9 @@ class TestView < Test::Unit::TestCase
|
|
|
297
304
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
298
305
|
expected = [
|
|
299
306
|
"<ul>",
|
|
300
|
-
"<li class=\"entry\"><p class=\"position\">
|
|
301
|
-
"<li class=\"entry\"><p class=\"position\">(
|
|
302
|
-
"<li class=\"entry\"><p class=\"position\">
|
|
307
|
+
"<li class=\"entry\"><p class=\"position\">LL1-2, (L1)</p><blockquote class=\"body\"><p class=\"body\"><span class=\"del\"><del>a<br />\nb</del></span>cd</p></blockquote></li>\n",
|
|
308
|
+
"<li class=\"entry\"><p class=\"position\">(L2), LL1-2</p><blockquote class=\"body\"><p class=\"body\">cd<span class=\"add\"><ins>X<br />\nY</ins></span>e<br />\n</p></blockquote></li>\n",
|
|
309
|
+
"<li class=\"entry\"><p class=\"position\">L3, L3</p><blockquote class=\"body\"><p class=\"body\">e<br />\n<span class=\"before-change\"><del>f</del></span><span class=\"after-change\"><ins>F</ins></span><br />\n</p></blockquote></li>\n",
|
|
303
310
|
"</ul>",
|
|
304
311
|
]
|
|
305
312
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
@@ -311,9 +318,9 @@ class TestView < Test::Unit::TestCase
|
|
|
311
318
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
312
319
|
expected = [
|
|
313
320
|
"<ul>",
|
|
314
|
-
"<li class=\"entry\"><p class=\"position\">
|
|
315
|
-
"<li class=\"entry\"><p class=\"position\">(
|
|
316
|
-
"<li class=\"entry\"><p class=\"position\">
|
|
321
|
+
"<li class=\"entry\"><p class=\"position\">LL1-2, (L1)</p><blockquote class=\"body\"><p class=\"body\">a<br />\nbcd</p><p class=\"body\"><span class=\"del\"><del>a<br />\nb</del></span>cd</p></blockquote></li>\n",
|
|
322
|
+
"<li class=\"entry\"><p class=\"position\">(L2), LL1-2</p><blockquote class=\"body\"><p class=\"body\">cde<br />\n</p><p class=\"body\">cd<span class=\"add\"><ins>X<br />\nY</ins></span>e<br />\n</p></blockquote></li>\n",
|
|
323
|
+
"<li class=\"entry\"><p class=\"position\">L3, L3</p><blockquote class=\"body\"><p class=\"body\">e<br />\n<span class=\"before-change\"><del>f</del></span><br />\n</p><p class=\"body\">e<br />\n<span class=\"after-change\"><ins>F</ins></span><br />\n</p></blockquote></li>\n",
|
|
317
324
|
"</ul>",
|
|
318
325
|
]
|
|
319
326
|
view = View.new(Difference.new(array1, array2), "US-ASCII", "LF")
|
|
@@ -491,9 +498,9 @@ class TestView < Test::Unit::TestCase
|
|
|
491
498
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
492
499
|
expected = [
|
|
493
500
|
"----\n",
|
|
494
|
-
"
|
|
495
|
-
"(
|
|
496
|
-
"
|
|
501
|
+
"LL1-2, (L1)\n[a\nb/]cd\n----\n",
|
|
502
|
+
"(L2), LL1-2\ncd[/X\nY]e\n\n----\n",
|
|
503
|
+
"L3, L3\ne\n[f/F]\n\n----\n",
|
|
497
504
|
]
|
|
498
505
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
499
506
|
assert_equal(expected, view.to_manued_digest(nil, false))
|
|
@@ -504,9 +511,9 @@ class TestView < Test::Unit::TestCase
|
|
|
504
511
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
505
512
|
expected = [
|
|
506
513
|
"----\n",
|
|
507
|
-
"
|
|
508
|
-
"(
|
|
509
|
-
"
|
|
514
|
+
"LL1-2, (L1)\na\nbcd\n[a\nb/]cd\n----\n",
|
|
515
|
+
"(L2), LL1-2\ncde\n\ncd[/X\nY]e\n\n----\n",
|
|
516
|
+
"L3, L3\ne\n[f/]\n\ne\n[/F]\n\n----\n",
|
|
510
517
|
]
|
|
511
518
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
512
519
|
assert_equal(expected, view.to_manued_digest({ display: "block" }, false))
|
|
@@ -587,9 +594,9 @@ class TestView < Test::Unit::TestCase
|
|
|
587
594
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
588
595
|
expected = [
|
|
589
596
|
"----\n",
|
|
590
|
-
"
|
|
591
|
-
"(
|
|
592
|
-
"
|
|
597
|
+
"LL1-2, (L1)\n[-a\nb-]cd\n----\n",
|
|
598
|
+
"(L2), LL1-2\ncd{+X\nY+}e\n\n----\n",
|
|
599
|
+
"L3, L3\ne\n[-f-]{+F+}\n\n----\n",
|
|
593
600
|
]
|
|
594
601
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
595
602
|
assert_equal(expected, view.to_wdiff_digest(nil, false))
|
|
@@ -600,9 +607,9 @@ class TestView < Test::Unit::TestCase
|
|
|
600
607
|
array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"]
|
|
601
608
|
expected = [
|
|
602
609
|
"----\n",
|
|
603
|
-
"
|
|
604
|
-
"(
|
|
605
|
-
"
|
|
610
|
+
"LL1-2, (L1)\na\nbcd\n[-a\nb-]cd\n----\n",
|
|
611
|
+
"(L2), LL1-2\ncde\n\ncd{+X\nY+}e\n\n----\n",
|
|
612
|
+
"L3, L3\ne\n[-f-]\n\ne\n{+F+}\n\n----\n",
|
|
606
613
|
]
|
|
607
614
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
608
615
|
assert_equal(expected, view.to_wdiff_digest({ display: "block" }, false))
|
|
@@ -673,9 +680,9 @@ class TestView < Test::Unit::TestCase
|
|
|
673
680
|
end_after_change: "</!+>",
|
|
674
681
|
}
|
|
675
682
|
expected = [
|
|
676
|
-
"
|
|
677
|
-
"(
|
|
678
|
-
"
|
|
683
|
+
"LL1-2, (L1) <->a\nb</->cd\n",
|
|
684
|
+
"(L2), LL1-2 cd<+>X\nY</+>e\n\n",
|
|
685
|
+
"L3, L3 e\n<!->f</!-><!+>F</!+>\n\n",
|
|
679
686
|
]
|
|
680
687
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
681
688
|
assert_equal(expected, view.to_user_digest(user_tags, false))
|
|
@@ -698,9 +705,9 @@ class TestView < Test::Unit::TestCase
|
|
|
698
705
|
display: "block",
|
|
699
706
|
}
|
|
700
707
|
expected = [
|
|
701
|
-
"
|
|
702
|
-
"(
|
|
703
|
-
"
|
|
708
|
+
"LL1-2, (L1) a\nbcd<->a\nb</->cd\n",
|
|
709
|
+
"(L2), LL1-2 cde\ncd<+>X\nY</+>e\n\n",
|
|
710
|
+
"L3, L3 e\n<!->f</!->\ne\n<!+>F</!+>\n\n",
|
|
704
711
|
]
|
|
705
712
|
view = Difference.new(array1, array2).to_view("US-ASCII", "LF")
|
|
706
713
|
assert_equal(expected, view.to_user_digest(user_tags, false))
|
|
@@ -721,7 +728,7 @@ class TestView < Test::Unit::TestCase
|
|
|
721
728
|
assert_equal(expected, view.difference_whole)
|
|
722
729
|
end
|
|
723
730
|
|
|
724
|
-
# def test_difference_digest
|
|
731
|
+
# def test_difference_digest
|
|
725
732
|
# array1 = ["a", "\n", "b", "c", "d", "e", "\n", "f", "\n"] # a \n b c d e \n f \n
|
|
726
733
|
# array2 = ["c", "d", "X", "\n", "Y", "e", "\n", "F", "\n"] # c d X \n Y e \n F \n
|
|
727
734
|
# expected = [
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docdiff
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hisashi Morita
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-04-05 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: test-unit
|
|
@@ -27,7 +27,7 @@ description: |-
|
|
|
27
27
|
DocDiff compares two text files and shows the
|
|
28
28
|
difference. It can compare files word by word,
|
|
29
29
|
character by character, or line by line. It has
|
|
30
|
-
several output formats such as
|
|
30
|
+
several output formats such as tty, HTML, Manued,
|
|
31
31
|
or user-defined markup.
|
|
32
32
|
email:
|
|
33
33
|
- hisashim@icloud.com
|
|
@@ -53,15 +53,25 @@ files:
|
|
|
53
53
|
- doc/example/docdiff.conf.example
|
|
54
54
|
- doc/example/docdiffwebui.cgi
|
|
55
55
|
- doc/example/docdiffwebui.html
|
|
56
|
-
- doc/img/screenshot-format-html-digest-firefox.png
|
|
57
|
-
- doc/img/screenshot-format-html-firefox.png
|
|
58
|
-
- doc/img/screenshot-format-tty-cmdexe-en.png
|
|
59
|
-
- doc/img/screenshot-format-tty-cmdexe-ja.png
|
|
60
|
-
- doc/img/screenshot-format-tty-rxvtunicode-en.png
|
|
61
|
-
- doc/img/screenshot-format-tty-rxvtunicode-ja.png
|
|
62
|
-
- doc/img/screenshot-format-tty-xterm-en.png
|
|
63
|
-
- doc/img/screenshot-format-tty-xterm-ja.png
|
|
64
|
-
- doc/img/screenshot-resolution-linewordchar-xterm.png
|
|
56
|
+
- doc/img/old/screenshot-format-html-digest-firefox.png
|
|
57
|
+
- doc/img/old/screenshot-format-html-firefox.png
|
|
58
|
+
- doc/img/old/screenshot-format-tty-cmdexe-en.png
|
|
59
|
+
- doc/img/old/screenshot-format-tty-cmdexe-ja.png
|
|
60
|
+
- doc/img/old/screenshot-format-tty-rxvtunicode-en.png
|
|
61
|
+
- doc/img/old/screenshot-format-tty-rxvtunicode-ja.png
|
|
62
|
+
- doc/img/old/screenshot-format-tty-xterm-en.png
|
|
63
|
+
- doc/img/old/screenshot-format-tty-xterm-ja.png
|
|
64
|
+
- doc/img/old/screenshot-resolution-linewordchar-xterm.png
|
|
65
|
+
- doc/img/screenshot-html.png
|
|
66
|
+
- doc/img/screenshot-tty-char.png
|
|
67
|
+
- doc/img/screenshot-tty-digest-block.png
|
|
68
|
+
- doc/img/screenshot-tty-digest-license-block.png
|
|
69
|
+
- doc/img/screenshot-tty-digest-license.png
|
|
70
|
+
- doc/img/screenshot-tty-digest.png
|
|
71
|
+
- doc/img/screenshot-tty-en-ja.png
|
|
72
|
+
- doc/img/screenshot-tty-manued.png
|
|
73
|
+
- doc/img/screenshot-tty-wdiff.png
|
|
74
|
+
- doc/img/screenshot-tty-word-char.png
|
|
65
75
|
- doc/man/docdiff.adoc
|
|
66
76
|
- doc/news.md
|
|
67
77
|
- doc/shell_completion/_docdiff.zsh
|
|
@@ -110,8 +120,10 @@ files:
|
|
|
110
120
|
- test/fixture/02_ja_utf8_crlf.txt
|
|
111
121
|
- test/fixture/02_ja_utf8_lf.txt
|
|
112
122
|
- test/fixture/format_wdiff.conf
|
|
113
|
-
- test/fixture/
|
|
114
|
-
- test/fixture/
|
|
123
|
+
- test/fixture/humpty_dumpty_01_en.txt
|
|
124
|
+
- test/fixture/humpty_dumpty_01_ja.txt
|
|
125
|
+
- test/fixture/humpty_dumpty_02_en.txt
|
|
126
|
+
- test/fixture/humpty_dumpty_02_ja.txt
|
|
115
127
|
- test/fixture/simple.conf
|
|
116
128
|
- test/test_helper.rb
|
|
117
129
|
- test/view_test.rb
|
|
File without changes
|
|
File without changes
|
/data/doc/img/{screenshot-format-tty-cmdexe-en.png → old/screenshot-format-tty-cmdexe-en.png}
RENAMED
|
File without changes
|
/data/doc/img/{screenshot-format-tty-cmdexe-ja.png → old/screenshot-format-tty-cmdexe-ja.png}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|