review 3.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) 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 +50 -12
  5. data/.travis.yml +17 -8
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +358 -0
  8. data/NEWS.md +358 -1
  9. data/README.md +11 -8
  10. data/appveyor.yml +1 -3
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -8
  13. data/bin/review-checkdep +1 -1
  14. data/bin/review-compile +12 -12
  15. data/bin/review-epubmaker +3 -35
  16. data/bin/review-idgxmlmaker +16 -0
  17. data/bin/review-index +2 -89
  18. data/bin/review-preproc +14 -19
  19. data/bin/review-validate +3 -3
  20. data/bin/review-vol +4 -78
  21. data/doc/LICENSE +1 -1
  22. data/doc/config.yml.sample +46 -12
  23. data/doc/config.yml.sample-simple +4 -2
  24. data/doc/format.ja.md +37 -13
  25. data/doc/format.md +35 -20
  26. data/doc/pdfmaker.ja.md +43 -1
  27. data/doc/pdfmaker.md +42 -1
  28. data/doc/quickstart.ja.md +46 -26
  29. data/doc/quickstart.md +38 -17
  30. data/lib/epubmaker/epubcommon.rb +10 -5
  31. data/lib/epubmaker/epubv2.rb +1 -1
  32. data/lib/epubmaker/epubv3.rb +1 -0
  33. data/lib/epubmaker/producer.rb +4 -2
  34. data/lib/review/book.rb +1 -1
  35. data/lib/review/book/base.rb +38 -79
  36. data/lib/review/book/chapter.rb +18 -3
  37. data/lib/review/book/compilable.rb +6 -5
  38. data/lib/review/book/index.rb +69 -101
  39. data/lib/review/book/index/item.rb +40 -0
  40. data/lib/review/book/page_metric.rb +7 -7
  41. data/lib/review/book/part.rb +28 -5
  42. data/lib/review/book/volume.rb +3 -4
  43. data/lib/review/builder.rb +105 -44
  44. data/lib/review/catalog.rb +13 -16
  45. data/lib/review/compiler.rb +84 -72
  46. data/lib/review/configure.rb +19 -8
  47. data/lib/review/epub2html.rb +37 -4
  48. data/lib/review/epubmaker.rb +62 -7
  49. data/lib/review/extentions/string.rb +0 -4
  50. data/lib/review/htmlbuilder.rb +102 -115
  51. data/lib/review/htmlutils.rb +2 -3
  52. data/lib/review/i18n.rb +2 -2
  53. data/lib/review/i18n.yml +9 -0
  54. data/lib/review/idgxmlbuilder.rb +153 -74
  55. data/lib/review/idgxmlmaker.rb +191 -0
  56. data/lib/review/init-web/finish.html +10 -0
  57. data/lib/review/init-web/index.html +190 -0
  58. data/lib/review/init-web/review-layout-design.js +691 -0
  59. data/lib/review/init.rb +125 -34
  60. data/lib/review/latexbuilder.rb +199 -88
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/location.rb +32 -0
  63. data/lib/review/logger.rb +4 -8
  64. data/lib/review/makerhelper.rb +24 -5
  65. data/lib/review/markdownbuilder.rb +31 -37
  66. data/lib/review/md2inaobuilder.rb +3 -5
  67. data/lib/review/pdfmaker.rb +44 -22
  68. data/lib/review/plaintextbuilder.rb +106 -85
  69. data/lib/review/preprocessor.rb +32 -41
  70. data/lib/review/rstbuilder.rb +33 -33
  71. data/lib/review/textmaker.rb +19 -3
  72. data/lib/review/textutils.rb +76 -2
  73. data/lib/review/tocprinter.rb +231 -102
  74. data/lib/review/topbuilder.rb +114 -61
  75. data/lib/review/update.rb +19 -19
  76. data/lib/review/version.rb +1 -1
  77. data/lib/review/volumeprinter.rb +99 -0
  78. data/lib/review/webmaker.rb +11 -4
  79. data/lib/review/webtocprinter.rb +38 -35
  80. data/lib/review/yamlloader.rb +26 -16
  81. data/review.gemspec +6 -4
  82. data/samples/sample-book/README.md +7 -2
  83. data/samples/sample-book/src/.gitignore +154 -0
  84. data/samples/sample-book/src/config-ebook.yml +4 -0
  85. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  86. data/samples/sample-book/src/config-jlreq.yml +6 -0
  87. data/samples/sample-book/src/config.yml +2 -2
  88. data/samples/sample-book/src/lib/tasks/review.rake +29 -14
  89. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  90. data/samples/syntax-book/ch01.re +4 -2
  91. data/samples/syntax-book/ch02.re +8 -16
  92. data/samples/syntax-book/ch03.re +3 -6
  93. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  94. data/samples/syntax-book/config-jlreq.yml +5 -0
  95. data/samples/syntax-book/config-print.yml +3 -0
  96. data/samples/syntax-book/config.yml +1 -1
  97. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  98. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  99. data/templates/latex/config.erb +16 -0
  100. data/templates/latex/layout.tex.erb +4 -0
  101. data/templates/latex/review-jlreq/review-base.sty +150 -61
  102. data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
  103. data/templates/latex/review-jlreq/review-style.sty +4 -1
  104. data/templates/latex/review-jsbook/README.md +39 -0
  105. data/templates/latex/review-jsbook/review-base.sty +101 -23
  106. data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
  107. data/templates/latex/review-jsbook/review-style.sty +5 -2
  108. data/templates/opf/epubv3.opf.erb +1 -0
  109. data/templates/web/html/layout-html5.html.erb +2 -2
  110. data/test/assets/test_template.tex +24 -3
  111. data/test/assets/test_template_backmatter.tex +24 -3
  112. data/test/test_book.rb +75 -21
  113. data/test/test_book_chapter.rb +4 -2
  114. data/test/test_book_part.rb +3 -3
  115. data/test/test_builder.rb +16 -0
  116. data/test/test_catalog.rb +24 -42
  117. data/test/test_catalog_converter_cmd.rb +1 -1
  118. data/test/test_epubmaker_cmd.rb +14 -7
  119. data/test/test_helper.rb +15 -7
  120. data/test/test_htmlbuilder.rb +909 -159
  121. data/test/test_i18n.rb +25 -25
  122. data/test/test_idgxmlbuilder.rb +395 -38
  123. data/test/test_idgxmlmaker_cmd.rb +46 -0
  124. data/test/test_image_finder.rb +52 -70
  125. data/test/test_index.rb +50 -10
  126. data/test/test_latexbuilder.rb +1194 -106
  127. data/test/test_latexbuilder_v2.rb +628 -97
  128. data/test/test_logger.rb +14 -1
  129. data/test/test_makerhelper.rb +3 -3
  130. data/test/test_markdownbuilder.rb +134 -16
  131. data/test/test_md2inaobuilder.rb +32 -9
  132. data/test/test_pdfmaker.rb +18 -1
  133. data/test/test_pdfmaker_cmd.rb +100 -6
  134. data/test/test_plaintextbuilder.rb +371 -25
  135. data/test/test_preprocessor.rb +2 -16
  136. data/test/test_rstbuilder.rb +249 -26
  137. data/test/test_textmaker_cmd.rb +54 -0
  138. data/test/test_textutils.rb +109 -2
  139. data/test/test_topbuilder.rb +546 -31
  140. data/test/test_update.rb +17 -8
  141. data/test/test_webtocprinter.rb +66 -34
  142. data/test/test_yamlloader.rb +13 -0
  143. data/vendor/jsclasses/LICENSE +1 -1
  144. data/vendor/jsclasses/jis/jsarticle.cls +53 -14
  145. data/vendor/jsclasses/jis/jsbook.cls +53 -14
  146. data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
  147. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  148. data/vendor/jsclasses/jis/jslogo.sty +3 -3
  149. data/vendor/jsclasses/jis/jspf.cls +52 -13
  150. data/vendor/jsclasses/jis/jsreport.cls +53 -14
  151. data/vendor/jsclasses/jis/kiyou.cls +53 -14
  152. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  153. data/vendor/jsclasses/jis/okumacro.sty +3 -4
  154. data/vendor/jsclasses/jsarticle.cls +53 -14
  155. data/vendor/jsclasses/jsbook.cls +53 -14
  156. data/vendor/jsclasses/jsclasses.dtx +84 -25
  157. data/vendor/jsclasses/jsclasses.pdf +0 -0
  158. data/vendor/jsclasses/jslogo.dtx +4 -4
  159. data/vendor/jsclasses/jslogo.pdf +0 -0
  160. data/vendor/jsclasses/jslogo.sty +3 -3
  161. data/vendor/jsclasses/jspf.cls +52 -13
  162. data/vendor/jsclasses/jsreport.cls +53 -14
  163. data/vendor/jsclasses/kiyou.cls +53 -14
  164. data/vendor/jsclasses/okumacro.dtx +4 -5
  165. data/vendor/jsclasses/okumacro.pdf +0 -0
  166. data/vendor/jsclasses/okumacro.sty +3 -4
  167. metadata +55 -10
  168. data/lib/review/tocparser.rb +0 -271
  169. data/samples/syntax-book/review-ext.rb +0 -14
  170. data/test/test_tocparser.rb +0 -25
