review 2.3.0 → 2.4.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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +90 -66
  3. data/.travis.yml +1 -1
  4. data/Gemfile +0 -1
  5. data/NEWS.ja.md +82 -0
  6. data/NEWS.md +83 -0
  7. data/README.md +5 -3
  8. data/Rakefile +8 -8
  9. data/bin/review +1 -5
  10. data/bin/review-catalog-converter +22 -27
  11. data/bin/review-check +36 -43
  12. data/bin/review-checkdep +10 -15
  13. data/bin/review-compile +37 -55
  14. data/bin/review-epubmaker +4 -5
  15. data/bin/review-index +21 -29
  16. data/bin/review-init +26 -37
  17. data/bin/review-pdfmaker +0 -2
  18. data/bin/review-preproc +25 -45
  19. data/bin/review-validate +19 -18
  20. data/bin/review-vol +15 -27
  21. data/doc/config.yml.sample +5 -2
  22. data/doc/format.ja.md +20 -1
  23. data/doc/format.md +21 -5
  24. data/doc/images/review-generate.png +0 -0
  25. data/lib/epubmaker.rb +1 -3
  26. data/lib/epubmaker/content.rb +24 -27
  27. data/lib/epubmaker/epubcommon.rb +135 -148
  28. data/lib/epubmaker/epubv2.rb +39 -46
  29. data/lib/epubmaker/epubv3.rb +93 -103
  30. data/lib/epubmaker/producer.rb +138 -151
  31. data/lib/epubmaker/zip_exporter.rb +21 -26
  32. data/lib/review/book.rb +3 -6
  33. data/lib/review/book/base.rb +78 -103
  34. data/lib/review/book/chapter.rb +36 -40
  35. data/lib/review/book/compilable.rb +28 -31
  36. data/lib/review/book/image_finder.rb +6 -13
  37. data/lib/review/book/index.rb +100 -121
  38. data/lib/review/book/page_metric.rb +2 -7
  39. data/lib/review/book/part.rb +18 -20
  40. data/lib/review/book/volume.rb +9 -13
  41. data/lib/review/builder.rb +81 -116
  42. data/lib/review/catalog.rb +15 -19
  43. data/lib/review/compiler.rb +64 -83
  44. data/lib/review/configure.rb +87 -97
  45. data/lib/review/converter.rb +2 -7
  46. data/lib/review/epubbuilder.rb +1 -3
  47. data/lib/review/epubmaker.rb +213 -205
  48. data/lib/review/exception.rb +2 -4
  49. data/lib/review/extentions.rb +0 -1
  50. data/lib/review/extentions/hash.rb +2 -2
  51. data/lib/review/extentions/string.rb +5 -30
  52. data/lib/review/htmlbuilder.rb +320 -375
  53. data/lib/review/htmltoc.rb +4 -7
  54. data/lib/review/htmlutils.rb +29 -32
  55. data/lib/review/i18n.rb +33 -44
  56. data/lib/review/i18n.yml +3 -3
  57. data/lib/review/idgxmlbuilder.rb +309 -345
  58. data/lib/review/latexbuilder.rb +175 -212
  59. data/lib/review/latexindex.rb +2 -8
  60. data/lib/review/latexutils.rb +33 -43
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/logger.rb +21 -0
  63. data/lib/review/makerhelper.rb +1 -4
  64. data/lib/review/markdownbuilder.rb +44 -53
  65. data/lib/review/md2inaobuilder.rb +6 -12
  66. data/lib/review/pdfmaker.rb +143 -173
  67. data/lib/review/preprocessor.rb +64 -101
  68. data/lib/review/rstbuilder.rb +126 -158
  69. data/lib/review/sec_counter.rb +18 -34
  70. data/lib/review/template.rb +4 -5
  71. data/lib/review/textbuilder.rb +2 -3
  72. data/lib/review/textutils.rb +7 -13
  73. data/lib/review/tocparser.rb +31 -56
  74. data/lib/review/tocprinter.rb +26 -52
  75. data/lib/review/topbuilder.rb +219 -247
  76. data/lib/review/unfold.rb +15 -24
  77. data/lib/review/version.rb +1 -1
  78. data/lib/review/webmaker.rb +75 -99
  79. data/lib/review/webtocprinter.rb +15 -20
  80. data/lib/review/yamlloader.rb +13 -15
  81. data/review.gemspec +20 -22
  82. data/templates/latex/layout.tex.erb +2 -2
  83. data/templates/opf/epubv2.opf.erb +7 -7
  84. data/templates/opf/epubv3.opf.erb +7 -7
  85. data/templates/web/html/layout-html5.html.erb +2 -2
  86. data/test/assets/black.eps +280 -0
  87. data/test/assets/fit.png +0 -0
  88. data/test/assets/large.gif +0 -0
  89. data/test/assets/large.jpg +0 -0
  90. data/test/assets/large.png +0 -0
  91. data/test/assets/large.svg +65 -0
  92. data/test/assets/test_template.tex +1 -1
  93. data/test/book_test_helper.rb +2 -2
  94. data/test/run_test.rb +4 -4
  95. data/test/sample-book/src/Rakefile +21 -22
  96. data/test/syntax-book/Gemfile +4 -0
  97. data/test/syntax-book/Rakefile +72 -0
  98. data/test/syntax-book/appA.re +22 -0
  99. data/test/syntax-book/bib.re +6 -0
  100. data/test/syntax-book/catalog.yml +15 -0
  101. data/test/syntax-book/ch01.re +136 -0
  102. data/test/syntax-book/ch02.re +351 -0
  103. data/test/syntax-book/ch03.re +82 -0
  104. data/test/syntax-book/config.yml +35 -0
  105. data/test/syntax-book/images/ball.png +0 -0
  106. data/test/syntax-book/images/cover.jpg +0 -0
  107. data/test/syntax-book/images/fractal.png +0 -0
  108. data/test/syntax-book/images/img3-1.png +0 -0
  109. data/test/syntax-book/images/inlineicon.jpg +0 -0
  110. data/test/syntax-book/images/logic.png +0 -0
  111. data/test/syntax-book/images/logic2.png +0 -0
  112. data/test/syntax-book/images/puzzle.jpg +0 -0
  113. data/test/syntax-book/images/table.jpg +0 -0
  114. data/test/syntax-book/part2.re +6 -0
  115. data/test/syntax-book/pre01.re +26 -0
  116. data/test/syntax-book/review-ext.rb +14 -0
  117. data/test/syntax-book/sty/jumoline.sty +310 -0
  118. data/test/syntax-book/sty/reviewmacro.sty +39 -0
  119. data/test/syntax-book/style.css +494 -0
  120. data/test/syntax-book/syntax.dic +2 -0
  121. data/test/test_book.rb +106 -111
  122. data/test/test_book_chapter.rb +21 -22
  123. data/test/test_book_part.rb +3 -5
  124. data/test/test_builder.rb +11 -22
  125. data/test/test_catalog.rb +17 -18
  126. data/test/test_catalog_converter_cmd.rb +5 -5
  127. data/test/test_compiler.rb +18 -16
  128. data/test/test_configure.rb +35 -38
  129. data/test/test_converter.rb +3 -4
  130. data/test/test_epub3maker.rb +136 -117
  131. data/test/test_epubmaker.rb +107 -114
  132. data/test/test_epubmaker_cmd.rb +2 -4
  133. data/test/test_extentions_hash.rb +32 -33
  134. data/test/test_helper.rb +9 -11
  135. data/test/test_htmlbuilder.rb +454 -420
  136. data/test/test_htmltoc.rb +8 -12
  137. data/test/test_htmlutils.rb +0 -2
  138. data/test/test_i18n.rb +159 -150
  139. data/test/test_idgxmlbuilder.rb +190 -197
  140. data/test/test_image_finder.rb +21 -22
  141. data/test/test_index.rb +24 -29
  142. data/test/test_latexbuilder.rb +274 -264
  143. data/test/test_lineinput.rb +7 -10
  144. data/test/test_location.rb +7 -7
  145. data/test/test_makerhelper.rb +13 -25
  146. data/test/test_markdownbuilder.rb +23 -26
  147. data/test/test_md2inaobuilder.rb +8 -11
  148. data/test/test_pdfmaker.rb +114 -123
  149. data/test/test_pdfmaker_cmd.rb +1 -3
  150. data/test/test_review_ext.rb +3 -5
  151. data/test/test_rstbuilder.rb +92 -97
  152. data/test/test_template.rb +3 -7
  153. data/test/test_textutils.rb +27 -27
  154. data/test/test_tocparser.rb +2 -2
  155. data/test/test_topbuilder.rb +98 -103
  156. data/test/test_webtocprinter.rb +5 -6
  157. data/test/test_yamlloader.rb +42 -42
  158. data/test/test_zip_exporter.rb +12 -18
  159. metadata +86 -9
  160. data/lib/review/ewbbuilder.rb +0 -382
