review 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-win.yml +39 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.rubocop.yml +10 -7
  5. data/Dockerfile +21 -5
  6. data/NEWS.ja.md +101 -1
  7. data/NEWS.md +102 -2
  8. data/README.md +10 -7
  9. data/appveyor.yml +0 -20
  10. data/bin/review-compile +1 -1
  11. data/bin/review-validate +1 -1
  12. data/doc/config.yml.sample +12 -1
  13. data/doc/config.yml.sample-simple +1 -0
  14. data/doc/format.ja.md +16 -4
  15. data/doc/format.md +2 -1
  16. data/doc/quickstart.ja.md +40 -23
  17. data/doc/quickstart.md +33 -15
  18. data/lib/review/book/base.rb +8 -7
  19. data/lib/review/book/index.rb +50 -56
  20. data/lib/review/book/index/item.rb +1 -1
  21. data/lib/review/builder.rb +26 -4
  22. data/lib/review/compiler.rb +6 -3
  23. data/lib/review/configure.rb +5 -3
  24. data/lib/review/epubmaker.rb +15 -2
  25. data/lib/review/extentions/string.rb +0 -4
  26. data/lib/review/htmlbuilder.rb +4 -15
  27. data/lib/review/idgxmlbuilder.rb +10 -19
  28. data/lib/review/idgxmlmaker.rb +10 -3
  29. data/lib/review/init.rb +8 -1
  30. data/lib/review/latexbuilder.rb +13 -6
  31. data/lib/review/pdfmaker.rb +24 -9
  32. data/lib/review/rstbuilder.rb +2 -2
  33. data/lib/review/textmaker.rb +7 -1
  34. data/lib/review/tocparser.rb +6 -2
  35. data/lib/review/version.rb +1 -1
  36. data/lib/review/webmaker.rb +8 -1
  37. data/review.gemspec +2 -2
  38. data/samples/sample-book/src/.gitignore +1 -0
  39. data/samples/sample-book/src/config-ebook.yml +4 -0
  40. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  41. data/samples/sample-book/src/config.yml +1 -1
  42. data/samples/sample-book/src/lib/tasks/review.rake +10 -6
  43. data/samples/syntax-book/ch01.re +4 -2
  44. data/samples/syntax-book/ch02.re +8 -16
  45. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  46. data/samples/syntax-book/config-print.yml +3 -0
  47. data/samples/syntax-book/config.yml +1 -1
  48. data/samples/syntax-book/lib/tasks/review.rake +23 -8
  49. data/templates/latex/config.erb +6 -6
  50. data/templates/latex/review-jlreq/review-base.sty +14 -4
  51. data/templates/latex/review-jlreq/review-jlreq.cls +10 -1
  52. data/templates/latex/review-jlreq/review-style.sty +1 -1
  53. data/templates/latex/review-jsbook/review-base.sty +10 -0
  54. data/templates/latex/review-jsbook/review-jsbook.cls +1 -1
  55. data/templates/latex/review-jsbook/review-style.sty +1 -1
  56. data/test/assets/test_template.tex +6 -6
  57. data/test/assets/test_template_backmatter.tex +6 -6
  58. data/test/test_book.rb +8 -0
  59. data/test/test_book_chapter.rb +4 -2
  60. data/test/test_catalog.rb +1 -0
  61. data/test/test_epubmaker_cmd.rb +12 -5
  62. data/test/test_helper.rb +11 -6
  63. data/test/test_htmlbuilder.rb +80 -8
  64. data/test/test_idgxmlbuilder.rb +57 -2
  65. data/test/test_idgxmlmaker_cmd.rb +46 -0
  66. data/test/test_image_finder.rb +52 -70
  67. data/test/test_index.rb +12 -12
  68. data/test/test_latexbuilder.rb +171 -8
  69. data/test/test_latexbuilder_v2.rb +9 -7
  70. data/test/test_pdfmaker_cmd.rb +99 -5
  71. data/test/test_textmaker_cmd.rb +54 -0
  72. data/test/test_topbuilder.rb +59 -0
  73. data/vendor/jsclasses/LICENSE +1 -1
  74. data/vendor/jsclasses/jis/jsarticle.cls +53 -14
  75. data/vendor/jsclasses/jis/jsbook.cls +53 -14
  76. data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
  77. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  78. data/vendor/jsclasses/jis/jslogo.sty +3 -3
  79. data/vendor/jsclasses/jis/jspf.cls +52 -13
  80. data/vendor/jsclasses/jis/jsreport.cls +53 -14
  81. data/vendor/jsclasses/jis/kiyou.cls +53 -14
  82. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  83. data/vendor/jsclasses/jis/okumacro.sty +3 -4
  84. data/vendor/jsclasses/jsarticle.cls +53 -14
  85. data/vendor/jsclasses/jsbook.cls +53 -14
  86. data/vendor/jsclasses/jsclasses.dtx +84 -25
  87. data/vendor/jsclasses/jsclasses.pdf +0 -0
  88. data/vendor/jsclasses/jslogo.dtx +4 -4
  89. data/vendor/jsclasses/jslogo.pdf +0 -0
  90. data/vendor/jsclasses/jslogo.sty +3 -3
  91. data/vendor/jsclasses/jspf.cls +52 -13
  92. data/vendor/jsclasses/jsreport.cls +53 -14
  93. data/vendor/jsclasses/kiyou.cls +53 -14
  94. data/vendor/jsclasses/okumacro.dtx +4 -5
  95. data/vendor/jsclasses/okumacro.pdf +0 -0
  96. data/vendor/jsclasses/okumacro.sty +3 -4
  97. metadata +15 -6
  98. data/samples/syntax-book/review-ext.rb +0 -14
