review 3.0.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-win.yml +39 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +50 -12
- data/.travis.yml +17 -8
- data/Dockerfile +21 -5
- data/NEWS.ja.md +358 -0
- data/NEWS.md +358 -1
- data/README.md +11 -8
- data/appveyor.yml +1 -3
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -8
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +12 -12
- data/bin/review-epubmaker +3 -35
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +2 -89
- data/bin/review-preproc +14 -19
- data/bin/review-validate +3 -3
- data/bin/review-vol +4 -78
- data/doc/LICENSE +1 -1
- data/doc/config.yml.sample +46 -12
- data/doc/config.yml.sample-simple +4 -2
- data/doc/format.ja.md +37 -13
- data/doc/format.md +35 -20
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +46 -26
- data/doc/quickstart.md +38 -17
- data/lib/epubmaker/epubcommon.rb +10 -5
- data/lib/epubmaker/epubv2.rb +1 -1
- data/lib/epubmaker/epubv3.rb +1 -0
- data/lib/epubmaker/producer.rb +4 -2
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +38 -79
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +6 -5
- data/lib/review/book/index.rb +69 -101
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +28 -5
- data/lib/review/book/volume.rb +3 -4
- data/lib/review/builder.rb +105 -44
- data/lib/review/catalog.rb +13 -16
- data/lib/review/compiler.rb +84 -72
- data/lib/review/configure.rb +19 -8
- data/lib/review/epub2html.rb +37 -4
- data/lib/review/epubmaker.rb +62 -7
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +102 -115
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/i18n.yml +9 -0
- data/lib/review/idgxmlbuilder.rb +153 -74
- data/lib/review/idgxmlmaker.rb +191 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +125 -34
- data/lib/review/latexbuilder.rb +199 -88
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/location.rb +32 -0
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +24 -5
- data/lib/review/markdownbuilder.rb +31 -37
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +44 -22
- data/lib/review/plaintextbuilder.rb +106 -85
- data/lib/review/preprocessor.rb +32 -41
- data/lib/review/rstbuilder.rb +33 -33
- data/lib/review/textmaker.rb +19 -3
- data/lib/review/textutils.rb +76 -2
- data/lib/review/tocprinter.rb +231 -102
- data/lib/review/topbuilder.rb +114 -61
- data/lib/review/update.rb +19 -19
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +99 -0
- data/lib/review/webmaker.rb +11 -4
- data/lib/review/webtocprinter.rb +38 -35
- data/lib/review/yamlloader.rb +26 -16
- data/review.gemspec +6 -4
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +154 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/config.yml +2 -2
- data/samples/sample-book/src/lib/tasks/review.rake +29 -14
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch01.re +4 -2
- data/samples/syntax-book/ch02.re +8 -16
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/lib/tasks/review.rake +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +16 -0
- data/templates/latex/layout.tex.erb +4 -0
- data/templates/latex/review-jlreq/review-base.sty +150 -61
- data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
- data/templates/latex/review-jlreq/review-style.sty +4 -1
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +101 -23
- data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
- data/templates/latex/review-jsbook/review-style.sty +5 -2
- data/templates/opf/epubv3.opf.erb +1 -0
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/test_template.tex +24 -3
- data/test/assets/test_template_backmatter.tex +24 -3
- data/test/test_book.rb +75 -21
- data/test/test_book_chapter.rb +4 -2
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +16 -0
- data/test/test_catalog.rb +24 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +15 -7
- data/test/test_htmlbuilder.rb +909 -159
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +395 -38
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +50 -10
- data/test/test_latexbuilder.rb +1194 -106
- data/test/test_latexbuilder_v2.rb +628 -97
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +134 -16
- data/test/test_md2inaobuilder.rb +32 -9
- data/test/test_pdfmaker.rb +18 -1
- data/test/test_pdfmaker_cmd.rb +100 -6
- data/test/test_plaintextbuilder.rb +371 -25
- data/test/test_preprocessor.rb +2 -16
- data/test/test_rstbuilder.rb +249 -26
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +546 -31
- data/test/test_update.rb +17 -8
- data/test/test_webtocprinter.rb +66 -34
- data/test/test_yamlloader.rb +13 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/jis/jsarticle.cls +53 -14
- data/vendor/jsclasses/jis/jsbook.cls +53 -14
- data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.sty +3 -3
- data/vendor/jsclasses/jis/jspf.cls +52 -13
- data/vendor/jsclasses/jis/jsreport.cls +53 -14
- data/vendor/jsclasses/jis/kiyou.cls +53 -14
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.sty +3 -4
- data/vendor/jsclasses/jsarticle.cls +53 -14
- data/vendor/jsclasses/jsbook.cls +53 -14
- data/vendor/jsclasses/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +3 -3
- data/vendor/jsclasses/jspf.cls +52 -13
- data/vendor/jsclasses/jsreport.cls +53 -14
- data/vendor/jsclasses/kiyou.cls +53 -14
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +3 -4
- metadata +55 -10
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
data/test/test_preprocessor.rb
CHANGED
@@ -2,22 +2,8 @@ require 'test_helper'
|
|
2
2
|
require 'review/preprocessor'
|
3
3
|
require 'stringio'
|
4
4
|
|
5
|
-
class
|
5
|
+
class PreprocessorTest < Test::Unit::TestCase
|
6
6
|
include ReVIEW
|
7
7
|
|
8
|
-
|
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
|
data/test/test_rstbuilder.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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::
|
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
|
-
|
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::
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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::
|
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
|
-
|
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::
|
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
|
-
|
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
|