@@ -2,22 +2,8 @@ require 'test_helper'
2
2
  require 'review/preprocessor'
3
3
  require 'stringio'
4
4
 
5
- class PreprocessorStripTest < Test::Unit::TestCase
5
+ class PreprocessorTest < Test::Unit::TestCase
6
6
  include ReVIEW
7
7
 
8
- def test_gets
9
- f = StringIO.new '= Header'
10
- s = Preprocessor::Strip.new(f)
11
- expect = '= Header'
12
- actual = s.gets
13
- assert_equal expect, actual
14
- end
15
-
16
- def test_gets_with_comment
17
- f = StringIO.new '#@warn(write it later)'
18
- s = Preprocessor::Strip.new(f)
19
- expect = '#@#' + "\n"
20
- actual = s.gets
21
- assert_equal expect, actual
22
- end
8
+ ## TODO: add tests
23
9
  end
@@ -30,29 +30,66 @@ class RSTBuidlerTest < Test::Unit::TestCase
30
30
 
31
31
  def test_headline_level1
32
32
  actual = compile_block("={test} this is test.\n")
33
- assert_equal %Q(.. _test:\n\n==========================\nthis is test.\n==========================\n\n), actual
33
+ expected = <<-EOS
34
+ .. _test:
35
+
36
+ ==========================
37
+ this is test.
38
+ ==========================
39
+
40
+ EOS
41
+ assert_equal expected, actual
34
42
  end