@@ -1,8 +1,16 @@
1
1
  require 'book_test_helper'
2
+ require 'fileutils'
2
3
 
3
4
  class BookTest < Test::Unit::TestCase
4
5
  include BookTestHelper
5
6
 
7
+ def setup
8
+ if ENV['GITHUB_WORKSPACE']
9
+ ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
10
+ FileUtils.mkdir_p(ENV['TMPDIR'])
11
+ end
12
+ end
13
+
6
14
  def assert_same_path(expected, result, *options)
7
15
  require 'pathname'
8
16
  ex_path = Pathname(expected).realpath
@@ -37,11 +37,13 @@ class ChapterTest < Test::Unit::TestCase
37
37
 
38
38
  def test_size
39
39
  ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
40
- assert_equal File.size(__FILE__), ch.size
40
+ filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
41
+ assert_equal filesize, ch.size
41
42
 
42
43
  File.open(__FILE__, 'r') do |i|
43
44
  ch = Book::Chapter.new(nil, nil, nil, nil, i)
44
- assert_equal File.size(__FILE__), ch.size
45
+ filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
46
+ assert_equal filesize, ch.size
45
47
  end
46
48
  end
47
49
 
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'book_test_helper'
2
3
  require 'review/catalog'
3
4
 
4
5
  class CatalogTest < Test::Unit::TestCase
@@ -21,18 +21,25 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
21
21
  ENV['RUBYLIB'] = @old_rubylib
22
22
  end
23
23
 
24
- def test_epubmaker_cmd
24
+ def common_buildepub(bookdir, configfile, targetepubfile)
25
25
  if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
26
- config = prepare_samplebook(@tmpdir1)
26
+ config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
27
27
  builddir = File.join(@tmpdir1, config['bookname'] + '-epub')
28
28
  assert !File.exist?(builddir)
29
29
 
30
30
  ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
31
31
  Dir.chdir(@tmpdir1) do
32
- system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} config.yml 1>/dev/null 2>/dev/null")
32
+ system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} #{configfile} 1>/dev/null 2>/dev/null")
33
33
  end
34
-
35
- assert File.exist?(builddir)
34
+ assert File.exist?(File.join(@tmpdir1, targetepubfile))
36
35
  end
37
36
  end
37
+
38
+ def test_epubmaker_cmd_samplebook
39
+ common_buildepub('sample-book/src', 'config.yml', 'book.epub')
40
+ end
41
+
42
+ def test_epubmaker_cmd_syntaxbook
43
+ common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub')
44
+ end
38
45
  end
@@ -1,6 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
2
2
  require 'test/unit'
3
3
  require 'fileutils'
4
+ require 'review/yamlloader'
5
+ require 'review/extentions'
4
6
 
5
7
  def touch_file(path)
6
8
  FileUtils.touch(path)
@@ -10,13 +12,16 @@ def assets_dir
10
12
  File.join(File.dirname(__FILE__), 'assets')