@@ -9,13 +9,12 @@ class ConverterTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_converter_builder
12
- mktmpbookdir('config.yml'=>"bookname: book\n") do |dir, book, files|
12
+ mktmpbookdir('config.yml' => "bookname: book\n") do |dir, _book, _files|
13
13
  @book = Book::Base.new(dir)
14
- config_file = File.join(dir,"config.yml")
14
+ config_file = File.join(dir, 'config.yml')
15
15
  @book.load_config(config_file)
16
16
  @converter = ReVIEW::Converter.new(@book, ReVIEW::LATEXBuilder.new)
17
- assert_equal "latex", @book.config["builder"]
17
+ assert_equal 'latex', @book.config['builder']
18
18
  end
19
19
  end
20
-
21
20
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'epubmaker'
5
3
  require 'review/epubmaker'
@@ -9,15 +7,16 @@ class EPUB3MakerTest < Test::Unit::TestCase
9
7
 
10
8
  def setup
11
9
  @producer = Producer.new
12
- @producer.merge_params({
13
- "bookname" => "sample",
14
- "title" => "Sample Book",
15
- "epubversion" => 3,
16
- "urnid" => "http://example.jp/",
17
- "date" => "2011-01-01",
18
- "language" => "en",
19
- "modified" => "2014-12-13T14:15:16Z"
20
- })
10
+ @producer.merge_config(
11
+ 'bookname' => 'sample',
12
+ 'title' => 'Sample Book',
13
+ 'epubversion' => 3,
14
+ 'urnid' => 'http://example.jp/',
15
+ 'date' => '2011-01-01',
16
+ 'language' => 'en',
17
+ 'modified' => '2014-12-13T14:15:16Z',
18
+ 'titlepage' => nil
19
+ )
21
20
  @output = StringIO.new
22
21
  end
23
22
 
@@ -26,18 +25,18 @@ class EPUB3MakerTest < Test::Unit::TestCase
26
25
  end
27
26
 
28
27
  def test_resource_en
29
- @producer.merge_params({"language" => "en"})
30
- assert_equal "Table of Contents", @producer.res.v("toctitle")
28
+ @producer.merge_config('language' => 'en')
29
+ assert_equal 'Table of Contents', @producer.res.v('toctitle')
31
30
  end
32
31
 
33
32
  def test_resource_ja
34
- @producer.merge_params({"language" => "ja"})
35
- assert_equal "目次", @producer.res.v("toctitle")
33
+ @producer.merge_config('language' => 'ja')
34
+ assert_equal '目次', @producer.res.v('toctitle')
36
35
  end
37
36
 
38
37
  def test_mimetype
39
38
  @producer.mimetype(@output)
40
- assert_equal %Q[application/epub+zip], @output.string
39
+ assert_equal 'application/epub+zip', @output.string
41
40
  end
42
41
 
43
42
  def test_container
@@ -82,7 +81,10 @@ EOT
82
81
  end
83
82
 
84
83
  def test_stage1_opf_ebpaj
85
- @producer.merge_params({"opf_prefix"=>{"ebpaj"=>"http://www.ebpaj.jp/"},"opf_meta"=>{"ebpaj:guide-version" => "1.1.2"}})
84
+ @producer.merge_config(
85
+ 'opf_prefix' => { 'ebpaj' => 'http://www.ebpaj.jp/' },
86
+ 'opf_meta' => { 'ebpaj:guide-version' => '1.1.2' }
87
+ )
86
88
  @producer.opf(@output)
87
89
  expect = <<EOT
88
90
  <?xml version="1.0" encoding="UTF-8"?>
@@ -112,9 +114,9 @@ EOT
112
114
  end
113
115
 
114
116
  def test_stage1_opf_fileas
