review 1.2.0 → 1.3.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/.gitignore +36 -0
- data/.rubocop.yml +1 -0
- data/ChangeLog +102 -0
- data/README.rdoc +2 -2
- data/bin/review-check +18 -16
- data/bin/review-compile +49 -42
- data/bin/review-epubmaker +23 -993
- data/bin/review-epubmaker-legacy +1024 -0
- data/bin/review-index +17 -15
- data/bin/review-init +39 -9
- data/bin/review-pdfmaker +124 -89
- data/bin/review-preproc +16 -14
- data/bin/review-vol +17 -15
- data/debian/docs +1 -1
- data/doc/catalog.rdoc +34 -0
- data/doc/format.rdoc +16 -2
- data/doc/libepubmaker/{config.yaml → config.yml} +63 -19
- data/doc/quickstart.rdoc +1 -1
- data/doc/{sample.yaml → sample.yml} +0 -0
- data/lib/epubmaker.rb +1 -1
- data/lib/epubmaker/content.rb +9 -1
- data/lib/epubmaker/epubv2.rb +59 -7
- data/lib/epubmaker/epubv3.rb +14 -9
- data/lib/epubmaker/producer.rb +68 -27
- data/lib/epubmaker/resource.rb +3 -1
- data/lib/lineinput.rb +2 -2
- data/lib/review/book/base.rb +125 -24
- data/lib/review/book/chapter.rb +42 -0
- data/lib/review/book/compilable.rb +23 -4
- data/lib/review/book/image_finder.rb +64 -0
- data/lib/review/book/index.rb +64 -50
- data/lib/review/book/page_metric.rb +1 -1
- data/lib/review/builder.rb +19 -12
- data/lib/review/catalog.rb +47 -0
- data/lib/review/compiler.rb +3 -2
- data/lib/review/configure.rb +5 -3
- data/lib/review/epubmaker.rb +130 -46
- data/lib/review/ewbbuilder.rb +27 -31
- data/lib/review/extentions/string.rb +4 -4
- data/lib/review/htmlbuilder.rb +140 -79
- data/lib/review/htmllayout.rb +26 -4
- data/lib/review/htmlutils.rb +20 -1
- data/lib/review/i18n.rb +5 -2
- data/lib/review/{i18n.yaml → i18n.yml} +4 -2
- data/lib/review/idgxmlbuilder.rb +65 -39
- data/lib/review/latexbuilder.rb +72 -24
- data/lib/review/latexutils.rb +3 -1
- data/lib/review/makerhelper.rb +8 -2
- data/lib/review/preprocessor.rb +20 -20
- data/lib/review/review.tex.erb +4 -0
- data/lib/review/sec_counter.rb +9 -11
- data/lib/review/tocparser.rb +2 -2
- data/lib/review/tocprinter.rb +12 -12
- data/lib/review/topbuilder.rb +15 -15
- data/lib/review/version.rb +1 -1
- data/lib/uuid.rb +7 -7
- data/review.gemspec +2 -2
- data/rubocop-todo.yml +443 -0
- data/test/sample-book/src/config.yml +2 -2
- data/test/sample-book/src/{main.css → style.css} +0 -0
- data/test/test_book.rb +46 -48
- data/test/test_book_chapter.rb +25 -13
- data/test/test_builder.rb +3 -3
- data/test/test_catalog.rb +107 -0
- data/test/test_epubmaker.rb +6 -6
- data/test/test_htmlbuilder.rb +160 -39
- data/test/test_htmlutils.rb +22 -0
- data/test/test_i18n.rb +2 -2
- data/test/test_idgxmlbuilder.rb +33 -47
- data/test/test_image_finder.rb +82 -0
- data/test/test_inaobuilder.rb +1 -1
- data/test/test_latexbuilder.rb +35 -39
- data/test/test_lineinput.rb +2 -2
- data/test/test_markdownbuilder.rb +2 -2
- data/test/test_topbuilder.rb +39 -23
- metadata +23 -14
- data/bin/review-epubmaker-ng +0 -23
@@ -38,13 +38,13 @@ coverimage: cover.jpg
|
|
38
38
|
# 固有IDに使用するドメイン
|
39
39
|
urnid: http://tatsu-zine.com/books/review-sample-book/1.0.0/
|
40
40
|
# CSSファイル (yamlファイルおよびRe:VIEWファイルを置いたディレクトリにあること
|
41
|
-
stylesheet:
|
41
|
+
stylesheet: style.css
|
42
42
|
# 目次として抽出するレベル
|
43
43
|
toclevel: 2
|
44
44
|
# セクション番号を表示するレベル
|
45
45
|
secnolevel: 3
|
46
46
|
# review-compileに渡すパラメータ
|
47
|
-
params: --stylesheet=
|
47
|
+
params: --stylesheet=style.css
|
48
48
|
# 目次生成用?
|
49
49
|
mytoc: true
|
50
50
|
# 奥付生成用
|
File without changes
|
data/test/test_book.rb
CHANGED
@@ -17,24 +17,6 @@ class BookTest < Test::Unit::TestCase
|
|
17
17
|
Dir.chdir(dir) do
|
18
18
|
assert_same_path dir, File.expand_path(Book.load_default.basedir), "error in dir CHAPS"
|
19
19
|
end
|
20
|
-
|
21
|
-
subdir = File.join(dir, 'sub')
|
22
|
-
Dir.mkdir(subdir)
|
23
|
-
Dir.chdir(subdir) do
|
24
|
-
assert_same_path dir, File.expand_path(Book.load_default.basedir), "error in dir sub"
|
25
|
-
end
|
26
|
-
|
27
|
-
sub2dir = File.join(dir, 'sub', 'sub')
|
28
|
-
Dir.mkdir(sub2dir)
|
29
|
-
Dir.chdir(sub2dir) do
|
30
|
-
assert_same_path dir, File.expand_path(Book.load_default.basedir), "error in dir sub sub"
|
31
|
-
end
|
32
|
-
|
33
|
-
sub3dir = File.join(dir, 'sub', 'sub', 'sub')
|
34
|
-
Dir.mkdir(sub3dir)
|
35
|
-
Dir.chdir(sub3dir) do
|
36
|
-
assert_same_path sub3dir, File.expand_path(Book.load_default.basedir), "error in dir sub sub sub"
|
37
|
-
end
|
38
20
|
end
|
39
21
|
|
40
22
|
# tests for ReVIEW.book
|
@@ -76,19 +58,6 @@ class BookTest < Test::Unit::TestCase
|
|
76
58
|
assert_equal save_load_path, $LOAD_PATH
|
77
59
|
end
|
78
60
|
|
79
|
-
begin
|
80
|
-
Dir.mktmpdir do |dir|
|
81
|
-
local_lib_path = File.join(dir, 'lib')
|
82
|
-
Dir.mkdir(local_lib_path)
|
83
|
-
Dir.mkdir(File.join(local_lib_path, 'review'))
|
84
|
-
Book.update_rubyenv(dir)
|
85
|
-
assert save_load_path != $LOAD_PATH
|
86
|
-
assert $LOAD_PATH.index(local_lib_path)
|
87
|
-
end
|
88
|
-
ensure
|
89
|
-
$LOAD_PATH.replace save_load_path
|
90
|
-
end
|
91
|
-
|
92
61
|
num = rand(99999)
|
93
62
|
test_const = "ReVIEW__BOOK__TEST__#{num}"
|
94
63
|
begin
|
@@ -171,10 +140,19 @@ class BookTest < Test::Unit::TestCase
|
|
171
140
|
end
|
172
141
|
end
|
173
142
|
|
143
|
+
# backword compatible
|
174
144
|
def test_setParameter
|
175
145
|
book = Book::Base.new(File.dirname(__FILE__))
|
176
146
|
book.param = :test
|
177
|
-
assert_equal :test, book.
|
147
|
+
assert_equal :test, book.param # old way
|
148
|
+
assert_equal :test, book.config # new way
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_setConfig
|
152
|
+
book = Book::Base.new(File.dirname(__FILE__))
|
153
|
+
book.config = :test
|
154
|
+
assert_equal :test, book.param # old way
|
155
|
+
assert_equal :test, book.config # new way
|
178
156
|
end
|
179
157
|
|
180
158
|
def test_parse_chapters
|
@@ -310,7 +288,7 @@ EOC
|
|
310
288
|
end
|
311
289
|
|
312
290
|
mktmpbookdir 'preface.re' => '',
|
313
|
-
|
291
|
+
'PREDEF' => '' do |dir, book, files|
|
314
292
|
assert_equal nil, book.prefaces # XXX: OK?
|
315
293
|
end
|
316
294
|
|
@@ -319,7 +297,7 @@ EOC
|
|
319
297
|
end
|
320
298
|
|
321
299
|
mktmpbookdir 'PREDEF' => 'chapter1',
|
322
|
-
|
300
|
+
'chapter1.re' => '' do |dir, book, files|
|
323
301
|
assert_kind_of Book::Part, book.prefaces
|
324
302
|
assert_equal '', book.prefaces.name
|
325
303
|
assert_equal 1, book.prefaces.chapters.size
|
@@ -328,7 +306,7 @@ EOC
|
|
328
306
|
end
|
329
307
|
|
330
308
|
mktmpbookdir 'PREDEF' => "chapter1\n\nchapter2",
|
331
|
-
|
309
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |dir, book, files|
|
332
310
|
assert_kind_of Book::Part, book.prefaces
|
333
311
|
assert_equal '', book.prefaces.name
|
334
312
|
assert_equal 2, book.prefaces.chapters.size
|
@@ -339,7 +317,7 @@ EOC
|
|
339
317
|
end
|
340
318
|
|
341
319
|
mktmpbookdir 'PREDEF' => "chapter1 chapter2",
|
342
|
-
|
320
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |dir, book, files|
|
343
321
|
assert_kind_of Book::Part, book.prefaces
|
344
322
|
assert_equal '', book.prefaces.name
|
345
323
|
assert_equal 2, book.prefaces.chapters.size # XXX: OK?
|
@@ -352,14 +330,14 @@ EOC
|
|
352
330
|
end
|
353
331
|
|
354
332
|
mktmpbookdir 'PREDEF' => 'chapter1.re',
|
355
|
-
|
333
|
+
'chapter1.re' => '' do |dir, book, files|
|
356
334
|
assert_kind_of Book::Part, book.prefaces
|
357
335
|
assert_equal '', book.prefaces.name
|
358
336
|
assert_equal 1, book.prefaces.chapters.size
|
359
337
|
end
|
360
338
|
|
361
339
|
mktmpbookdir 'PREDEF' => 'chapter1.txt',
|
362
|
-
|
340
|
+
'chapter1.txt' => '' do |dir, book, files|
|
363
341
|
assert_kind_of Book::Part, book.prefaces
|
364
342
|
assert_equal '', book.prefaces.name
|
365
343
|
assert_equal 1, book.prefaces.chapters.size
|
@@ -390,7 +368,7 @@ EOC
|
|
390
368
|
end
|
391
369
|
|
392
370
|
mktmpbookdir 'appendix.re' => '',
|
393
|
-
|
371
|
+
'postscript.re' => '' do |dir, book, files|
|
394
372
|
assert_kind_of Book::Part, book.postscripts
|
395
373
|
assert_equal '', book.postscripts.name
|
396
374
|
assert_equal 2, book.postscripts.chapters.size
|
@@ -403,7 +381,7 @@ EOC
|
|
403
381
|
end
|
404
382
|
|
405
383
|
mktmpbookdir 'preface.re' => '',
|
406
|
-
|
384
|
+
'POSTDEF' => '' do |dir, book, files|
|
407
385
|
assert_equal nil, book.postscripts # XXX: OK?
|
408
386
|
end
|
409
387
|
|
@@ -412,7 +390,7 @@ EOC
|
|
412
390
|
end
|
413
391
|
|
414
392
|
mktmpbookdir 'POSTDEF' => 'chapter1',
|
415
|
-
|
393
|
+
'chapter1.re' => '' do |dir, book, files|
|
416
394
|
assert_kind_of Book::Part, book.postscripts
|
417
395
|
assert_equal '', book.postscripts.name
|
418
396
|
assert_equal 1, book.postscripts.chapters.size
|
@@ -421,7 +399,7 @@ EOC
|
|
421
399
|
end
|
422
400
|
|
423
401
|
mktmpbookdir 'POSTDEF' => "chapter1\n\nchapter2",
|
424
|
-
|
402
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |dir, book, files|
|
425
403
|
assert_kind_of Book::Part, book.postscripts
|
426
404
|
assert_equal '', book.postscripts.name
|
427
405
|
assert_equal 2, book.postscripts.chapters.size
|
@@ -432,7 +410,7 @@ EOC
|
|
432
410
|
end
|
433
411
|
|
434
412
|
mktmpbookdir 'POSTDEF' => "chapter1 chapter2",
|
435
|
-
|
413
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |dir, book, files|
|
436
414
|
assert_kind_of Book::Part, book.postscripts
|
437
415
|
assert_equal '', book.postscripts.name
|
438
416
|
assert_equal 2, book.postscripts.chapters.size # XXX: OK?
|
@@ -470,7 +448,7 @@ EOC
|
|
470
448
|
end
|
471
449
|
|
472
450
|
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3",
|
473
|
-
|
451
|
+
'preface.re' => '' do |dir, book, files|
|
474
452
|
parts = book.parts
|
475
453
|
assert_equal 3, parts.size
|
476
454
|
assert book.part(1)
|
@@ -485,7 +463,7 @@ EOC
|
|
485
463
|
end
|
486
464
|
|
487
465
|
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3",
|
488
|
-
|
466
|
+
'postscript.re' => '' do |dir, book, files|
|
489
467
|
parts = book.parts
|
490
468
|
assert_equal 3, parts.size
|
491
469
|
assert book.part(1)
|
@@ -500,7 +478,7 @@ EOC
|
|
500
478
|
end
|
501
479
|
|
502
480
|
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3",
|
503
|
-
|
481
|
+
'preface.re' => '', 'postscript.re' => '' do |dir, book, files|
|
504
482
|
parts = book.parts
|
505
483
|
assert_equal 4, parts.size
|
506
484
|
assert book.part(1)
|
@@ -519,7 +497,7 @@ EOC
|
|
519
497
|
|
520
498
|
def test_chapters
|
521
499
|
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3",
|
522
|
-
|
500
|
+
'preface.re' => '', 'postscript.re' => '' do |dir, book, files|
|
523
501
|
chapters = book.chapters
|
524
502
|
assert_equal 5, chapters.size
|
525
503
|
|
@@ -539,7 +517,7 @@ EOC
|
|
539
517
|
end
|
540
518
|
|
541
519
|
mktmpbookdir 'CHAPS' => "ch1.txt\nch2.txt\n\nch3.txt",
|
542
|
-
|
520
|
+
'preface.re' => '', 'postscript.re' => '' do |dir, book, files|
|
543
521
|
chapters = book.chapters
|
544
522
|
assert_equal 5, chapters.size
|
545
523
|
|
@@ -559,6 +537,26 @@ EOC
|
|
559
537
|
end
|
560
538
|
end
|
561
539
|
|
540
|
+
def test_next_chapter
|
541
|
+
mktmpbookdir 'CHAPS' => "ch1\nch2" do |dir, book, files|
|
542
|
+
chapter = book.chapter('ch1')
|
543
|
+
assert_equal book.chapter('ch2'), book.next_chapter(chapter)
|
544
|
+
|
545
|
+
chapter = book.chapter('ch2')
|
546
|
+
assert_equal nil, book.next_chapter(chapter)
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
def test_prev_chapter
|
551
|
+
mktmpbookdir 'CHAPS' => "ch1\nch2" do |dir, book, files|
|
552
|
+
chapter = book.chapter('ch2')
|
553
|
+
assert_equal book.chapter('ch1'), book.prev_chapter(chapter)
|
554
|
+
|
555
|
+
chapter = book.chapter('ch1')
|
556
|
+
assert_equal nil, book.prev_chapter(chapter)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
562
560
|
def test_volume
|
563
561
|
mktmpbookdir do |dir, book, files|
|
564
562
|
assert book.volume
|
data/test/test_book_chapter.rb
CHANGED
@@ -133,8 +133,8 @@ class ChapterTest < Test::Unit::TestCase
|
|
133
133
|
ch = Book::Chapter.new(nil, nil, 'foo.bar', nil)
|
134
134
|
assert_equal 'foo', ch.name
|
135
135
|
|
136
|
-
ch = Book::Chapter.new(nil, nil, nil, nil)
|
137
|
-
assert_raises(TypeError) { ch.name } # XXX: OK?
|
136
|
+
# ch = Book::Chapter.new(nil, nil, nil, nil)
|
137
|
+
# assert_raises(TypeError) { ch.name } # XXX: OK?
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_open
|
@@ -161,11 +161,11 @@ class ChapterTest < Test::Unit::TestCase
|
|
161
161
|
|
162
162
|
def test_title
|
163
163
|
io = StringIO.new
|
164
|
-
ch = Book::Chapter.new(
|
164
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, nil, io)
|
165
165
|
assert_equal '', ch.title
|
166
166
|
|
167
167
|
io = StringIO.new("=1\n=2\n")
|
168
|
-
ch = Book::Chapter.new(
|
168
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, nil, io)
|
169
169
|
assert_equal '1', ch.title
|
170
170
|
|
171
171
|
|
@@ -176,8 +176,8 @@ class ChapterTest < Test::Unit::TestCase
|
|
176
176
|
['XYZ', @eucjp_str],
|
177
177
|
].each do |enc, instr|
|
178
178
|
io = StringIO.new("= #{instr}\n")
|
179
|
-
ch = Book::Chapter.new(
|
180
|
-
ReVIEW.book.
|
179
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, nil, io)
|
180
|
+
ReVIEW.book.config = {'inencoding' => enc}
|
181
181
|
assert_equal @utf8_str, ch.title
|
182
182
|
assert_equal @utf8_str, ch.instance_eval { @title }
|
183
183
|
end
|
@@ -195,8 +195,8 @@ class ChapterTest < Test::Unit::TestCase
|
|
195
195
|
tf.print instr
|
196
196
|
tf.close
|
197
197
|
|
198
|
-
ch = Book::Chapter.new(
|
199
|
-
ReVIEW.book.
|
198
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, tf.path)
|
199
|
+
ReVIEW.book.config = {'inencoding' => enc}
|
200
200
|
assert_equal @utf8_str, ch.content
|
201
201
|
assert_equal @utf8_str, ch.instance_eval { @content }
|
202
202
|
ensure
|
@@ -212,8 +212,8 @@ class ChapterTest < Test::Unit::TestCase
|
|
212
212
|
tf2.puts instr
|
213
213
|
tf1.close
|
214
214
|
|
215
|
-
ch = Book::Chapter.new(
|
216
|
-
ReVIEW.book.
|
215
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, tf1.path, tf2)
|
216
|
+
ReVIEW.book.config = {'inencoding' => enc}
|
217
217
|
assert_equal "#{@utf8_str}\n#{@utf8_str}\n", ch.content # XXX: OK?
|
218
218
|
ensure
|
219
219
|
tf1.close(true)
|
@@ -228,7 +228,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
228
228
|
tf.print lines.join('')
|
229
229
|
tf.close
|
230
230
|
|
231
|
-
ch = Book::Chapter.new(
|
231
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, tf.path)
|
232
232
|
assert_equal lines, ch.lines
|
233
233
|
|
234
234
|
lines = ["1\n", "2\n", "3"]
|
@@ -240,7 +240,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
240
240
|
tf2.puts lines.join('')
|
241
241
|
tf2.close
|
242
242
|
|
243
|
-
ch = Book::Chapter.new(
|
243
|
+
ch = Book::Chapter.new(ReVIEW.book, nil, nil, tf1.path, tf2.path)
|
244
244
|
assert_equal lines, ch.lines # XXX: OK?
|
245
245
|
end
|
246
246
|
|
@@ -265,7 +265,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
265
265
|
|
266
266
|
def test_on_CHAPS?
|
267
267
|
mktmpbookdir 'CHAPS' => "chapter1.re\nchapter2.re",
|
268
|
-
|
268
|
+
'chapter1.re' => '12345', 'preface.re' => 'abcde' do |dir, book, files|
|
269
269
|
ch1 = Book::Chapter.new(book, 1, 'chapter1', files['chapter1.re'])
|
270
270
|
pre = Book::Chapter.new(book, nil, 'preface', files['preface.re'])
|
271
271
|
|
@@ -354,6 +354,18 @@ E
|
|
354
354
|
E
|
355
355
|
end
|
356
356
|
|
357
|
+
|
358
|
+
def test_column_index
|
359
|
+
ReVIEW.book.config = {"inencoding" => "utf-8"}
|
360
|
+
do_test_index(<<E, Book::ColumnIndex, :column_index, :column, :propagate => false)
|
361
|
+
= dummy1
|
362
|
+
===[column]{abc} aaaa
|
363
|
+
= dummy2
|
364
|
+
===[column] def
|
365
|
+
== dummy3
|
366
|
+
E
|
367
|
+
end
|
368
|
+
|
357
369
|
def test_image
|
358
370
|
do_test_index(<<E, Book::ImageIndex, :image_index, :image)
|
359
371
|
//image
|
data/test/test_builder.rb
CHANGED
@@ -80,7 +80,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
80
80
|
].each do |m, instr, expstr|
|
81
81
|
b = Builder.new
|
82
82
|
b.bind(nil, nil, nil)
|
83
|
-
ReVIEW.book.
|
83
|
+
ReVIEW.book.config = params
|
84
84
|
b.__send__(m, instr)
|
85
85
|
if "".respond_to?(:encode)
|
86
86
|
assert_equal expstr.encode("UTF-8"), b.result
|
@@ -128,9 +128,9 @@ class BuidlerTest < Test::Unit::TestCase
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_convert_outencoding
|
131
|
-
ReVIEW.book.
|
131
|
+
ReVIEW.book.config = {'outencoding' => "EUC"}
|
132
132
|
b = Builder.new
|
133
|
-
ret = b.convert_outencoding("a", ReVIEW.book.
|
133
|
+
ret = b.convert_outencoding("a", ReVIEW.book.config["outencoding"])
|
134
134
|
assert_equal "a", ret
|
135
135
|
end
|
136
136
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/catalog'
|
3
|
+
|
4
|
+
class CatalogTest < Test::Unit::TestCase
|
5
|
+
include ReVIEW
|
6
|
+
|
7
|
+
def test_predef
|
8
|
+
sut = Catalog.new(yaml)
|
9
|
+
exp =<<-EOS
|
10
|
+
pre01.re
|
11
|
+
pre02.re
|
12
|
+
EOS
|
13
|
+
assert_equal(exp.chomp, sut.predef)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_chaps
|
17
|
+
sut = Catalog.new(yaml)
|
18
|
+
exp =<<-EOS
|
19
|
+
ch01.re
|
20
|
+
ch02.re
|
21
|
+
EOS
|
22
|
+
assert_equal(exp.chomp, sut.chaps)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_chaps_empty
|
26
|
+
yaml = StringIO.new
|
27
|
+
sut = Catalog.new(yaml)
|
28
|
+
assert_equal("", sut.chaps)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_postdef
|
32
|
+
sut = Catalog.new(yaml)
|
33
|
+
exp =<<-EOS
|
34
|
+
post01.re
|
35
|
+
post02.re
|
36
|
+
EOS
|
37
|
+
assert_equal(exp.chomp, sut.postdef)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_chaps_with_parts
|
41
|
+
sut = Catalog.new(yaml_with_parts)
|
42
|
+
exp =<<-EOS
|
43
|
+
ch01.re
|
44
|
+
ch02.re
|
45
|
+
ch03.re
|
46
|
+
ch04.re
|
47
|
+
ch05.re
|
48
|
+
EOS
|
49
|
+
assert_equal(exp.chomp, sut.chaps)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_parts
|
53
|
+
sut = Catalog.new(yaml_with_parts)
|
54
|
+
exp =<<-EOS
|
55
|
+
part1.re
|
56
|
+
part2.re
|
57
|
+
EOS
|
58
|
+
assert_equal(exp.chomp, sut.parts)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_parts_with_empty
|
62
|
+
sut = Catalog.new(yaml)
|
63
|
+
assert_equal("", sut.parts)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_parts2
|
67
|
+
sut = Catalog.new(yaml_with_parts)
|
68
|
+
assert_equal(["ch01.re",
|
69
|
+
{"part1.re" => ["ch02.re"]},
|
70
|
+
"ch03.re",
|
71
|
+
{"part2.re" => ["ch04.re", "ch05.re"]}],
|
72
|
+
sut.parts_with_chaps)
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
def yaml
|
77
|
+
StringIO.new <<-EOS
|
78
|
+
|
79
|
+
PREDEF:
|
80
|
+
- pre01.re
|
81
|
+
- pre02.re
|
82
|
+
|
83
|
+
CHAPS:
|
84
|
+
- ch01.re
|
85
|
+
- ch02.re
|
86
|
+
|
87
|
+
POSTDEF:
|
88
|
+
- post01.re
|
89
|
+
- post02.re
|
90
|
+
|
91
|
+
EOS
|
92
|
+
end
|
93
|
+
|
94
|
+
def yaml_with_parts
|
95
|
+
StringIO.new <<-EOS
|
96
|
+
CHAPS:
|
97
|
+
- ch01.re
|
98
|
+
- part1.re:
|
99
|
+
- ch02.re
|
100
|
+
- ch03.re
|
101
|
+
- part2.re:
|
102
|
+
- ch04.re
|
103
|
+
- ch05.re
|
104
|
+
|
105
|
+
EOS
|
106
|
+
end
|
107
|
+
end
|