11
13
  end
12
14
 
13
- def prepare_samplebook(srcdir)
14
- samplebook_dir = File.expand_path('../samples/sample-book/src/', File.dirname(__FILE__))
15
+ def prepare_samplebook(srcdir, bookdir, latextemplatedir, configfile)
16
+ samplebook_dir = File.expand_path("../samples/#{bookdir}/", File.dirname(__FILE__))
15
17
  FileUtils.cp_r(Dir.glob(File.join(samplebook_dir, '*')), srcdir)
16
- # copy from review-jsbook
17
- template_dir = File.expand_path('../templates/latex/review-jsbook/', File.dirname(__FILE__))
18
- FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty'))
19
- YAML.safe_load(File.open(File.join(srcdir, 'config.yml')), [Date])
18
+ if latextemplatedir
19
+ # copy from review-jsbook or review-jlreq
20
+ template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/", File.dirname(__FILE__))
21
+ FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty'))
22
+ end
23
+ loader = ReVIEW::YAMLLoader.new
24
+ loader.load_file(File.open(File.join(srcdir, configfile)))
20
25
  end
21
26
 
22
27
  def compile_inline(text)
@@ -244,8 +244,10 @@ EOS
244
244
 
245
245
  def test_inline_hd_chap
246
246
  def @chapter.headline_index
247
- items = [Book::Index::Item.new('chap1|test', [1, 1], 'te_st')]
248
- Book::HeadlineIndex.new(items, self)
247
+ item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
248
+ idx = Book::HeadlineIndex.new(self)
249
+ idx.add_item(item)
250
+ idx
249
251
  end
250
252
 
251
253
  @config['secnolevel'] = 2
@@ -270,8 +272,10 @@ EOS
270
272
  end
271
273
 
272
274
  def @chapter.headline_index
273
- items = [Book::Index::Item.new('test', [1], 'te_st')]
274
- Book::HeadlineIndex.new(items, self)
275
+ item = Book::Index::Item.new('test', [1], 'te_st')
276
+ idx = Book::HeadlineIndex.new(self)
277
+ idx.add_item(item)
278
+ idx
275
279
  end
276
280
 
277
281
  actual = compile_inline('test @<hd>{test} test2')
@@ -293,8 +297,10 @@ EOS
293
297
  end
294
298
 
295
299
  def @chapter.headline_index
296
- items = [Book::Index::Item.new('test', [1], 'te_st')]
297
- Book::HeadlineIndex.new(items, self)
300
+ item = Book::Index::Item.new('test', [1], 'te_st')
301
+ idx = Book::HeadlineIndex.new(self)
302
+ idx.add_item(item)
303
+ idx
298
304
  end
299
305
 
300
306
  actual = compile_inline('test @<hd>{test} test2')
@@ -772,6 +778,20 @@ EOS
772
778
  assert_equal expected, actual
773
779
  end
774
780
 
781
+ def test_dt_inline
782
+ fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
783
+ @chapter.instance_eval { @footnote_index = fn }
784
+ actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
785
+
786
+ expected = <<-EOS
787
+ <dl>
788
+ <dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]&lt;&gt;&amp;<span class="equation">\\alpha[]</span></dt>
789
+ <dd></dd>
790
+ </dl>
791
+ EOS
792
+ assert_equal expected, actual
793
+ end
794
+
775
795
  def test_list
776
796
  def @chapter.list(_id)
777
797
  Book::Index::Item.new('samplelist', 1)
@@ -1637,8 +1657,10 @@ EOS
1637
1657
 
1638
1658
  def test_column_in_aother_chapter_ref
1639
1659
  def @chapter.column_index
1640
- items = [Book::Index::Item.new('chap1|column', 1, 'column_cap')]
1641
- Book::ColumnIndex.new(items)
1660
+ item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
1661
+ idx = Book::ColumnIndex.new
1662
+ idx.add_item(item)
1663
+ idx
1642
1664
  end
1643
1665
 
1644
1666
  actual = compile_inline('test @<column>{chap1|column} test2')
@@ -2109,6 +2131,56 @@ EOS
2109
2131
  assert_equal expected, actual
2110
2132
  end
2111
2133
 
