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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -36
  3. data/README_ja.md +70 -37
  4. data/doc/example/docdiff.conf.example +3 -0
  5. data/doc/img/screenshot-html.png +0 -0
  6. data/doc/img/screenshot-tty-char.png +0 -0
  7. data/doc/img/screenshot-tty-digest-block.png +0 -0
  8. data/doc/img/screenshot-tty-digest-license-block.png +0 -0
  9. data/doc/img/screenshot-tty-digest-license.png +0 -0
  10. data/doc/img/screenshot-tty-digest.png +0 -0
  11. data/doc/img/screenshot-tty-en-ja.png +0 -0
  12. data/doc/img/screenshot-tty-manued.png +0 -0
  13. data/doc/img/screenshot-tty-wdiff.png +0 -0
  14. data/doc/img/screenshot-tty-word-char.png +0 -0
  15. data/doc/man/docdiff.adoc +3 -3
  16. data/doc/news.md +11 -0
  17. data/docdiff.gemspec +1 -1
  18. data/lib/doc_diff.rb +5 -5
  19. data/lib/docdiff/charstring.rb +36 -40
  20. data/lib/docdiff/cli.rb +23 -10
  21. data/lib/docdiff/document.rb +44 -44
  22. data/lib/docdiff/encoding/en_ascii.rb +4 -4
  23. data/lib/docdiff/version.rb +1 -1
  24. data/lib/docdiff/view.rb +27 -13
  25. data/test/charstring_test.rb +221 -221
  26. data/test/cli_test.rb +12 -12
  27. data/test/document_test.rb +223 -223
  28. data/test/fixture/humpty_dumpty_01_en.txt +4 -0
  29. data/test/fixture/humpty_dumpty_01_ja.txt +4 -0
  30. data/test/fixture/{humpty_dumpty01_ascii_lf.txt → humpty_dumpty_02_en.txt} +2 -2
  31. data/test/fixture/humpty_dumpty_02_ja.txt +4 -0
  32. data/test/view_test.rb +38 -31
  33. metadata +26 -14
  34. data/test/fixture/humpty_dumpty02_ascii_lf.txt +0 -4
  35. /data/doc/img/{screenshot-format-html-digest-firefox.png → old/screenshot-format-html-digest-firefox.png} +0 -0
  36. /data/doc/img/{screenshot-format-html-firefox.png → old/screenshot-format-html-firefox.png} +0 -0
  37. /data/doc/img/{screenshot-format-tty-cmdexe-en.png → old/screenshot-format-tty-cmdexe-en.png} +0 -0
  38. /data/doc/img/{screenshot-format-tty-cmdexe-ja.png → old/screenshot-format-tty-cmdexe-ja.png} +0 -0
  39. /data/doc/img/{screenshot-format-tty-rxvtunicode-en.png → old/screenshot-format-tty-rxvtunicode-en.png} +0 -0
  40. /data/doc/img/{screenshot-format-tty-rxvtunicode-ja.png → old/screenshot-format-tty-rxvtunicode-ja.png} +0 -0
  41. /data/doc/img/{screenshot-format-tty-xterm-en.png → old/screenshot-format-tty-xterm-en.png} +0 -0
  42. /data/doc/img/{screenshot-format-tty-xterm-ja.png → old/screenshot-format-tty-xterm-ja.png} +0 -0
  43. /data/doc/img/{screenshot-resolution-linewordchar-xterm.png → old/screenshot-resolution-linewordchar-xterm.png} +0 -0
@@ -0,0 +1,4 @@
1
+ Humpty Dumpty sat on a wall,
2
+ Poor Humpty Dumpty had a fall.
3
+ All the queen's horses and all the queen's men
4
+ Couldn't put Humpty together again.
@@ -0,0 +1,4 @@
1
+ ハンプティ・ダンプティ、塀の上に座った
2
+ あわれなハンプティ・ダンプティ、落っこちた
3
+ 女王様の馬をみな集めても、女王様の家来みなでかかっても
4
+ ハンプティを元に戻せなかった
@@ -1,4 +1,4 @@
1
- Humpty Dumpty sat on a wall.
1
+ Humpty Dumpty sat on a wall,
2
2
  Humpty Dumpty had a great fall.