35
43
 
36
44
  def test_headline_level1_without_secno
37
45
  @config['secnolevel'] = 0
38
46
  actual = compile_block("={test} this is test.\n")
39
- assert_equal %Q(.. _test:\n\n==========================\nthis is test.\n==========================\n\n), actual
47
+ expected = <<-EOS
48
+ .. _test:
49
+
50
+ ==========================
51
+ this is test.
52
+ ==========================
53
+
54
+ EOS
55
+ assert_equal expected, actual
40
56
  end
41
57
 
42
58
  def test_headline_level2
43
59
  actual = compile_block("=={test} this is test.\n")
44
- assert_equal %Q(.. _test:\n\nthis is test.\n==========================\n\n), actual
60
+ expected = <<-EOS
61
+ .. _test:
62
+
63
+ this is test.
64
+ ==========================
65
+
66
+ EOS
67
+ assert_equal expected, actual
45
68
  end
46
69
 
47
70
  def test_headline_level3
48
71
  actual = compile_block("==={test} this is test.\n")
49
- assert_equal %Q(.. _test:\n\nthis is test.\n--------------------------\n\n), actual
72
+ expected = <<-EOS
73
+ .. _test:
74
+
75
+ this is test.
76
+ --------------------------
77
+
78
+ EOS
79
+ assert_equal expected, actual
50
80
  end
51
81
 
52
82
  def test_headline_level3_with_secno
53
83
  @config['secnolevel'] = 3
54
84
  actual = compile_block("==={test} this is test.\n")
55
- assert_equal %Q(.. _test:\n\nthis is test.\n--------------------------\n\n), actual
85
+ expected = <<-EOS
86
+ .. _test:
87
+
88
+ this is test.
89
+ --------------------------
90
+
91
+ EOS
92
+ assert_equal expected, actual
56
93
  end
57
94
 
58
95
  def test_href
@@ -143,32 +180,90 @@ class RSTBuidlerTest < Test::Unit::TestCase
143
180
 
144
181
  def test_inline_in_table
145
182
  actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
146
- assert_equal %Q( * - ★1☆\n - ▲2☆\n * - ★3☆\n - ▲4☆<>&\n\n), actual
183
+ expected = <<-EOS
184
+ * - ★1☆
185
+ - ▲2☆
186
+ * - ★3☆
187
+ - ▲4☆<>&
188
+
189
+ EOS
190
+ assert_equal expected, actual
147
191
  end
148
192
 
149
193
  def test_emtable
150
194
  actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
151
- assert_equal %Q(.. list-table:: foo\n :header-rows: 1\n\n * - A\n\n * - A\n\n), actual
195
+ expected = <<-EOS
196
+ .. list-table:: foo
197
+ :header-rows: 1
198
+
199
+ * - A
200
+
201
+ * - A
202
+
203
+ EOS
204
+ assert_equal expected, actual
152
205
  end
153
206
 
154
207
  def test_paragraph
155
208
  actual = compile_block("foo\nbar\n")
156
209
  assert_equal %Q(foobar\n\n), actual