2134
+ def test_table_row_separator
2135
+ src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
2136
+ expected = <<-EOS
2137
+ <div class="table">
2138
+ <table>
2139
+ <tr><th>1</th><th>2</th><th>3 4| 5</th></tr>
2140
+ <tr><td>a b</td><td>c d |e</td><td></td></tr>
2141
+ </table>
2142
+ </div>
2143
+ EOS
2144
+ actual = compile_block(src)
2145
+ assert_equal expected, actual
2146
+
2147
+ @config['table_row_separator'] = 'singletab'
2148
+ actual = compile_block(src)
2149
+ expected = <<-EOS
2150
+ <div class="table">
2151
+ <table>
2152
+ <tr><th>1</th><th>2</th><th></th><th>3 4| 5</th></tr>
2153
+ <tr><td>a b</td><td>c d |e</td><td></td><td></td></tr>
2154
+ </table>
2155
+ </div>
2156
+ EOS
2157
+ assert_equal expected, actual
2158
+
2159
+ @config['table_row_separator'] = 'spaces'
2160
+ actual = compile_block(src)
2161
+ expected = <<-EOS
2162
+ <div class="table">
2163
+ <table>
2164
+ <tr><th>1</th><th>2</th><th>3</th><th>4|</th><th>5</th></tr>
2165
+ <tr><td>a</td><td>b</td><td>c</td><td>d</td><td>|e</td></tr>
2166
+ </table>
2167
+ </div>
2168
+ EOS
2169
+ assert_equal expected, actual
2170
+
2171
+ @config['table_row_separator'] = 'verticalbar'
2172
+ actual = compile_block(src)
2173
+ expected = <<-EOS
2174
+ <div class="table">
2175
+ <table>
2176
+ <tr><th>1 2 3 4</th><th>5</th></tr>
2177
+ <tr><td>a b c d</td><td>e</td></tr>
2178
+ </table>
2179
+ </div>
2180
+ EOS
2181
+ assert_equal expected, actual
2182
+ end
2183
+
2112
2184
  def test_major_blocks
2113
2185
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
2114
2186
  expected = <<-EOS