3
3
  All the king's horses and all the king's men
4
- Couldn't put Humpty together again!
4
+ Couldn't put Humpty together again.
@@ -0,0 +1,4 @@
1
+ ハンプティ・ダンプティ、塀の上に座った
2
+ ハンプティ・ダンプティ、まっさかさまに落っこちた
3
+ 王様の馬をみな集めても、王様の家来みなでかかっても
4
+ ハンプティを元に戻せなかった
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
- "1-2,(1)\n\033[7;4;31ma\nb\033[0mcd\n----\n",
243
- "(2),1-2\ncd\033[7;1;34mX\nY\033[0me\n\n----\n",
244
- "3,3\ne\n\033[7;4;33mf\033[0m\033[7;1;32mF\033[0m\n\n----\n",
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
- "1-2,(1)\na\nbcd\n\033[7;4;31ma\nb\033[0mcd\n----\n",
256
- "(2),1-2\ncde\n\ncd\033[7;1;34mX\nY\033[0me\n\n----\n",
257
- "3,3\ne\n\033[7;4;33mf\033[0m\n\ne\n\033[7;1;32mF\033[0m\n\n----\n",
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\">1-2,(1)</p><blockquote class=\"body\"><p class=\"body\"><span class=\"del\"><del>a<br />\nb</del></span>cd</p></blockquote></li>\n",
301
- "<li class=\"entry\"><p class=\"position\">(2),1-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",
302
- "<li class=\"entry\"><p class=\"position\">3,3</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",
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\">1-2,(1)</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",
315
- "<li class=\"entry\"><p class=\"position\">(2),1-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",
316
- "<li class=\"entry\"><p class=\"position\">3,3</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",
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
- "1-2,(1)\n[a\nb/]cd\n----\n",
495
- "(2),1-2\ncd[/X\nY]e\n\n----\n",
496
- "3,3\ne\n[f/F]\n\n----\n",
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
- "1-2,(1)\na\nbcd\n[a\nb/]cd\n----\n",
508
- "(2),1-2\ncde\n\ncd[/X\nY]e\n\n----\n",
509
- "3,3\ne\n[f/]\n\ne\n[/F]\n\n----\n",
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
- "1-2,(1)\n[-a\nb-]cd\n----\n",
591
- "(2),1-2\ncd{+X\nY+}e\n\n----\n",
592
- "3,3\ne\n[-f-]{+F+}\n\n----\n",
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
- "1-2,(1)\na\nbcd\n[-a\nb-]cd\n----\n",
604
- "(2),1-2\ncde\n\ncd{+X\nY+}e\n\n----\n",
605
- "3,3\ne\n[-f-]\n\ne\n{+F+}\n\n----\n",
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
- "1-2,(1) <->a\nb</->cd\n",
677
- "(2),1-2 cd<+>X\nY</+>e\n\n",
678
- "3,3 e\n<!->f</!-><!+>F</!+>\n\n",
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
- "1-2,(1) a\nbcd<->a\nb</->cd\n",
702
- "(2),1-2 cde\ncd<+>X\nY</+>e\n\n",
703
- "3,3 e\n<!->f</!->\ne\n<!+>F</!+>\n\n",
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.6.7
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-02-25 00:00:00.000000000 Z
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 HTML, tty, Manued,
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/humpty_dumpty01_ascii_lf.txt
114
- - test/fixture/humpty_dumpty02_ascii_lf.txt
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
@@ -1,4 +0,0 @@
1
- Humpty Dumpty was sitting on a Humpty Dumpty wall.
2
- Humpty had a great fall by mistake.
3
- All the king's men and all the king's horses
4
- Couldn't put Humpty Dumpty together!