115
- @producer.params["title"] = {"name" => "これは書籍です", "file-as" => "コレハショセキデス"}
116
- @producer.params["aut"] = [{"name" => "著者A", "file-as" => "チョシャA"}, {"name" => "著者B", "file-as" => "チョシャB"}]
117
- @producer.params["pbl"] = [{"name" => "出版社", "file-as" => "シュッパンシャ"}]
117
+ @producer.config['title'] = { 'name' => 'これは書籍です', 'file-as' => 'コレハショセキデス' }
118
+ @producer.config['aut'] = [{ 'name' => '著者A', 'file-as' => 'チョシャA' }, { 'name' => '著者B', 'file-as' => 'チョシャB' }]
119
+ @producer.config['pbl'] = [{ 'name' => '出版社', 'file-as' => 'シュッパンシャ' }]
118
120
  @producer.opf(@output)
119
121
  expect = <<EOT
120
122
  <?xml version="1.0" encoding="UTF-8"?>
@@ -179,15 +181,15 @@ EOT
179
181
 
180
182
  def stage2
181
183
  # add one item
182
- @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
184
+ @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => 'CH01', 'level' => 1 })
183
185
  end
184
186
 
185
187
  def test_stage2_add_l1item
186
188
  stage2
187
- expect = EPUBMaker::Content.new("ch01.html",
188
- "ch01-html",
189
- "application/xhtml+xml",
190
- "CH01",
189
+ expect = EPUBMaker::Content.new('ch01.html',
190
+ 'ch01-html',
191
+ 'application/xhtml+xml',
192
+ 'CH01',
191
193
  1)
192
194
  assert_equal expect, @producer.contents[0]
193
195
  end
@@ -249,49 +251,49 @@ EOT
249
251
 
250
252
  def stage3
251
253
  # add more items
252
- @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01<>&\"", "level" => 1})
253
- @producer.contents << Content.new({"file" => "ch02.html", "title" => "CH02", "level" => 1})
254
- @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
255
- @producer.contents << Content.new({"file" => "ch02.html#S1.1", "title" => "CH02.1.1", "level" => 3})
256
- @producer.contents << Content.new({"file" => "ch02.html#S1.1.1", "title" => "CH02.1.1.1", "level" => 4})
257
- @producer.contents << Content.new({"file" => "ch02.html#S1.1.1.1", "title" => "CH02.1.1.1.1", "level" => 5})
258
- @producer.contents << Content.new({"file" => "ch02.html#S1.1.2", "title" => "CH02.1.1.2", "level" => 4})
259
- @producer.contents << Content.new({"file" => "ch02.html#S2", "title" => "CH02.2", "level" => 2})
260
- @producer.contents << Content.new({"file" => "ch02.html#S2.1", "title" => "CH02.2.1", "level" => 3})
261
- @producer.contents << Content.new({"file" => "ch03.html", "title" => "CH03", "level" => 1, "properties" => ["mathml"]})
262
- @producer.contents << Content.new({"file" => "ch03.html#S1", "title" => "CH03.1", "level" => 2})
263
- @producer.contents << Content.new({"file" => "ch03.html#S1.1", "title" => "CH03.1.1", "level" => 3})
264
- @producer.contents << Content.new({"file" => "ch04.html", "title" => "CH04", "level" => 1})
265
- @producer.contents << Content.new({"file" => "sample.png"})
266
- @producer.contents << Content.new({"file" => "sample.jpg"})
267
- @producer.contents << Content.new({"file" => "sample.JPEG"})
268
- @producer.contents << Content.new({"file" => "sample.SvG"})
269
- @producer.contents << Content.new({"file" => "sample.GIF"})
270
- @producer.contents << Content.new({"file" => "sample.css"})
254
+ @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => %Q(CH01<>&"), 'level' => 1 })
255
+ @producer.contents << Content.new({ 'file' => 'ch02.html', 'title' => 'CH02', 'level' => 1 })
256
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1', 'title' => 'CH02.1', 'level' => 2 })
257
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1', 'title' => 'CH02.1.1', 'level' => 3 })
258
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1', 'title' => 'CH02.1.1.1', 'level' => 4 })
259
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1.1', 'title' => 'CH02.1.1.1.1', 'level' => 5 })
260
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.2', 'title' => 'CH02.1.1.2', 'level' => 4 })
261
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S2', 'title' => 'CH02.2', 'level' => 2 })
262
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S2.1', 'title' => 'CH02.2.1', 'level' => 3 })
263
+ @producer.contents << Content.new({ 'file' => 'ch03.html', 'title' => 'CH03', 'level' => 1, 'properties' => ['mathml'] })
264
+ @producer.contents << Content.new({ 'file' => 'ch03.html#S1', 'title' => 'CH03.1', 'level' => 2 })
265
+ @producer.contents << Content.new({ 'file' => 'ch03.html#S1.1', 'title' => 'CH03.1.1', 'level' => 3 })
266
+ @producer.contents << Content.new({ 'file' => 'ch04.html', 'title' => 'CH04', 'level' => 1 })
267
+ @producer.contents << Content.new({ 'file' => 'sample.png' })
268
+ @producer.contents << Content.new({ 'file' => 'sample.jpg' })
269
+ @producer.contents << Content.new({ 'file' => 'sample.JPEG' })
270
+ @producer.contents << Content.new({ 'file' => 'sample.SvG' })
271
+ @producer.contents << Content.new({ 'file' => 'sample.GIF' })
272
+ @producer.contents << Content.new({ 'file' => 'sample.css' })
271
273
  end
272
274
 
273
275
  def test_stage3_add_various_items
274
276
  stage3
275
277
  expect = [
276
- Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1),
277
- Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1),
278
- Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2),
279
- Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3),
280
- Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4),
281
- Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5),
282
- Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4),
283
- Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2),
284
- Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3),
285
- Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1, nil, ["mathml"]),
286
- Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2),
287
- Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3),
288
- Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1),
289
- Content.new("sample.png", "sample-png", "image/png"),
290
- Content.new("sample.jpg", "sample-jpg", "image/jpeg"),
291
- Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"),
292
- Content.new("sample.SvG", "sample-SvG", "image/svg+xml"),
293
- Content.new("sample.GIF", "sample-GIF", "image/gif"),
294
- Content.new("sample.css", "sample-css", "text/css")
278
+ Content.new('ch01.html', 'ch01-html', 'application/xhtml+xml', %Q(CH01<>&"), 1),
279
+ Content.new('ch02.html', 'ch02-html', 'application/xhtml+xml', 'CH02', 1),
280
+ Content.new('ch02.html#S1', 'ch02-html#S1', 'html#s1', 'CH02.1', 2),
281
+ Content.new('ch02.html#S1.1', 'ch02-html#S1-1', '1', 'CH02.1.1', 3),
282
+ Content.new('ch02.html#S1.1.1', 'ch02-html#S1-1-1', '1', 'CH02.1.1.1', 4),
283
+ Content.new('ch02.html#S1.1.1.1', 'ch02-html#S1-1-1-1', '1', 'CH02.1.1.1.1', 5),
284
+ Content.new('ch02.html#S1.1.2', 'ch02-html#S1-1-2', '2', 'CH02.1.1.2', 4),
285
+ Content.new('ch02.html#S2', 'ch02-html#S2', 'html#s2', 'CH02.2', 2),
286
+ Content.new('ch02.html#S2.1', 'ch02-html#S2-1', '1', 'CH02.2.1', 3),
287
+ Content.new('ch03.html', 'ch03-html', 'application/xhtml+xml', 'CH03', 1, nil, ['mathml']),
288
+ Content.new('ch03.html#S1', 'ch03-html#S1', 'html#s1', 'CH03.1', 2),
289
+ Content.new('ch03.html#S1.1', 'ch03-html#S1-1', '1', 'CH03.1.1', 3),
290
+ Content.new('ch04.html', 'ch04-html', 'application/xhtml+xml', 'CH04', 1),
291
+ Content.new('sample.png', 'sample-png', 'image/png'),
292
+ Content.new('sample.jpg', 'sample-jpg', 'image/jpeg'),
293
+ Content.new('sample.JPEG', 'sample-JPEG', 'image/jpeg'),
294
+ Content.new('sample.SvG', 'sample-SvG', 'image/svg+xml'),
295
+ Content.new('sample.GIF', 'sample-GIF', 'image/gif'),
296
+ Content.new('sample.css', 'sample-css', 'text/css')
295
297
  ]
296
298
 
297
299
  assert_equal expect, @producer.contents
@@ -403,7 +405,7 @@ EOT
403
405
  end
404
406
 
405
407
  def test_stage3_flat
406
- @producer.merge_params({"epubmaker" => {"flattoc" => true, "flattocindent" => false}})
408
+ @producer.merge_config('epubmaker' => { 'flattoc' => true, 'flattocindent' => false })
407
409
  stage3
408
410
  @producer.mytoc(@output)
409
411
  expect = <<EOT
@@ -454,7 +456,7 @@ EOT
454
456
 
455
457
  def test_stage3_cover_with_image
456
458
  stage3
457
- @producer.params["coverimage"] = "sample.png"
459
+ @producer.config['coverimage'] = 'sample.png'
458
460
  @producer.cover(@output)
459
461
  expect = <<EOT
460
462
  <?xml version="1.0" encoding="UTF-8"?>
@@ -476,8 +478,8 @@ EOT
476
478
  end
477
479
 
478
480
  def test_colophon_default
479
- @producer.params["aut"] = ["Mr.Smith"]
480
- @producer.params["pbl"] = ["BLUEPRINT"]
481
+ @producer.config['aut'] = ['Mr.Smith']
482
+ @producer.config['pbl'] = ['BLUEPRINT']
481
483
  @producer.colophon(@output)
482
484
  expect = <<EOT
483
485
  <?xml version="1.0" encoding="UTF-8"?>
@@ -506,9 +508,9 @@ EOT
506
508
  end
507
509
 
508
510
  def test_colophon_pht
509
- @producer.params["aut"] = ["Mr.Smith"]
510
- @producer.params["pbl"] = ["BLUEPRINT"]
511
- @producer.params["pht"] = ["Mrs.Smith"]
511
+ @producer.config['aut'] = ['Mr.Smith']
512
+ @producer.config['pbl'] = ['BLUEPRINT']
513
+ @producer.config['pht'] = ['Mrs.Smith']
512
514
  @producer.colophon(@output)
513
515
  expect = <<EOT
514
516
  <?xml version="1.0" encoding="UTF-8"?>
@@ -538,11 +540,11 @@ EOT
538
540
  end
539
541
 
540
542
  def test_colophon_history
541
- @producer.params["aut"] = ["Mr.Smith"]
542
- @producer.params["pbl"] = ["BLUEPRINT"]
543
- @producer.params["pht"] = ["Mrs.Smith"]
544
- @producer.merge_params({"language" => "ja"})
545
- history = @producer.instance_eval{ @epub.colophon_history }
543
+ @producer.config['aut'] = ['Mr.Smith']
544
+ @producer.config['pbl'] = ['BLUEPRINT']
545
+ @producer.config['pht'] = ['Mrs.Smith']
546
+ @producer.merge_config('language' => 'ja')
547
+ history = @producer.instance_eval { @epub.colophon_history }
546
548
  expect = <<EOT
547
549
  <div class="pubhistory">
548
550
  <p>2011年1月1日 発行</p>
@@ -552,15 +554,14 @@ EOT
552
554
  end
553
555
 
554
556
  def test_colophon_history_2
555
- @producer.params["aut"] = ["Mr.Smith"]
556
- @producer.params["pbl"] = ["BLUEPRINT"]
557
- @producer.params["pht"] = ["Mrs.Smith"]
558
- @producer.merge_params({"language" => "ja",
559
- "history" => [[
560
- "2011-08-03 v1.0.0版発行",
561
- "2012-02-15 v1.1.0版発行",
562
- ]] })
563
- history = @producer.instance_eval{ @epub.colophon_history }
557
+ @producer.config['aut'] = ['Mr.Smith']
558
+ @producer.config['pbl'] = ['BLUEPRINT']
559
+ @producer.config['pht'] = ['Mrs.Smith']
560
+ @producer.merge_config(
561
+ 'language' => 'ja',
562
+ 'history' => [['2011-08-03 v1.0.0版発行', '2012-02-15 v1.1.0版発行']]
563
+ )
564
+ history = @producer.instance_eval { @epub.colophon_history }
564
565
  expect = <<EOT
565
566
  <div class="pubhistory">
566
567
  <p>2011年8月3日 v1.0.0版発行</p>
@@ -571,15 +572,14 @@ EOT
571
572
  end
572
573
 
573
574
  def test_colophon_history_date
574
- @producer.params["aut"] = ["Mr.Smith"]
575
- @producer.params["pbl"] = ["BLUEPRINT"]
576
- @producer.params["pht"] = ["Mrs.Smith"]
577
- @producer.merge_params({"language" => "ja",
578
- "history" => [[
579
- "2011-08-03",
580
- "2012-02-15",
581
- ]] })
582
- history = @producer.instance_eval{ @epub.colophon_history }
575
+ @producer.config['aut'] = ['Mr.Smith']
576
+ @producer.config['pbl'] = ['BLUEPRINT']
577
+ @producer.config['pht'] = ['Mrs.Smith']
578
+ @producer.merge_config(
579
+ 'language' => 'ja',
580
+ 'history' => [['2011-08-03', '2012-02-15']]
581
+ )
582
+ history = @producer.instance_eval { @epub.colophon_history }
583
583
  expect = <<EOT
584
584
  <div class="pubhistory">
585
585
  <p>2011年8月3日 初版第1刷 発行</p>
@@ -590,19 +590,16 @@ EOT
590
590
  end
591
591
 
592
592
  def test_colophon_history_date2
593
- @producer.params["aut"] = ["Mr.Smith"]
594
- @producer.params["pbl"] = ["BLUEPRINT"]
595
- @producer.params["pht"] = ["Mrs.Smith"]
596
- @producer.merge_params({"language" => "ja",
597
- "history" => [[
598
- "2011-08-03",
599
- "2012-02-15",
600
- ],[
601
- "2012-10-01",
602
- ],[
603
- "2013-03-01",
604
- ]] })
605
- history = @producer.instance_eval{ @epub.colophon_history }
593
+ @producer.config['aut'] = ['Mr.Smith']
594
+ @producer.config['pbl'] = ['BLUEPRINT']
595
+ @producer.config['pht'] = ['Mrs.Smith']
596
+ @producer.merge_config(
597
+ 'language' => 'ja',
598
+ 'history' => [['2011-08-03', '2012-02-15'],
599
+ ['2012-10-01'],
600
+ ['2013-03-01']]
601
+ )
602
+ history = @producer.instance_eval { @epub.colophon_history }
606
603
  expect = <<EOT
607
604
  <div class="pubhistory">
608
605
  <p>2011年8月3日 初版第1刷 発行</p>
@@ -617,7 +614,7 @@ EOT
617
614
  def test_detect_mathml
618
615
  Dir.mktmpdir do |dir|
619
616
  epubmaker = ReVIEW::EPUBMaker.new
620
- path = File.join(dir,"test.html")
617
+ path = File.join(dir, 'test.html')
621
618
  html = <<EOT
622
619
  <?xml version="1.0" encoding="UTF-8"?>
623
620
  <!DOCTYPE html>
@@ -629,22 +626,20 @@ EOT
629
626
  </head>
630
627
  <body>
631
628
  <div>
632
- <p><span class=\"equation\"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>&#xb1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span></p>
629
+ <p><span class="equation"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>&#xb1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span></p>
633
630
  </div>
634
631
  </body>
635
632
  </html>
636
633
  EOT
637
- File.open(path, "w") do |f|
638
- f.write(html)
639
- end
640
- assert_equal ["mathml"], epubmaker.detect_properties(path)
634
+ File.open(path, 'w') { |f| f.write(html) }
635
+ assert_equal ['mathml'], epubmaker.detect_properties(path)
641
636
  end
642
637
  end
643
638
 
644
639
  def test_detect_mathml_ns
645
640
  Dir.mktmpdir do |dir|
646
641
  epubmaker = ReVIEW::EPUBMaker.new
647
- path = File.join(dir,"test.html")
642
+ path = File.join(dir, 'test.html')
648
643
  html = <<EOT
649
644
  <?xml version="1.0" encoding="UTF-8"?>
650
645
  <!DOCTYPE html>
@@ -656,15 +651,39 @@ EOT
656
651
  </head>
657
652
  <body>
658
653
  <div>
659
- <p><span class=\"equation\"><m:math xmlns:m='http://www.w3.org/1998/Math/MathML' display='inline'><m:mfrac><m:mrow><m:mo stretchy='false'>-</m:mo><m:mi>b</m:mi><m:mo stretchy='false'>&#xb1;</m:mo><m:msqrt><m:mrow><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup><m:mo stretchy='false'>-</m:mo><m:mn>4</m:mn><m:mi>a</m:mi><m:mi>c</m:mi></m:mrow></m:msqrt></m:mrow><m:mrow><m:mn>2</m:mn><m:mi>a</m:mi></m:mrow></m:mfrac></m:math></span></p>
654
+ <p><span class="equation"><m:math xmlns:m='http://www.w3.org/1998/Math/MathML' display='inline'><m:mfrac><m:mrow><m:mo stretchy='false'>-</m:mo><m:mi>b</m:mi><m:mo stretchy='false'>&#xb1;</m:mo><m:msqrt><m:mrow><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup><m:mo stretchy='false'>-</m:mo><m:mn>4</m:mn><m:mi>a</m:mi><m:mi>c</m:mi></m:mrow></m:msqrt></m:mrow><m:mrow><m:mn>2</m:mn><m:mi>a</m:mi></m:mrow></m:mfrac></m:math></span></p>
660
655
  </div>
661
656
  </body>
662
657
  </html>
663
658
  EOT
664
- File.open(path, "w") do |f|
665
- f.write(html)
659
+ File.open(path, 'w') { |f| f.write(html) }
660
+ assert_equal ['mathml'], epubmaker.detect_properties(path)
661
+ end
662
+ end
663
+
664
+ def test_image_size
665
+ begin
666
+ require 'image_size'
667
+ rescue LoadError
668
+ $stderr.puts 'skip test_image_size (cannot find image_size.rb)'
669
+ return true
670
+ end
671
+ epubmaker = ReVIEW::EPUBMaker.new
672
+ epubmaker.instance_eval do
673
+ def warn(msg)
674
+ $stderr.puts msg
666
675
  end
667
- assert_equal ["mathml"], epubmaker.detect_properties(path)
668
676
  end
677
+ _out, err = capture_output do
678
+ epubmaker.check_image_size(assets_dir, 5500, %w[png gif jpg jpeg svg ttf woff otf])
679
+ end
680
+
681
+ expected = <<-EOS
682
+ large.gif: 250x150 exceeds a limit. suggeted value is 95x57
683
+ large.jpg: 250x150 exceeds a limit. suggeted value is 95x57
684
+ large.png: 250x150 exceeds a limit. suggeted value is 95x57
685
+ large.svg: 250x150 exceeds a limit. suggeted value is 95x57
686
+ EOS
687
+ assert_equal expected, err
669
688
  end
670
689
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'epubmaker'
5
3
 
@@ -8,14 +6,15 @@ class EPUBMakerTest < Test::Unit::TestCase
8
6
 
9
7
  def setup
10
8
  @producer = Producer.new
11
- @producer.merge_params({
12
- "bookname" => "sample",
13
- "title" => "Sample Book",
14
- "epubversion" => 2,
15
- "urnid" => "http://example.jp/",
16
- "date" => "2011-01-01",
17
- "language" => "en",
18
- })
9
+ @producer.merge_config(
10
+ 'bookname' => 'sample',
11
+ 'title' => 'Sample Book',
12
+ 'epubversion' => 2,
13
+ 'urnid' => 'http://example.jp/',
14
+ 'date' => '2011-01-01',
15
+ 'language' => 'en',
16
+ 'titlepage' => nil
17
+ )
19
18
  @output = StringIO.new
20
19
  end
21
20
 
@@ -24,18 +23,18 @@ class EPUBMakerTest < Test::Unit::TestCase
24
23
  end
25
24
 
26
25
  def test_resource_en
27
- @producer.merge_params({"language" => "en"})
28
- assert_equal "Table of Contents", @producer.res.v("toctitle")
26
+ @producer.merge_config('language' => 'en')
27
+ assert_equal 'Table of Contents', @producer.res.v('toctitle')
29
28
  end
30
29
 
31
30
  def test_resource_ja
32
- @producer.merge_params({"language" => "ja"})
33
- assert_equal "目次", @producer.res.v("toctitle")
31
+ @producer.merge_config('language' => 'ja')
32
+ assert_equal '目次', @producer.res.v('toctitle')
34
33
  end
35
34
 
36
35
  def test_mimetype
37
36
  @producer.mimetype(@output)
38
- assert_equal %Q[application/epub+zip], @output.string
37
+ assert_equal 'application/epub+zip', @output.string
39
38
  end
40
39
 
41
40
  def test_container
@@ -78,7 +77,7 @@ EOT
78
77
  end
79
78
 
80
79
  def test_stage1_opf_escape
81
- @producer.params["title"] = "Sample<>Book"
80
+ @producer.config['title'] = 'Sample<>Book'
82
81
  @producer.opf(@output)
83
82
  expect = <<EOT
84
83
  <?xml version="1.0" encoding="UTF-8"?>
@@ -135,7 +134,7 @@ EOT
135
134
  end
136
135
 
137
136
  def test_stage1_ncx_escape
138
- @producer.params["title"] = "Sample<>Book"
137
+ @producer.config['title'] = 'Sample<>Book'
139
138
  @producer.ncx(@output)
140
139
  expect = <<EOT
141
140
  <?xml version="1.0" encoding="UTF-8"?>
@@ -167,15 +166,15 @@ EOT
167
166
 
168
167
  def stage2
169
168
  # add one item
170
- @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
169
+ @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => 'CH01', 'level' => 1 })
171
170
  end