@@ -146,6 +146,36 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
146
146
  assert_equal %Q(<table><caption>foo</caption><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
147
147
  end
148
148
 
149
+ def test_table_row_separator
150
+ src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
151
+ expected = <<-EOS.chomp
152
+ <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="3"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">c d |e</td></tbody></table>
153
+ EOS
154
+ actual = compile_block(src)
155
+ assert_equal expected, actual
156
+
157
+ @config['table_row_separator'] = 'singletab'
158
+ actual = compile_block(src)
159
+ expected = <<-EOS.chomp
160
+ <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="4"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086"></td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">c d |e</td></tbody></table>
161
+ EOS
162
+ assert_equal expected, actual
163
+
164
+ @config['table_row_separator'] = 'spaces'
165
+ actual = compile_block(src)
166
+ expected = <<-EOS.chomp
167
+ <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="5"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">3</td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">4|</td><td xyh="5,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">a</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">b</td><td xyh="3,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">c</td><td xyh="4,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">d</td><td xyh="5,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">|e</td></tbody></table>
168
+ EOS
169
+ assert_equal expected, actual
170
+
171
+ @config['table_row_separator'] = 'verticalbar'
172
+ actual = compile_block(src)
173
+ expected = <<-EOS.chomp
174
+ <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">1 2 3 4</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">a b c d</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">e</td></tbody></table>
175
+ EOS
176
+ assert_equal expected, actual
177
+ end
178
+
149
179
  def test_inline_br
150
180
  actual = compile_inline('@<br>{}')
151
181
  assert_equal "\n", actual
@@ -196,6 +226,17 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
196
226
  assert_equal %Q(<dl><dt>foo</dt><dd>foo.</dd></dl><p>para</p><dl><dt>foo</dt><dd>foo.</dd></dl><ol><li aid:pstyle="ol-item" olnum="1" num="1">bar</li></ol><dl><dt>foo</dt><dd>foo.</dd></dl><ul><li aid:pstyle="ul-item">bar</li></ul>), actual
197
227
  end
198
228
 
229
+ def test_dt_inline
230
+ fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
231
+ @chapter.instance_eval { @footnote_index = fn }
232
+ actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
233
+
234
+ expected = <<-EOS.chomp
235
+ <dl><dt>foo<footnote>bar</footnote>[]&lt;&gt;&amp;<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
236
+ EOS
237
+ assert_equal expected, actual
238
+ end
239
+
199
240
  def test_paragraph
200
241
  actual = compile_block("foo\nbar\n")
201
242
  assert_equal '<p>foobar</p>', actual
@@ -430,6 +471,18 @@ EOS
430
471
  <source><pre>foo
431
472
  bar
432
473
 
474
+ buz
475
+ </pre></source>
476
+ EOS
477
+ assert_equal expected, actual
478
+ end
479
+
480
+ def test_source_nil_caption
481
+ actual = compile_block("//source{\nfoo\nbar\n\nbuz\n//}\n")
482
+ expected = <<-EOS.chomp
483
+ <source><pre>foo
484
+ bar
485
+
433
486
  buz
434
487
  </pre></source>
435
488
  EOS
@@ -664,8 +717,10 @@ EOS
664
717
 
665
718
  def test_column_in_aother_chapter_ref
666
719
  def @chapter.column_index
667
- items = [Book::Index::Item.new('chap1|column', 1, 'column_cap')]
668
- Book::ColumnIndex.new(items)
720
+ item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
721
+ idx = Book::ColumnIndex.new
722
+ idx.add_item(item)
723
+ idx
669
724
  end
670
725
 
671
726
  actual = compile_inline('test @<column>{chap1|column} test2')
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+ require 'yaml'
5
+ require 'rbconfig'
6
+ require 'open3'
7
+
8
+ REVIEW_IDGXMLMAKER = File.expand_path('../bin/review-idgxmlmaker', File.dirname(__FILE__))
9
+
10
+ class IDGXMLMakerCmdTest < Test::Unit::TestCase
11
+ def setup
12
+ @tmpdir1 = Dir.mktmpdir
13
+
14
+ @old_rubylib = ENV['RUBYLIB']
15
+ ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
16
+ end
17
+
18
+ def teardown
19
+ FileUtils.rm_rf(@tmpdir1)
20
+ ENV['RUBYLIB'] = @old_rubylib
21
+ end
22
+
23
+ def common_buildidgxml(bookdir, configfile, targetfile, option)
24
+ if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
25
+ config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
26
+ builddir = File.join(@tmpdir1, config['bookname'] + '-idgxml')
27
+ assert !File.exist?(builddir)
28
+
29
+ ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
30
+ Dir.chdir(@tmpdir1) do
31
+ _o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_IDGXMLMAKER} #{option} #{configfile}")
32
+ STDERR.puts e unless e.empty?
33
+ assert s.success?
34
+ end
35
+ assert File.exist?(File.join(@tmpdir1, targetfile))
36
+ end
37
+ end
38
+
39
+ def test_idgxmlmaker_cmd_samplebook
40
+ common_buildidgxml('sample-book/src', 'config.yml', 'book-idgxml/ch01.xml', nil)
41
+ end
42
+
43
+ def test_idgxmlmaker_cmd_syntaxbook
44
+ common_buildidgxml('syntax-book', 'config.yml', 'syntax-book-idgxml/ch01.xml', nil)
45
+ end
46
+ end
@@ -7,93 +7,75 @@ class ImageFinderTest < Test::Unit::TestCase
7
7
  include ReVIEW
8
8
 
9
9
  def setup
10
+ if ENV['GITHUB_WORKSPACE']
11
+ ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
12
+ FileUtils.mkdir_p(ENV['TMPDIR'])
13
+ end
14
+ @dir = Dir.mktmpdir
10
15
  end
11
16
 
12
- def test_find_path_pattern1
13
- dir = Dir.mktmpdir
14
- begin
15
- path = File.join(dir, 'builder/ch01/foo.jpg')
16
- FileUtils.mkdir_p(File.dirname(path))
17
- FileUtils.touch(path)
18
-
19
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
20
- assert_equal(path, finder.find_path('foo'))
21
- ensure
22
- FileUtils.remove_entry_secure(dir)
17
+ def teardown
18
+ if @dir
19
+ FileUtils.remove_entry_secure(@dir)
23
20
  end
24
21
  end
25
22
 
