review 1.7.2 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -43
- data/.travis.yml +0 -9
- data/ChangeLog +0 -16
- data/Gemfile +1 -0
- data/README.rdoc +1 -1
- data/Rakefile +12 -1
- data/bin/review-check +21 -8
- data/bin/review-compile +15 -9
- data/bin/review-epubmaker-legacy +6 -6
- data/bin/review-index +13 -2
- data/bin/review-init +18 -12
- data/bin/review-preproc +14 -1
- data/bin/review-validate +1 -1
- data/bin/review-vol +13 -1
- data/doc/quickstart.ja.md +1 -1
- data/doc/quickstart.md +1 -1
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +108 -91
- data/lib/epubmaker/epubv2.rb +67 -14
- data/lib/epubmaker/epubv3.rb +59 -25
- data/lib/epubmaker/producer.rb +1 -13
- data/lib/lineinput.rb +0 -48
- data/lib/review/book/base.rb +4 -12
- data/lib/review/book/compilable.rb +3 -1
- data/lib/review/book/index.rb +4 -4
- data/lib/review/builder.rb +54 -47
- data/lib/review/compiler.rb +4662 -326
- data/lib/review/compiler/literals_1_8.kpeg +19 -0
- data/lib/review/compiler/literals_1_8.rb +432 -0
- data/lib/review/compiler/literals_1_9.kpeg +22 -0
- data/lib/review/compiler/literals_1_9.rb +435 -0
- data/lib/review/configure.rb +8 -20
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +122 -52
- data/lib/review/ewbbuilder.rb +4 -4
- data/lib/review/exception.rb +1 -1
- data/lib/review/extentions.rb +1 -0
- data/lib/review/extentions/array.rb +25 -0
- data/lib/review/htmlbuilder.rb +286 -275
- data/lib/review/htmllayout.rb +0 -2
- data/lib/review/htmlutils.rb +4 -4
- data/lib/review/i18n.rb +2 -6
- data/lib/review/i18n.yml +1 -1
- data/lib/review/idgxmlbuilder.rb +239 -204
- data/lib/review/inaobuilder.rb +75 -73
- data/lib/review/latexbuilder.rb +265 -219
- data/lib/review/latexutils.rb +6 -6
- data/lib/review/layout.tex.erb +1 -1
- data/lib/review/location.rb +24 -0
- data/lib/review/markdownbuilder.rb +124 -79
- data/lib/review/node.rb +267 -0
- data/lib/review/pdfmaker.rb +92 -92
- data/lib/review/preprocessor.rb +51 -14
- data/lib/review/review.kpeg +724 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +24 -18
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +31 -8
- data/lib/review/topbuilder.rb +119 -111
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/review.gemspec +2 -2
- data/rubocop-todo.yml +456 -0
- data/test/assets/test_template.tex +1 -1
- data/test/sample-book/src/config.yml +0 -1
- data/test/test.re +1 -1
- data/test/test_book.rb +4 -4
- data/test/test_book_chapter.rb +70 -0
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +6 -28
- data/test/test_compiler.rb +59 -14
- data/test/test_helper.rb +47 -4
- data/test/test_htmlbuilder.rb +104 -73
- data/test/test_i18n.rb +5 -3
- data/test/test_idgxmlbuilder.rb +5 -2
- data/test/test_inaobuilder.rb +4 -2
- data/test/test_latexbuilder.rb +18 -37
- data/test/test_lineinput.rb +25 -4
- data/test/test_markdownbuilder.rb +4 -22
- data/test/test_pdfmaker.rb +12 -11
- data/test/test_textutils.rb +0 -36
- data/test/test_topbuilder.rb +2 -0
- metadata +14 -28
- data/.rubocop_todo.yml +0 -605
- data/Dockerfile +0 -22
- data/doc/NEWS.ja.md +0 -362
- data/doc/NEWS.md +0 -366
- data/lib/review/htmltoc.rb +0 -45
- data/lib/review/template.rb +0 -21
- data/templates/html/layout-html5.html.erb +0 -17
- data/templates/html/layout-xhtml1.html.erb +0 -20
- data/templates/ncx/epubv2.ncx.erb +0 -11
- data/templates/opf/epubv2.opf.erb +0 -21
- data/templates/opf/epubv3.opf.erb +0 -18
- data/templates/xml/container.xml.erb +0 -6
- data/test/assets/test.xml.erb +0 -3
- data/test/sample-book/src/config-epub2.yml +0 -186
- data/test/test_configure.rb +0 -50
- data/test/test_htmltoc.rb +0 -32
- data/test/test_template.rb +0 -26
data/test/test_i18n.rb
CHANGED
@@ -10,7 +10,7 @@ require 'tmpdir'
|
|
10
10
|
class I18nTest < Test::Unit::TestCase
|
11
11
|
include ReVIEW
|
12
12
|
|
13
|
-
if RUBY_VERSION !~ /^1.8/
|
13
|
+
if RUBY_VERSION !~ /^1.8/ ## to avoid Travis error :-(
|
14
14
|
def test_load_locale_yml
|
15
15
|
Dir.mktmpdir do |dir|
|
16
16
|
Dir.chdir(dir) do
|
@@ -137,8 +137,10 @@ class I18nTest < Test::Unit::TestCase
|
|
137
137
|
I18n.setup "en"
|
138
138
|
@builder = HTMLBuilder.new()
|
139
139
|
@config = {
|
140
|
-
"secnolevel" => 2,
|
141
|
-
"
|
140
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
141
|
+
"inencoding" => "UTF-8",
|
142
|
+
"outencoding" => "UTF-8",
|
143
|
+
"stylesheet" => nil, # for HTMLBuilder
|
142
144
|
"ext" => ".re"
|
143
145
|
}
|
144
146
|
@book = Book::Base.new(".")
|
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -14,6 +14,8 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
@config = ReVIEW::Configure.values
|
15
15
|
@config.merge!({
|
16
16
|
"secnolevel" => 2,
|
17
|
+
"inencoding" => "UTF-8",
|
18
|
+
"outencoding" => "UTF-8",
|
17
19
|
"nolf" => true,
|
18
20
|
"tableopt" => "10"
|
19
21
|
})
|
@@ -175,11 +177,13 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
175
177
|
assert_equal %Q|<quote>foo\n\nbuz</quote>|, actual
|
176
178
|
end
|
177
179
|
|
180
|
+
## XXX block content should be escaped.
|
178
181
|
def test_note
|
179
182
|
actual = compile_block("//note[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
180
183
|
assert_equal %Q|<note><title aid:pstyle='note-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, actual
|
181
184
|
end
|
182
185
|
|
186
|
+
## XXX block content should be escaped.
|
183
187
|
def test_memo
|
184
188
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
185
189
|
assert_equal %Q|<memo><title aid:pstyle='memo-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></memo>|, actual
|
@@ -194,7 +198,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
194
198
|
@book.config["deprecated-blocklines"] = true
|
195
199
|
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
196
200
|
@book.config["deprecated-blocklines"] = nil
|
197
|
-
assert_equal %Q|<term>
|
201
|
+
assert_equal %Q|<term>test1test1.5\n\ntest<i>2</i></term>|, actual
|
198
202
|
end
|
199
203
|
|
200
204
|
def test_notice
|
@@ -603,5 +607,4 @@ EOS
|
|
603
607
|
expected = %Q(|idgxml <>!\"\n& )
|
604
608
|
assert_equal expected.chomp, actual
|
605
609
|
end
|
606
|
-
|
607
610
|
end
|
data/test/test_inaobuilder.rb
CHANGED
@@ -9,8 +9,10 @@ class INAOBuidlerTest < Test::Unit::TestCase
|
|
9
9
|
|
10
10
|
def setup
|
11
11
|
@param = {
|
12
|
-
"secnolevel" => 2,
|
13
|
-
"
|
12
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
13
|
+
"inencoding" => "UTF-8",
|
14
|
+
"outencoding" => "UTF-8",
|
15
|
+
"stylesheet" => nil, # for HTMLBuilder
|
14
16
|
}
|
15
17
|
end
|
16
18
|
|
data/test/test_latexbuilder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'test_helper'
|
3
|
-
require 'review/compiler'
|
4
3
|
require 'review/book'
|
4
|
+
require 'review/compiler'
|
5
5
|
require 'review/latexbuilder'
|
6
6
|
require 'review/i18n'
|
7
7
|
|
@@ -12,9 +12,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
12
12
|
@builder = LATEXBuilder.new()
|
13
13
|
@config = ReVIEW::Configure.values
|
14
14
|
@config.merge!( {
|
15
|
-
"secnolevel" => 2,
|
15
|
+
"secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
|
16
16
|
"toclevel" => 2,
|
17
|
-
"
|
17
|
+
"inencoding" => "UTF-8",
|
18
|
+
"outencoding" => "UTF-8",
|
19
|
+
"stylesheet" => nil, # for EPUBBuilder
|
18
20
|
})
|
19
21
|
@book = Book::Base.new(nil)
|
20
22
|
@book.config = @config
|
@@ -277,34 +279,9 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
277
279
|
assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, actual
|
278
280
|
end
|
279
281
|
|
280
|
-
def test_emlistnum_caption
|
281
|
-
actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
282
|
-
assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n|, actual
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_list
|
286
|
-
actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
287
|
-
assert_equal %Q|\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n|, actual
|
288
|
-
end
|
289
|
-
|
290
|
-
def test_list_lst
|
291
|
-
@book.config["highlight"] = {}
|
292
|
-
@book.config["highlight"]["latex"] = "listings"
|
293
|
-
actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
294
|
-
assert_equal %Q|\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n|, actual
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_list_lst_with_lang
|
298
|
-
@book.config["highlight"] = {}
|
299
|
-
@book.config["highlight"]["latex"] = "listings"
|
300
|
-
@book.config["highlight"]["lang"] = "sql"
|
301
|
-
actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
302
|
-
assert_equal %Q|\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n|, actual
|
303
|
-
end
|
304
|
-
|
305
282
|
def test_listnum
|
306
283
|
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
307
|
-
assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
|
284
|
+
assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\reviewlistcaption{ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
|
308
285
|
end
|
309
286
|
|
310
287
|
def test_listnum_lst
|
@@ -336,7 +313,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
336
313
|
|
337
314
|
def test_noindent
|
338
315
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
339
|
-
assert_equal %Q|\\noindent\
|
316
|
+
assert_equal %Q|\\noindent\nfoobar\n\nfoo2bar2\n|, actual
|
340
317
|
end
|
341
318
|
|
342
319
|
def test_image
|
@@ -383,6 +360,17 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
383
360
|
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual
|
384
361
|
end
|
385
362
|
|
363
|
+
def test_indepimage_esc
|
364
|
+
def @chapter.image(id)
|
365
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
366
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
367
|
+
item
|
368
|
+
end
|
369
|
+
|
370
|
+
actual = compile_block("//indepimage[sean_2_10][sample photo][]\n")
|
371
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual
|
372
|
+
end
|
373
|
+
|
386
374
|
def test_indepimage_without_caption
|
387
375
|
def @chapter.image(id)
|
388
376
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
@@ -479,7 +467,6 @@ EOS
|
|
479
467
|
\\addcontentsline{toc}{subsection}{prev column}
|
480
468
|
|
481
469
|
inside prev column
|
482
|
-
|
483
470
|
\\end{reviewcolumn}
|
484
471
|
|
485
472
|
\\begin{reviewcolumn}
|
@@ -488,7 +475,6 @@ inside prev column
|
|
488
475
|
\\addcontentsline{toc}{subsection}{test}
|
489
476
|
|
490
477
|
inside column
|
491
|
-
|
492
478
|
\\end{reviewcolumn}
|
493
479
|
EOS
|
494
480
|
@config["toclevel"] = 3
|
@@ -510,9 +496,7 @@ EOS
|
|
510
496
|
\\reviewcolumnhead{}{test}
|
511
497
|
|
512
498
|
inside column
|
513
|
-
|
514
499
|
\\end{reviewcolumn}
|
515
|
-
|
516
500
|
\\subsection*{next level}
|
517
501
|
\\label{sec:1-0-1}
|
518
502
|
EOS
|
@@ -598,7 +582,6 @@ EOS
|
|
598
582
|
\\begin{itemize}
|
599
583
|
\\item AA
|
600
584
|
\\end{itemize}
|
601
|
-
|
602
585
|
\\end{itemize}
|
603
586
|
EOS
|
604
587
|
actual = compile_block(src)
|
@@ -621,13 +604,11 @@ EOS
|
|
621
604
|
\\begin{itemize}
|
622
605
|
\\item AA
|
623
606
|
\\end{itemize}
|
624
|
-
|
625
607
|
\\item BBB
|
626
608
|
|
627
609
|
\\begin{itemize}
|
628
610
|
\\item BB
|
629
611
|
\\end{itemize}
|
630
|
-
|
631
612
|
\\end{itemize}
|
632
613
|
EOS
|
633
614
|
actual = compile_block(src)
|
data/test/test_lineinput.rb
CHANGED
@@ -57,6 +57,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
57
57
|
assert_equal -1, li.lineno # XXX: OK?
|
58
58
|
end
|
59
59
|
|
60
|
+
=begin
|
60
61
|
def test_peek
|
61
62
|
li = LineInput.new(StringIO.new)
|
62
63
|
assert_equal nil, li.peek
|
@@ -73,6 +74,25 @@ class LineInputTest < Test::Unit::TestCase
|
|
73
74
|
assert li.next?
|
74
75
|
end
|
75
76
|
|
77
|
+
def test_skip_blank_lines
|
78
|
+
if "".respond_to?(:encode)
|
79
|
+
euc_jp_spc = " ".encode("EUC-JP")
|
80
|
+
else
|
81
|
+
euc_jp_spc = "\xa1\xa1" # EUC-JP 全角空白
|
82
|
+
end
|
83
|
+
[
|
84
|
+
["", 0, nil],
|
85
|
+
["\n \n \nabc", 3, 'abc'],
|
86
|
+
["\t", 1, nil],
|
87
|
+
[euc_jp_spc, 0, euc_jp_spc],
|
88
|
+
].each do |text, n, rest|
|
89
|
+
li = LineInput.new(StringIO.new(text))
|
90
|
+
assert_equal n, li.skip_blank_lines
|
91
|
+
assert_equal rest, li.gets
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
76
96
|
def test_gets_if
|
77
97
|
io = StringIO.new
|
78
98
|
li = LineInput.new(io)
|
@@ -99,7 +119,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
99
119
|
assert_equal "abc\n", li.gets_unless(/^X/)
|
100
120
|
assert_equal nil, li.gets_unless(/^d/)
|
101
121
|
end
|
102
|
-
|
122
|
+
=end
|
103
123
|
def test_each
|
104
124
|
content = "abc\ndef\nghi"
|
105
125
|
io = StringIO.new(content)
|
@@ -118,7 +138,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
118
138
|
assert_equal 2, li.lineno
|
119
139
|
assert_equal "ghi", li.gets
|
120
140
|
end
|
121
|
-
|
141
|
+
=begin
|
122
142
|
def test_getlines_while
|
123
143
|
io = StringIO.new("abc\ndef\nghi")
|
124
144
|
li = LineInput.new(io)
|
@@ -128,7 +148,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
128
148
|
assert_equal 2, li.lineno
|
129
149
|
assert_equal "ghi", li.gets
|
130
150
|
end
|
131
|
-
|
151
|
+
=end
|
132
152
|
def test_until_match
|
133
153
|
io = StringIO.new("abc\ndef\nghi")
|
134
154
|
li = LineInput.new(io)
|
@@ -137,7 +157,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
137
157
|
assert_equal 1, li.lineno
|
138
158
|
assert_equal "def\n", li.gets
|
139
159
|
end
|
140
|
-
|
160
|
+
=begin
|
141
161
|
def test_getlines_until
|
142
162
|
io = StringIO.new("abc\ndef\nghi")
|
143
163
|
li = LineInput.new(io)
|
@@ -176,5 +196,6 @@ class LineInputTest < Test::Unit::TestCase
|
|
176
196
|
assert_equal ["abc\n", "def\n"], data
|
177
197
|
assert_equal 3, li.lineno
|
178
198
|
end
|
199
|
+
=end
|
179
200
|
end
|
180
201
|
|
@@ -12,8 +12,10 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
|
|
12
12
|
def setup
|
13
13
|
@builder = MARKDOWNBuilder.new()
|
14
14
|
@config = {
|
15
|
-
"secnolevel" => 2,
|
16
|
-
"
|
15
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
16
|
+
"inencoding" => "UTF-8",
|
17
|
+
"outencoding" => "UTF-8",
|
18
|
+
"stylesheet" => nil, # for HTMLBuilder
|
17
19
|
}
|
18
20
|
@book = Book::Base.new(nil)
|
19
21
|
@book.config = @config
|
@@ -62,23 +64,6 @@ EOS
|
|
62
64
|
assert_equal "```shell-session\nlineA\nlineB\n```\n", actual
|
63
65
|
end
|
64
66
|
|
65
|
-
|
66
|
-
def test_dlist
|
67
|
-
actual = compile_block(": foo\n foo.\n bar.\n")
|
68
|
-
assert_equal %Q|<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_dlist_with_bracket
|
72
|
-
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
73
|
-
assert_equal %Q|<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_dlist_with_comment
|
77
|
-
source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
|
78
|
-
actual = compile_block(source)
|
79
|
-
assert_equal %Q|<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
|
80
|
-
end
|
81
|
-
|
82
67
|
def test_list
|
83
68
|
actual = compile_block(<<-EOS)
|
84
69
|
//list[name][caption]{
|
@@ -89,7 +74,6 @@ BBB
|
|
89
74
|
|
90
75
|
assert_equal <<-EOS, actual
|
91
76
|
リスト1.1 caption
|
92
|
-
|
93
77
|
```
|
94
78
|
AAA
|
95
79
|
BBB
|
@@ -107,7 +91,6 @@ BBB
|
|
107
91
|
|
108
92
|
assert_equal <<-EOS, actual
|
109
93
|
リスト1.1 caption
|
110
|
-
|
111
94
|
```ruby
|
112
95
|
AAA
|
113
96
|
BBB
|
@@ -126,7 +109,6 @@ BBB
|
|
126
109
|
assert_equal <<-EOS, actual
|
127
110
|
|
128
111
|
caption
|
129
|
-
|
130
112
|
```ruby
|
131
113
|
AAA
|
132
114
|
BBB
|
data/test/test_pdfmaker.rb
CHANGED
@@ -17,7 +17,6 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
17
17
|
"date" => "2011-01-01",
|
18
18
|
"language" => "ja",
|
19
19
|
})
|
20
|
-
@maker.config = @config
|
21
20
|
@output = StringIO.new
|
22
21
|
I18n.setup(@config["language"])
|
23
22
|
end
|
@@ -27,23 +26,24 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
27
26
|
Dir.chdir(dir) do
|
28
27
|
pdf_file = File.join(dir, "sample.pdf")
|
29
28
|
FileUtils.touch(pdf_file)
|
30
|
-
@maker.
|
31
|
-
@maker.remove_old_file
|
29
|
+
@maker.check_book(@config)
|
32
30
|
assert !File.exist?(pdf_file)
|
33
31
|
end
|
34
32
|
end
|
33
|
+
ensure
|
34
|
+
$stderr = STDERR
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_check_book_none
|
38
38
|
Dir.mktmpdir do |dir|
|
39
39
|
assert_nothing_raised do
|
40
|
-
@maker.
|
40
|
+
@maker.check_book(@config)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_buildpath
|
46
|
-
assert_equal(@maker.build_path, "./sample-pdf")
|
46
|
+
assert_equal(@maker.build_path(@config), "./sample-pdf")
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_parse_opts_help
|
@@ -80,7 +80,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
80
80
|
"csl"=>["監修三郎"],
|
81
81
|
"trl"=>["翻訳四郎","翻訳五郎",]})
|
82
82
|
Dir.mktmpdir do |dir|
|
83
|
-
authors = @maker.make_authors
|
83
|
+
authors = @maker.make_authors(@config)
|
84
84
|
assert_equal("テスト太郎、テスト次郎 著 \\\\\n監修三郎 監修 \\\\\n翻訳四郎、翻訳五郎 訳",
|
85
85
|
authors)
|
86
86
|
end
|
@@ -89,7 +89,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
89
89
|
def test_make_authors_only_aut
|
90
90
|
@config.merge!({"aut"=>"テスト太郎"})
|
91
91
|
Dir.mktmpdir do |dir|
|
92
|
-
authors = @maker.make_authors
|
92
|
+
authors = @maker.make_authors(@config)
|
93
93
|
assert_equal("テスト太郎 著", authors)
|
94
94
|
end
|
95
95
|
end
|
@@ -106,7 +106,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
106
106
|
"prt"=>"テスト出版",
|
107
107
|
})
|
108
108
|
Dir.mktmpdir do |dir|
|
109
|
-
okuduke = @maker.make_colophon
|
109
|
+
okuduke = @maker.make_colophon(@config)
|
110
110
|
assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\n翻 訳 & 翻訳四郎、翻訳五郎 \\\\\nデザイン & デザイン六郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n表 紙 & 表紙九郎 \\\\\n編 集 & 編集十郎 \\\\\n発行所 & テスト出版 \\\\\n",
|
111
111
|
okuduke)
|
112
112
|
end
|
@@ -124,7 +124,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
124
124
|
})
|
125
125
|
Dir.mktmpdir do |dir|
|
126
126
|
I18n.update({"prt" => "印刷所"},"ja")
|
127
|
-
okuduke = @maker.make_colophon
|
127
|
+
okuduke = @maker.make_colophon(@config)
|
128
128
|
assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n発行所 & テスト出版 \\\\\n連絡先 & tarou@example.jp \\\\\n印刷所 & テスト印刷 \\\\\n",
|
129
129
|
okuduke)
|
130
130
|
end
|
@@ -132,7 +132,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
132
132
|
|
133
133
|
def test_gettemplate
|
134
134
|
Dir.mktmpdir do |dir|
|
135
|
-
tmpl = @maker.get_template
|
135
|
+
tmpl = @maker.get_template(@config)
|
136
136
|
expect = File.read(File.join(assets_dir,"test_template.tex"))
|
137
137
|
assert_equal(expect, tmpl)
|
138
138
|
end
|
@@ -159,7 +159,8 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
159
159
|
|
160
160
|
expect = File.read(File.join(assets_dir,"test_template_backmatter.tex"))
|
161
161
|
|
162
|
-
|
162
|
+
maker = ReVIEW::PDFMaker.new
|
163
|
+
tmpl = maker.get_template(@config)
|
163
164
|
tmpl.gsub!(/\A.*%% backmatter begins\n/m,"")
|
164
165
|
assert_equal(expect, tmpl)
|
165
166
|
end
|
data/test/test_textutils.rb
CHANGED
@@ -29,40 +29,4 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
29
29
|
detabed = detab("\tabc\tdef", 4)
|
30
30
|
assert_equal " abc def", detabed
|
31
31
|
end
|
32
|
-
|
33
|
-
def test_split_paragraph_empty_nil
|
34
|
-
ret = @tu_nil.split_paragraph([])
|
35
|
-
assert_equal ret, [""]
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_split_paragraph_empty_p
|
39
|
-
ret = @tu_p.split_paragraph([])
|
40
|
-
assert_equal ret, ["<p></p>"]
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_split_paragraph_p
|
44
|
-
ret = @tu_p.split_paragraph(["abc"])
|
45
|
-
assert_equal ["<p>abc</p>"], ret
|
46
|
-
ret = @tu_p.split_paragraph(["abc","def"])
|
47
|
-
assert_equal ["<p>abcdef</p>"], ret
|
48
|
-
ret = @tu_p.split_paragraph(["abc","","def"])
|
49
|
-
assert_equal ["<p>abc</p>","<p>def</p>"], ret
|
50
|
-
ret = @tu_p.split_paragraph(["abc","","","def"])
|
51
|
-
assert_equal ["<p>abc</p>","<p>def</p>"], ret
|
52
|
-
ret = @tu_p.split_paragraph(["abc","","","def","ghi"])
|
53
|
-
assert_equal ["<p>abc</p>","<p>defghi</p>"], ret
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_split_paragraph_nil
|
57
|
-
ret = @tu_nil.split_paragraph(["abc"])
|
58
|
-
assert_equal ["abc"], ret
|
59
|
-
ret = @tu_nil.split_paragraph(["abc","def"])
|
60
|
-
assert_equal ["abcdef"], ret
|
61
|
-
ret = @tu_nil.split_paragraph(["abc","","def"])
|
62
|
-
assert_equal ["abc","def"], ret
|
63
|
-
ret = @tu_nil.split_paragraph(["abc","","","def"])
|
64
|
-
assert_equal ["abc","def"], ret
|
65
|
-
ret = @tu_nil.split_paragraph(["abc","","","def","ghi"])
|
66
|
-
assert_equal ["abc","defghi"], ret
|
67
|
-
end
|
68
32
|
end
|