210
+
211
+ @book.config['join_lines_by_lang'] = true
212
+ actual = compile_block("foo\nbar\n")
213
+ assert_equal %Q(foo bar\n\n), actual
157
214
  end
158
215
 
159
216
  def test_tabbed_paragraph
160
217
  actual = compile_block("\tfoo\nbar\n")
161
218
  assert_equal %Q(\tfoobar\n\n), actual
219
+
220
+ @book.config['join_lines_by_lang'] = true
221
+ actual = compile_block("\tfoo\nbar\n")
222
+ assert_equal %Q(\tfoo bar\n\n), actual
162
223
  end
163
224
 
164
225
  def test_flushright
165
226
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
166
- assert_equal %Q(.. flushright::\n\n foobar\nbuz\n\n), actual
227
+ expected = <<-EOS
228
+ .. flushright::
229
+
230
+ foobar
231
+ buz
232
+
233
+ EOS
234
+ assert_equal expected, actual
235
+
236
+ @book.config['join_lines_by_lang'] = true
237
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
238
+ expected = <<-EOS
239
+ .. flushright::
240
+
241
+ foo bar
242
+ buz
243
+
244
+ EOS
245
+ assert_equal expected, actual
167
246
  end
168
247
 
169
248
  def test_noindent
170
249
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
171
- assert_equal %Q(foobar\n\nfoo2bar2\n\n), actual
250
+ expected = <<-EOS
251
+ foobar
252
+
253
+ foo2bar2
254
+
255
+ EOS
256
+ assert_equal expected, actual
257
+
258
+ @book.config['join_lines_by_lang'] = true
259
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
260
+ expected = <<-EOS
261
+ foo bar
262
+
263
+ foo2 bar2
264
+
265
+ EOS
266
+ assert_equal expected, actual
172
267
  end
173
268
 
174
269
  def test_comment
@@ -184,79 +279,207 @@ class RSTBuidlerTest < Test::Unit::TestCase
184
279
 
185
280
  def test_list
186
281
  def @chapter.list(_id)
187
- Book::ListIndex::Item.new('test', 1)
282
+ Book::Index::Item.new('test', 1)
188
283
  end
189
284
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
190
- assert_equal %Q(.. _samplelist:\n\n-foo\n-bar\n), actual
285
+ expected = <<-EOS
286
+ .. _samplelist:
287
+
288
+ -foo
289
+ -bar
290
+ EOS
291
+ assert_equal expected, actual
191
292
  end
192
293
 
193
294
  def test_listnum
194
295
  def @chapter.list(_id)
195
- Book::ListIndex::Item.new('test', 1)
296
+ Book::Index::Item.new('test', 1)
196
297
  end
197
298
  actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
198
- assert_equal %Q(.. _test:\n\n1\n2\n\n), actual
299
+ expected = <<-EOS
300
+ .. _test:
301
+
302
+ 1
303
+ 2
304
+
305
+ EOS
306
+ assert_equal expected, actual
199
307
  end
200
308
 
201
309
  def test_emlistnum
202
310
  actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
203
- assert_equal %Q(this is @<b>{test}<&>_\n\n.. code-block:: none\n :linenos:\n\n foo\n bar\n\n), actual
311
+ expected = <<-EOS
312
+ this is @<b>{test}<&>_
313
+
314
+ .. code-block:: none
315
+ :linenos:
316
+
317
+ foo
318
+ bar
319
+
320
+ EOS
321
+ assert_equal expected, actual
204
322
  end
205
323
 
206
324
  def test_major_blocks
207
325
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
208
- expected = %Q(.. note::\n\n A\nB\n\n.. note::\n\n caption\n A\n\n)
326
+ expected = <<-EOS
327
+ .. note::
328
+
329
+ A
330
+ B
331
+
332
+ .. note::
333
+
334
+ caption
335
+ A
336
+
337
+ EOS
209
338
  assert_equal expected, actual
210
339
 
211
340
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
212
- expected = %Q(.. memo::\n\n A\nB\n\n.. memo::\n\n caption\n A\n\n)
341
+ expected = <<-EOS
342
+ .. memo::
343
+
344
+ A
345
+ B
346
+
347
+ .. memo::
348
+
349
+ caption
350
+ A
351
+
352
+ EOS
213
353
  assert_equal expected, actual
214
354
 
215
355
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
216
- expected = %Q(.. info::\n\n A\nB\n\n.. info::\n\n caption\n A\n\n)
356
+ expected = <<-EOS
357
+ .. info::
358
+
359
+ A
360
+ B
361
+
362
+ .. info::
363
+
364
+ caption
365
+ A
366
+
367
+ EOS
217
368
  assert_equal expected, actual
218
369
 