23
+ def test_find_path_pattern1
24
+ path = File.join(@dir, 'builder/ch01/foo.jpg')
25
+ FileUtils.mkdir_p(File.dirname(path))
26
+ FileUtils.touch(path)
27
+
28
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
29
+
30
+ assert_equal(path, finder.find_path('foo'))
31
+ end
32
+
26
33
  def test_find_path_pattern2
27
- dir = Dir.mktmpdir
28
- begin
29
- path = File.join(dir, 'builder/ch01-foo.jpg')
30
- FileUtils.mkdir_p(File.dirname(path))
31
- FileUtils.touch(path)
32
-
33
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
34
- assert_equal(path, finder.find_path('foo'))
35
- ensure
36
- FileUtils.remove_entry_secure(dir)
37
- end
34
+ path = File.join(@dir, 'builder/ch01-foo.jpg')
35
+ FileUtils.mkdir_p(File.dirname(path))
36
+ FileUtils.touch(path)
37
+
38
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
39
+ assert_equal(path, finder.find_path('foo'))
38
40
  end
39
41
 
40
42
  def test_find_path_pattern3
41
- dir = Dir.mktmpdir
42
- begin
43
- path = File.join(dir, 'builder/foo.jpg')
44
- FileUtils.mkdir_p(File.dirname(path))
45
- FileUtils.touch(path)
46
-
47
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
48
- assert_equal(path, finder.find_path('foo'))
49
- ensure
50
- FileUtils.remove_entry_secure(dir)
51
- end
43
+ path = File.join(@dir, 'builder/foo.jpg')
44
+ FileUtils.mkdir_p(File.dirname(path))
45
+ FileUtils.touch(path)
46
+
47
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
48
+ assert_equal(path, finder.find_path('foo'))
52
49
  end
53
50
 
54
51
  def test_find_path_pattern4
55
- dir = Dir.mktmpdir
56
- begin
57
- path = File.join(dir, 'ch01/foo.jpg')
58
- FileUtils.mkdir_p(File.dirname(path))
59
- FileUtils.touch(path)
60
-
61
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
62
- assert_equal(path, finder.find_path('foo'))
63
- ensure
64
- FileUtils.remove_entry_secure(dir)
65
- end
52
+ path = File.join(@dir, 'ch01/foo.jpg')
53
+ FileUtils.mkdir_p(File.dirname(path))
54
+ FileUtils.touch(path)
55
+
56
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
57
+ assert_equal(path, finder.find_path('foo'))
66
58
  end
67
59
 
68
60
  def test_find_path_pattern5
69
- dir = Dir.mktmpdir
70
- begin
71
- path = File.join(dir, 'ch01-foo.jpg')
72
- FileUtils.mkdir_p(File.dirname(path))
73
- FileUtils.touch(path)
74
-
75
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
76
- assert_equal(path, finder.find_path('foo'))
77
- ensure
78
- FileUtils.remove_entry_secure(dir)
79
- end
61
+ path = File.join(@dir, 'ch01-foo.jpg')
62
+ FileUtils.mkdir_p(File.dirname(path))
63
+ FileUtils.touch(path)
64
+
65
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
66
+ assert_equal(path, finder.find_path('foo'))
80
67
  end
81
68
 
82
69
  def test_find_path_dir_symlink
83
- dir = Dir.mktmpdir
84
- begin
85
- path_src = File.join(dir, 'src')
86
- path_dst = File.join(dir, 'ch01')
87
- FileUtils.mkdir_p(path_src)
88
- FileUtils.symlink(path_src, path_dst)
89
- path_srcimg = File.join(path_src, 'foo.jpg')
90
- path_dstimg = File.join(path_dst, 'foo.jpg')
91
- FileUtils.touch(path_srcimg)
92
-
93
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
94
- assert_equal(path_dstimg, finder.find_path('foo'))
95
- ensure
96
- FileUtils.remove_entry_secure(dir)
97
- end
70
+ path_src = File.join(@dir, 'src')
71
+ path_dst = File.join(@dir, 'ch01')
72
+ FileUtils.mkdir_p(path_src)
73
+ FileUtils.symlink(path_src, path_dst)
74
+ path_srcimg = File.join(path_src, 'foo.jpg')
75
+ path_dstimg = File.join(path_dst, 'foo.jpg')
76
+ FileUtils.touch(path_srcimg)
77
+
78
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
79
+ assert_equal(path_dstimg, finder.find_path('foo'))
98
80
  end
99
81
  end