172
171
 
173
172
  def test_stage2_add_l1item
174
173
  stage2
175
- expect = EPUBMaker::Content.new("ch01.html",
176
- "ch01-html",
177
- "application/xhtml+xml",
178
- "CH01",
174
+ expect = EPUBMaker::Content.new('ch01.html',
175
+ 'ch01-html',
176
+ 'application/xhtml+xml',
177
+ 'CH01',
179
178
  1)
180
179
  assert_equal expect, @producer.contents[0]
181
180
  end
@@ -248,49 +247,49 @@ EOT
248
247
 
249
248
  def stage3
250
249
  # add more items
251
- @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01<>&\"", "level" => 1})
252
- @producer.contents << Content.new({"file" => "ch02.html", "title" => "CH02", "level" => 1})
253
- @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
254
- @producer.contents << Content.new({"file" => "ch02.html#S1.1", "title" => "CH02.1.1", "level" => 3})
255
- @producer.contents << Content.new({"file" => "ch02.html#S1.1.1", "title" => "CH02.1.1.1", "level" => 4})
256
- @producer.contents << Content.new({"file" => "ch02.html#S1.1.1.1", "title" => "CH02.1.1.1.1", "level" => 5})
257
- @producer.contents << Content.new({"file" => "ch02.html#S1.1.2", "title" => "CH02.1.1.2", "level" => 4})
258
- @producer.contents << Content.new({"file" => "ch02.html#S2", "title" => "CH02.2", "level" => 2})
259
- @producer.contents << Content.new({"file" => "ch02.html#S2.1", "title" => "CH02.2.1", "level" => 3})
260
- @producer.contents << Content.new({"file" => "ch03.html", "title" => "CH03", "level" => 1})
261
- @producer.contents << Content.new({"file" => "ch03.html#S1", "title" => "CH03.1", "level" => 2})
262
- @producer.contents << Content.new({"file" => "ch03.html#S1.1", "title" => "CH03.1.1", "level" => 3})
263
- @producer.contents << Content.new({"file" => "ch04.html", "title" => "CH04", "level" => 1})
264
- @producer.contents << Content.new({"file" => "sample.png"})
265
- @producer.contents << Content.new({"file" => "sample.jpg"})
266
- @producer.contents << Content.new({"file" => "sample.JPEG"})
267
- @producer.contents << Content.new({"file" => "sample.SvG"})
268
- @producer.contents << Content.new({"file" => "sample.GIF"})
269
- @producer.contents << Content.new({"file" => "sample.css"})
250
+ @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => %Q(CH01<>&"), 'level' => 1 })
251
+ @producer.contents << Content.new({ 'file' => 'ch02.html', 'title' => 'CH02', 'level' => 1 })
252
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1', 'title' => 'CH02.1', 'level' => 2 })
253
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1', 'title' => 'CH02.1.1', 'level' => 3 })
254
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1', 'title' => 'CH02.1.1.1', 'level' => 4 })
255
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1.1', 'title' => 'CH02.1.1.1.1', 'level' => 5 })
256
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.2', 'title' => 'CH02.1.1.2', 'level' => 4 })
257
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S2', 'title' => 'CH02.2', 'level' => 2 })
258
+ @producer.contents << Content.new({ 'file' => 'ch02.html#S2.1', 'title' => 'CH02.2.1', 'level' => 3 })
259
+ @producer.contents << Content.new({ 'file' => 'ch03.html', 'title' => 'CH03', 'level' => 1 })
260
+ @producer.contents << Content.new({ 'file' => 'ch03.html#S1', 'title' => 'CH03.1', 'level' => 2 })
261
+ @producer.contents << Content.new({ 'file' => 'ch03.html#S1.1', 'title' => 'CH03.1.1', 'level' => 3 })
262
+ @producer.contents << Content.new({ 'file' => 'ch04.html', 'title' => 'CH04', 'level' => 1 })
263
+ @producer.contents << Content.new({ 'file' => 'sample.png' })
264
+ @producer.contents << Content.new({ 'file' => 'sample.jpg' })
265
+ @producer.contents << Content.new({ 'file' => 'sample.JPEG' })
266
+ @producer.contents << Content.new({ 'file' => 'sample.SvG' })
267
+ @producer.contents << Content.new({ 'file' => 'sample.GIF' })
268
+ @producer.contents << Content.new({ 'file' => 'sample.css' })
270
269
  end
271
270
 
272
271
  def test_stage3_add_various_items
273
272
  stage3
274
273
  expect = [
275
- Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1),
276
- Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1),
277
- Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2),
278
- Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3),
279
- Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4),
280
- Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5),
281
- Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4),
282
- Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2),
283
- Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3),
284
- Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1),
285
- Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2),
286
- Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3),
287
- Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1),
288
- Content.new("sample.png", "sample-png", "image/png"),
289
- Content.new("sample.jpg", "sample-jpg", "image/jpeg"),
290
- Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"),
291
- Content.new("sample.SvG", "sample-SvG", "image/svg+xml"),
292
- Content.new("sample.GIF", "sample-GIF", "image/gif"),
293
- Content.new("sample.css", "sample-css", "text/css")
274
+ Content.new('ch01.html', 'ch01-html', 'application/xhtml+xml', %Q(CH01<>&"), 1),
275
+ Content.new('ch02.html', 'ch02-html', 'application/xhtml+xml', 'CH02', 1),
276
+ Content.new('ch02.html#S1', 'ch02-html#S1', 'html#s1', 'CH02.1', 2),
277
+ Content.new('ch02.html#S1.1', 'ch02-html#S1-1', '1', 'CH02.1.1', 3),
278
+ Content.new('ch02.html#S1.1.1', 'ch02-html#S1-1-1', '1', 'CH02.1.1.1', 4),
279
+ Content.new('ch02.html#S1.1.1.1', 'ch02-html#S1-1-1-1', '1', 'CH02.1.1.1.1', 5),
280
+ Content.new('ch02.html#S1.1.2', 'ch02-html#S1-1-2', '2', 'CH02.1.1.2', 4),
281
+ Content.new('ch02.html#S2', 'ch02-html#S2', 'html#s2', 'CH02.2', 2),
282
+ Content.new('ch02.html#S2.1', 'ch02-html#S2-1', '1', 'CH02.2.1', 3),
283
+ Content.new('ch03.html', 'ch03-html', 'application/xhtml+xml', 'CH03', 1),
284
+ Content.new('ch03.html#S1', 'ch03-html#S1', 'html#s1', 'CH03.1', 2),
285
+ Content.new('ch03.html#S1.1', 'ch03-html#S1-1', '1', 'CH03.1.1', 3),
286
+ Content.new('ch04.html', 'ch04-html', 'application/xhtml+xml', 'CH04', 1),
287
+ Content.new('sample.png', 'sample-png', 'image/png'),
288
+ Content.new('sample.jpg', 'sample-jpg', 'image/jpeg'),
289
+ Content.new('sample.JPEG', 'sample-JPEG', 'image/jpeg'),
290
+ Content.new('sample.SvG', 'sample-SvG', 'image/svg+xml'),
291
+ Content.new('sample.GIF', 'sample-GIF', 'image/gif'),
292
+ Content.new('sample.css', 'sample-css', 'text/css')
294
293
  ]
295
294
 
296
295
  assert_equal expect, @producer.contents
@@ -477,7 +476,7 @@ EOT
477
476
  end
478
477
 
479
478
  def test_stage3_flat
480
- @producer.merge_params({"epubmaker" => {"flattoc" => true, "flattocindent" => false}})
479
+ @producer.merge_config('epubmaker' => { 'flattoc' => true, 'flattocindent' => false })
481
480
  stage3
482
481
  @producer.mytoc(@output)
483
482
  expect = <<EOT
@@ -528,7 +527,7 @@ EOT
528
527
 
529
528
  def test_stage3_cover_escape
530
529
  stage3
531
- @producer.params["title"] = "Sample<>Book"
530
+ @producer.config['title'] = 'Sample<>Book'
532
531
  @producer.cover(@output)
533
532
  expect = <<EOT
534
533
  <?xml version="1.0" encoding="UTF-8"?>
@@ -549,7 +548,7 @@ EOT
549
548
 
550
549
  def test_stage3_cover_with_image
551
550
  stage3
552
- @producer.params["coverimage"] = "sample.png"
551
+ @producer.config['coverimage'] = 'sample.png'
553
552
  @producer.cover(@output)
554
553
  expect = <<EOT
555
554
  <?xml version="1.0" encoding="UTF-8"?>
@@ -572,8 +571,8 @@ EOT
572
571
 
573
572
  def test_stage3_cover_with_image_escape
574
573
  stage3
575
- @producer.params["title"] = "Sample<>Book"
576
- @producer.params["coverimage"] = "sample.png"
574
+ @producer.config['title'] = 'Sample<>Book'
575
+ @producer.config['coverimage'] = 'sample.png'
577
576
  @producer.cover(@output)
578
577
  expect = <<EOT
579
578
  <?xml version="1.0" encoding="UTF-8"?>
@@ -595,9 +594,9 @@ EOT
595
594
  end
596
595
 
597
596
  def test_colophon_default
598
- @producer.params["aut"] = ["Mr.Smith"]
599
- @producer.params["pbl"] = ["BLUEPRINT"]
600
- @producer.params["isbn"] = "9784797372274"
597
+ @producer.config['aut'] = ['Mr.Smith']
598
+ @producer.config['pbl'] = ['BLUEPRINT']
599
+ @producer.config['isbn'] = '9784797372274'
601
600
  @producer.colophon(@output)
602
601
  expect = <<EOT
603
602
  <?xml version="1.0" encoding="UTF-8"?>
@@ -627,12 +626,12 @@ EOT
627
626
  end
628
627
 
629
628
  def test_colophon_default_escape_and_multiple
630
- @producer.params["title"] = "<&Sample Book>"
631
- @producer.params["subtitle"] = "Sample<>Subtitle"
632
- @producer.params["aut"] = ["Mr.Smith", "Mr.&Anderson"]
633
- @producer.params["pbl"] = ["BLUEPRINT", "COPY<>EDIT"]
634
- @producer.params["isbn"] = "9784797372274"
635
- @producer.params["rights"] = ["COPYRIGHT 2016 <>", "& REVIEW"]
629
+ @producer.config['title'] = '<&Sample Book>'
630
+ @producer.config['subtitle'] = 'Sample<>Subtitle'
631
+ @producer.config['aut'] = ['Mr.Smith', 'Mr.&Anderson']
632
+ @producer.config['pbl'] = ['BLUEPRINT', 'COPY<>EDIT']
633
+ @producer.config['isbn'] = '9784797372274'
634
+ @producer.config['rights'] = ['COPYRIGHT 2016 <>', '& REVIEW']
636
635
  @producer.colophon(@output)
637
636
  expect = <<EOT
638
637
  <?xml version="1.0" encoding="UTF-8"?>
@@ -663,22 +662,19 @@ EOT
663
662
  end
664
663
 
665
664
  def test_colophon_history
666
- @producer.params["aut"] = ["Mr.Smith"]
667
- @producer.params["pbl"] = ["BLUEPRINT"]
668
- @producer.params["pht"] = ["Mrs.Smith"]
669
- @producer.merge_params({"language" => "ja"})
670
- @producer.params["history"] = [[
671
- "2011-08-03",
672
- "2012-02-15",
673
- ],[
674
- "2012-10-01",
675
- ],[
676
- "2013-03-01",
677
- ]]
678
- epub = @producer.instance_eval{@epub}
665
+ @producer.config['aut'] = ['Mr.Smith']
666
+ @producer.config['pbl'] = ['BLUEPRINT']
667
+ @producer.config['pht'] = ['Mrs.Smith']
668
+ @producer.merge_config('language' => 'ja')
669
+ @producer.config['history'] =
670
+ [['2011-08-03',
671
+ '2012-02-15'],
672
+ ['2012-10-01'],
673
+ ['2013-03-01']]
674
+ epub = @producer.instance_eval { @epub }
679
675
  result = epub.colophon_history
680
676
  expect = <<-EOT
681
- <div class=\"pubhistory\">
677
+ <div class="pubhistory">
682
678
  <p>2011年8月3日 初版第1刷 発行</p>
683
679
  <p>2012年2月15日 初版第2刷 発行</p>
684
680
  <p>2012年10月1日 第2版第1刷 発行</p>
@@ -689,22 +685,19 @@ EOT
689
685
  end
690
686
 
691
687
  def test_colophon_history_freeformat
692
- @producer.params["aut"] = ["Mr.Smith"]
693
- @producer.params["pbl"] = ["BLUEPRINT"]
694
- @producer.params["pht"] = ["Mrs.Smith"]
695
- @producer.merge_params({"language" => "ja"})
696
- @producer.params["history"] = [[
697
- "2011年8月3日 ver 1.1.0発行",
698
- ],[
699
- "20111012日 ver 1.2.0発行",
700
- ],[
701
- "2012年1月31日 ver 1.2.1発行",
702
- ]]
703
-
704
- epub = @producer.instance_eval{@epub}
688
+ @producer.config['aut'] = ['Mr.Smith']
689
+ @producer.config['pbl'] = ['BLUEPRINT']
690
+ @producer.config['pht'] = ['Mrs.Smith']
691
+ @producer.merge_config('language' => 'ja')
692
+ @producer.config['history'] =
693
+ [['2011年8月3日 ver 1.1.0発行'],
694
+ ['2011年10月12日 ver 1.2.0発行'],
695
+ ['2012131日 ver 1.2.1発行']]
696
+
697
+ epub = @producer.instance_eval { @epub }
705
698
  result = epub.colophon_history
706
699
  expect = <<-EOT
707
- <div class=\"pubhistory\">
700
+ <div class="pubhistory">
708
701
  <p>2011年8月3日 ver 1.1.0発行</p>
709
702
  <p>2011年10月12日 ver 1.2.0発行</p>
710
703
  <p>2012年1月31日 ver 1.2.1発行</p>
@@ -714,9 +707,9 @@ EOT
714
707
  end
715
708
 
716
709
  def test_colophon_pht
717
- @producer.params["aut"] = ["Mr.Smith"]
718
- @producer.params["pbl"] = ["BLUEPRINT"]
719
- @producer.params["pht"] = ["Mrs.Smith"]
710
+ @producer.config['aut'] = ['Mr.Smith']
711
+ @producer.config['pbl'] = ['BLUEPRINT']
712
+ @producer.config['pht'] = ['Mrs.Smith']
720
713
  @producer.colophon(@output)
721
714
  expect = <<EOT
722
715
  <?xml version="1.0" encoding="UTF-8"?>
@@ -746,23 +739,23 @@ EOT
746
739
  end
747
740
 
748
741
  def test_isbn13
749
- @producer.params["isbn"] = "9784797372274"
750
- assert_equal "978-4-79737-227-4", @producer.isbn_hyphen
742
+ @producer.config['isbn'] = '9784797372274'
743
+ assert_equal '978-4-79737-227-4', @producer.isbn_hyphen
751
744
  end
752
745
 
753
746
  def test_isbn10
754
- @producer.params["isbn"] = "4797372273"
755
- assert_equal "4-79737-227-3", @producer.isbn_hyphen
747
+ @producer.config['isbn'] = '4797372273'
748
+ assert_equal '4-79737-227-3', @producer.isbn_hyphen
756
749
  end
757
750
 
758
751
  def test_isbn_nil
759
- @producer.params["isbn"] = nil
752
+ @producer.config['isbn'] = nil
760
753
  assert_equal nil, @producer.isbn_hyphen
761
754
  end
762
755
 
763
756
  def test_title
764
- @producer.params["aut"] = ["Mr.Smith"]
765
- @producer.params["pbl"] = ["BLUEPRINT"]
757
+ @producer.config['aut'] = ['Mr.Smith']
758
+ @producer.config['pbl'] = ['BLUEPRINT']
766
759
  @producer.titlepage(@output)
767
760
  expect = <<EOT
768
761
  <?xml version="1.0" encoding="UTF-8"?>
@@ -794,8 +787,8 @@ EOT
794
787
  end
795
788
 
796
789
  def test_title_single_value_param
797
- @producer.params["aut"] = "Mr.Smith"
798
- @producer.params["pbl"] = "BLUEPRINT"
790
+ @producer.config['aut'] = 'Mr.Smith'
791
+ @producer.config['pbl'] = 'BLUEPRINT'
799
792
  @producer.titlepage(@output)
800
793
  expect = <<EOT
801
794
  <?xml version="1.0" encoding="UTF-8"?>