219
370
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
220
- expected = %Q(.. important::\n\n A\nB\n\n.. important::\n\n caption\n A\n\n)
371
+ expected = <<-EOS
372
+ .. important::
373
+
374
+ A
375
+ B
376
+
377
+ .. important::
378
+
379
+ caption
380
+ A
381
+
382
+ EOS
221
383
  assert_equal expected, actual
222
384
 
223
385
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
224
- expected = %Q(.. caution::\n\n A\nB\n\n.. caution::\n\n caption\n A\n\n)
386
+ expected = <<-EOS
387
+ .. caution::
388
+
389
+ A
390
+ B
391
+
392
+ .. caution::
393
+
394
+ caption
395
+ A
396
+
397
+ EOS
225
398
  assert_equal expected, actual
226
399
 
227
400
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
228
- expected = %Q(.. notice::\n\n A\nB\n\n.. notice::\n\n caption\n A\n\n)
401
+ expected = <<-EOS
402
+ .. notice::
403
+
404
+ A
405
+ B
406
+
407
+ .. notice::
408
+
409
+ caption
410
+ A
411
+
412
+ EOS
229
413
  assert_equal expected, actual
230
414
 
231
415
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
232
- expected = %Q(.. warning::\n\n A\nB\n\n.. warning::\n\n caption\n A\n\n)
416
+ expected = <<-EOS
417
+ .. warning::
418
+
419
+ A
420
+ B
421
+
422
+ .. warning::
423
+
424
+ caption
425
+ A
426
+
427
+ EOS
233
428
  assert_equal expected, actual
234
429
 
235
430
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
236
- expected = %Q(.. tip::\n\n A\nB\n\n.. tip::\n\n caption\n A\n\n)
431
+ expected = <<-EOS
432
+ .. tip::
433
+
434
+ A
435
+ B
436
+
437
+ .. tip::
438
+
439
+ caption
440
+ A
441
+
442
+ EOS
237
443
  assert_equal expected, actual
238
444
  end
239
445
 
240
446
  def test_image
241
447
  def @chapter.image(_id)
242
- item = Book::ImageIndex::Item.new('sampleimg', 1)
448
+ item = Book::Index::Item.new('sampleimg', 1)
243
449
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
244
450
  item
245
451
  end
246
452
 
247
453
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
248
- assert_equal %Q(.. _sampleimg:\n\n.. figure:: images/-/sampleimg.png\n\n sample photo\n\n), actual
454
+ expected = <<-EOS
455
+ .. _sampleimg:
456
+
457
+ .. figure:: images/-/sampleimg.png
458
+
459
+ sample photo
460
+
461
+ EOS
462
+ assert_equal expected, actual
249
463
  end
250
464
 
251
465
  def test_image_with_metric
252
466
  def @chapter.image(_id)
253
- item = Book::ImageIndex::Item.new('sampleimg', 1)
467
+ item = Book::Index::Item.new('sampleimg', 1)
254
468
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
255
469
  item
256
470
  end
257
471
 
258
472
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
259
- assert_equal %Q(.. _sampleimg:\n\n.. figure:: images/-/sampleimg.png\n :scale:120.0%\n\n sample photo\n\n), actual
473
+ expected = <<-EOS
474
+ .. _sampleimg:
475
+
476
+ .. figure:: images/-/sampleimg.png
477
+ :scale:120.0%
478
+
479
+ sample photo
480
+
481
+ EOS
482
+ assert_equal expected, actual
260
483
  end
261
484
 
262
485
  def test_texequation
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+ require 'yaml'
5
+ require 'rbconfig'
6
+ require 'open3'
7
+
8
+ REVIEW_TEXTMAKER = File.expand_path('../bin/review-textmaker', File.dirname(__FILE__))
9
+
10
+ class TEXTMakerCmdTest < 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_buildtext(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'] + '-text')
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_TEXTMAKER} #{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_textmaker_cmd_samplebook
40
+ common_buildtext('sample-book/src', 'config.yml', 'book-text/ch01.txt', nil)
41
+ end
42
+
43
+ def test_textmaker_cmd_samplebook_plain
44
+ common_buildtext('sample-book/src', 'config.yml', 'book-text/ch01.txt', '-n')
45
+ end
46
+
47
+ def test_textmaker_cmd_syntaxbook
48
+ common_buildtext('syntax-book', 'config.yml', 'syntax-book-text/ch01.txt', nil)
49
+ end
50
+
51
+ def test_textmaker_cmd_syntaxbook_plain
52
+ common_buildtext('syntax-book', 'config.yml', 'syntax-book-text/ch01.txt', '-n')
53
+ end
54
+ end