review 2.0.0.beta1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +66 -1
  3. data/.rubocop_todo.yml +617 -0
  4. data/.travis.yml +16 -1
  5. data/ChangeLog +48 -0
  6. data/Dockerfile +22 -0
  7. data/Gemfile +0 -1
  8. data/README.md +97 -0
  9. data/Rakefile +10 -11
  10. data/appveyor.yml +9 -0
  11. data/bin/review +46 -0
  12. data/bin/review-check +8 -21
  13. data/bin/review-compile +26 -43
  14. data/bin/review-index +9 -22
  15. data/bin/review-init +21 -25
  16. data/bin/review-preproc +9 -13
  17. data/bin/review-validate +1 -1
  18. data/bin/review-vol +3 -17
  19. data/bin/review-webmaker +15 -0
  20. data/doc/NEWS.ja.md +534 -0
  21. data/doc/NEWS.md +538 -0
  22. data/doc/catalog.ja.md +10 -18
  23. data/doc/catalog.md +5 -9
  24. data/doc/config.yml.sample +319 -0
  25. data/doc/customize_epub.ja.md +42 -0
  26. data/doc/format.ja.md +320 -288
  27. data/doc/format.md +277 -170
  28. data/doc/format_idg.ja.md +82 -175
  29. data/doc/pdfmaker.ja.md +61 -0
  30. data/doc/pdfmaker.md +65 -0
  31. data/doc/quickstart.ja.md +88 -98
  32. data/doc/quickstart.md +72 -110
  33. data/doc/sample.css +41 -0
  34. data/doc/writing_vertical.ja.md +55 -0
  35. data/doc/writing_vertical.md +5 -0
  36. data/lib/epubmaker/content.rb +3 -3
  37. data/lib/epubmaker/epubcommon.rb +173 -145
  38. data/lib/epubmaker/epubv2.rb +24 -77
  39. data/lib/epubmaker/epubv3.rb +72 -73
  40. data/lib/epubmaker/producer.rb +54 -30
  41. data/lib/lineinput.rb +48 -0
  42. data/lib/review/book.rb +0 -1
  43. data/lib/review/book/base.rb +47 -27
  44. data/lib/review/book/chapter.rb +48 -19
  45. data/lib/review/book/compilable.rb +10 -14
  46. data/lib/review/book/index.rb +10 -19
  47. data/lib/review/book/page_metric.rb +0 -10
  48. data/lib/review/book/part.rb +17 -3
  49. data/lib/review/builder.rb +84 -68
  50. data/lib/review/catalog.rb +5 -1
  51. data/lib/review/compiler.rb +327 -4657
  52. data/lib/review/configure.rb +84 -10
  53. data/lib/review/converter.rb +28 -0
  54. data/lib/review/epubbuilder.rb +1 -1
  55. data/lib/review/epubmaker.rb +142 -158
  56. data/lib/review/ewbbuilder.rb +5 -5
  57. data/lib/review/exception.rb +1 -1
  58. data/lib/review/extentions.rb +1 -1
  59. data/lib/review/extentions/hash.rb +15 -0
  60. data/lib/review/extentions/string.rb +2 -1
  61. data/lib/review/htmlbuilder.rb +364 -348
  62. data/lib/review/htmltoc.rb +44 -0
  63. data/lib/review/htmlutils.rb +12 -6
  64. data/lib/review/i18n.rb +78 -6
  65. data/lib/review/i18n.yml +7 -4
  66. data/lib/review/idgxmlbuilder.rb +226 -267
  67. data/lib/review/latexbuilder.rb +281 -274
  68. data/lib/review/latexutils.rb +56 -49
  69. data/lib/review/makerhelper.rb +8 -4
  70. data/lib/review/markdownbuilder.rb +80 -124
  71. data/lib/review/pdfmaker.rb +197 -138
  72. data/lib/review/preprocessor.rb +16 -67
  73. data/lib/review/template.rb +24 -0
  74. data/lib/review/textbuilder.rb +1 -1
  75. data/lib/review/textutils.rb +18 -24
  76. data/lib/review/tocparser.rb +51 -106
  77. data/lib/review/tocprinter.rb +61 -117
  78. data/lib/review/topbuilder.rb +119 -126
  79. data/lib/review/unfold.rb +2 -2
  80. data/lib/review/version.rb +1 -1
  81. data/lib/review/webmaker.rb +302 -0
  82. data/lib/review/webtocprinter.rb +48 -0
  83. data/lib/review/yamlloader.rb +47 -0
  84. data/review.gemspec +3 -3
  85. data/templates/html/layout-html5.html.erb +17 -0
  86. data/templates/html/layout-xhtml1.html.erb +20 -0
  87. data/{lib/review → templates/latex}/layout.tex.erb +107 -115
  88. data/templates/ncx/epubv2.ncx.erb +11 -0
  89. data/templates/opf/epubv2.opf.erb +21 -0
  90. data/templates/opf/epubv3.opf.erb +18 -0
  91. data/templates/web/html/layout-html5.html.erb +56 -0
  92. data/templates/web/html/layout-xhtml1.html.erb +20 -0
  93. data/templates/xml/container.xml.erb +6 -0
  94. data/test/assets/test.xml.erb +3 -0
  95. data/test/assets/test_template.tex +28 -71
  96. data/test/assets/test_template_backmatter.tex +1 -9
  97. data/test/sample-book/src/Rakefile +12 -3
  98. data/{doc/sample.yml → test/sample-book/src/config-epub2.yml} +92 -147
  99. data/test/sample-book/src/config.yml +40 -154
  100. data/test/sample-book/src/style-web.css +45 -0
  101. data/test/sample-book/src/style.css +23 -1
  102. data/test/test.re +1 -1
  103. data/test/test_book.rb +15 -17
  104. data/test/test_book_chapter.rb +2 -80
  105. data/test/test_book_part.rb +1 -1
  106. data/test/test_builder.rb +28 -6
  107. data/test/test_catalog.rb +17 -0
  108. data/test/test_compiler.rb +14 -59
  109. data/test/test_configure.rb +94 -0
  110. data/test/test_converter.rb +21 -0
  111. data/test/test_epub3maker.rb +155 -3
  112. data/test/test_epubmaker.rb +245 -30
  113. data/test/test_epubmaker_cmd.rb +2 -2
  114. data/test/test_extentions_hash.rb +60 -0
  115. data/test/test_helper.rb +4 -47
  116. data/test/test_htmlbuilder.rb +282 -175
  117. data/test/test_htmltoc.rb +33 -0
  118. data/test/test_i18n.rb +134 -70
  119. data/test/test_idgxmlbuilder.rb +58 -39
  120. data/test/test_latexbuilder.rb +132 -14
  121. data/test/test_lineinput.rb +5 -26
  122. data/test/test_makerhelper.rb +6 -4
  123. data/test/test_markdownbuilder.rb +23 -5
  124. data/test/test_pdfmaker.rb +86 -20
  125. data/test/test_pdfmaker_cmd.rb +1 -3
  126. data/test/test_review_ext.rb +1 -1
  127. data/test/test_template.rb +27 -0
  128. data/test/test_textutils.rb +36 -0
  129. data/test/test_tocparser.rb +25 -0
  130. data/test/test_topbuilder.rb +34 -2
  131. data/test/test_yamlloader.rb +188 -0
  132. metadata +71 -29
  133. data/README.rdoc +0 -81
  134. data/bin/review-epubmaker-legacy +0 -1024
  135. data/doc/ruby-uuid/README +0 -11
  136. data/doc/ruby-uuid/README.ja +0 -34
  137. data/lib/review/compiler/literals_1_8.kpeg +0 -19
  138. data/lib/review/compiler/literals_1_8.rb +0 -432
  139. data/lib/review/compiler/literals_1_9.kpeg +0 -22
  140. data/lib/review/compiler/literals_1_9.rb +0 -435
  141. data/lib/review/extentions/array.rb +0 -25
  142. data/lib/review/htmllayout.rb +0 -41
  143. data/lib/review/inaobuilder.rb +0 -357
  144. data/lib/review/location.rb +0 -24
  145. data/lib/review/node.rb +0 -267
  146. data/lib/review/review.kpeg +0 -724
  147. data/lib/uuid.rb +0 -312
  148. data/rubocop-todo.yml +0 -456
  149. data/test/test_inaobuilder.rb +0 -247
  150. data/test/test_uuid.rb +0 -157
@@ -77,6 +77,33 @@ EOT
77
77
  assert_equal expect, @output.string
78
78
  end
79
79
 
80
+ def test_stage1_opf_escape
81
+ @producer.params["title"] = "Sample<>Book"
82
+ @producer.opf(@output)
83
+ expect = <<EOT
84
+ <?xml version="1.0" encoding="UTF-8"?>
85
+ <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
86
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
87
+ <dc:title>Sample&lt;&gt;Book</dc:title>
88
+ <dc:language>en</dc:language>
89
+ <dc:date>2011-01-01</dc:date>
90
+ <dc:identifier id="BookId">http://example.jp/</dc:identifier>
91
+ </metadata>
92
+ <manifest>
93
+ <item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
94
+ <item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
95
+ </manifest>
96
+ <spine toc="ncx">
97
+ <itemref idref="sample" linear="no"/>
98
+ </spine>
99
+ <guide>
100
+ <reference type="cover" title="Cover" href="sample.html"/>
101
+ </guide>
102
+ </package>
103
+ EOT
104
+ assert_equal expect, @output.string
105
+ end
106
+
80
107
  def test_stage1_ncx
81
108
  @producer.ncx(@output)
82
109
  expect = <<EOT
@@ -107,6 +134,37 @@ EOT
107
134
  assert_equal expect, @output.string
108
135
  end
109
136
 
137
+ def test_stage1_ncx_escape
138
+ @producer.params["title"] = "Sample<>Book"
139
+ @producer.ncx(@output)
140
+ expect = <<EOT
141
+ <?xml version="1.0" encoding="UTF-8"?>
142
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
143
+ <head>
144
+ <meta name="dtb:depth" content="1"/>
145
+ <meta name="dtb:totalPageCount" content="0"/>
146
+ <meta name="dtb:maxPageNumber" content="0"/>
147
+ <meta name="dtb:uid" content="http://example.jp/"/>
148
+ </head>
149
+ <docTitle>
150
+ <text>Sample&lt;&gt;Book</text>
151
+ </docTitle>
152
+ <docAuthor>
153
+ <text></text>
154
+ </docAuthor>
155
+ <navMap>
156
+ <navPoint id="top" playOrder="1">
157
+ <navLabel>
158
+ <text>Sample&lt;&gt;Book</text>
159
+ </navLabel>
160
+ <content src="sample.html"/>
161
+ </navPoint>
162
+ </navMap>
163
+ </ncx>
164
+ EOT
165
+ assert_equal expect, @output.string
166
+ end
167
+
110
168
  def stage2
111
169
  # add one item
112
170
  @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
@@ -393,12 +451,11 @@ EOT
393
451
  @producer.mytoc(@output)
394
452
  expect = <<EOT
395
453
  <?xml version="1.0" encoding="UTF-8"?>
396
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
397
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
454
+ <!DOCTYPE html>
455
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
398
456
  <head>
399
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
400
- <meta http-equiv="Content-Style-Type" content="text/css"/>
401
- <meta name="generator" content="Re:VIEW"/>
457
+ <meta charset="UTF-8" />
458
+ <meta name="generator" content="Re:VIEW" />
402
459
  <title>Table of Contents</title>
403
460
  </head>
404
461
  <body>
@@ -425,12 +482,11 @@ EOT
425
482
  @producer.mytoc(@output)
426
483
  expect = <<EOT
427
484
  <?xml version="1.0" encoding="UTF-8"?>
428
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
429
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
485
+ <!DOCTYPE html>
486
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
430
487
  <head>
431
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
432
- <meta http-equiv="Content-Style-Type" content="text/css"/>
433
- <meta name="generator" content="Re:VIEW"/>
488
+ <meta charset="UTF-8" />
489
+ <meta name="generator" content="Re:VIEW" />
434
490
  <title>Table of Contents</title>
435
491
  </head>
436
492
  <body>
@@ -455,12 +511,11 @@ EOT
455
511
  @producer.cover(@output)
456
512
  expect = <<EOT
457
513
  <?xml version="1.0" encoding="UTF-8"?>
458
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
459
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
514
+ <!DOCTYPE html>
515
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
460
516
  <head>
461
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
462
- <meta http-equiv="Content-Style-Type" content="text/css"/>
463
- <meta name="generator" content="Re:VIEW"/>
517
+ <meta charset="UTF-8" />
518
+ <meta name="generator" content="Re:VIEW" />
464
519
  <title>Sample Book</title>
465
520
  </head>
466
521
  <body>
@@ -471,18 +526,38 @@ EOT
471
526
  assert_equal expect, @output.string
472
527
  end
473
528
 
529
+ def test_stage3_cover_escape
530
+ stage3
531
+ @producer.params["title"] = "Sample<>Book"
532
+ @producer.cover(@output)
533
+ expect = <<EOT
534
+ <?xml version="1.0" encoding="UTF-8"?>
535
+ <!DOCTYPE html>
536
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
537
+ <head>
538
+ <meta charset="UTF-8" />
539
+ <meta name="generator" content="Re:VIEW" />
540
+ <title>Sample&lt;&gt;Book</title>
541
+ </head>
542
+ <body>
543
+ <h1 class="cover-title">Sample&lt;&gt;Book</h1>
544
+ </body>
545
+ </html>
546
+ EOT
547
+ assert_equal expect, @output.string
548
+ end
549
+
474
550
  def test_stage3_cover_with_image
475
551
  stage3
476
552
  @producer.params["coverimage"] = "sample.png"
477
553
  @producer.cover(@output)
478
554
  expect = <<EOT
479
555
  <?xml version="1.0" encoding="UTF-8"?>
480
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
481
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
556
+ <!DOCTYPE html>
557
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
482
558
  <head>
483
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
484
- <meta http-equiv="Content-Style-Type" content="text/css"/>
485
- <meta name="generator" content="Re:VIEW"/>
559
+ <meta charset="UTF-8" />
560
+ <meta name="generator" content="Re:VIEW" />
486
561
  <title>Sample Book</title>
487
562
  </head>
488
563
  <body>
@@ -495,18 +570,42 @@ EOT
495
570
  assert_equal expect, @output.string
496
571
  end
497
572
 
573
+ def test_stage3_cover_with_image_escape
574
+ stage3
575
+ @producer.params["title"] = "Sample<>Book"
576
+ @producer.params["coverimage"] = "sample.png"
577
+ @producer.cover(@output)
578
+ expect = <<EOT
579
+ <?xml version="1.0" encoding="UTF-8"?>
580
+ <!DOCTYPE html>
581
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
582
+ <head>
583
+ <meta charset="UTF-8" />
584
+ <meta name="generator" content="Re:VIEW" />
585
+ <title>Sample&lt;&gt;Book</title>
586
+ </head>
587
+ <body>
588
+ <div id="cover-image" class="cover-image">
589
+ <img src="sample.png" alt="Sample&lt;&gt;Book" class="max"/>
590
+ </div>
591
+ </body>
592
+ </html>
593
+ EOT
594
+ assert_equal expect, @output.string
595
+ end
596
+
498
597
  def test_colophon_default
499
598
  @producer.params["aut"] = ["Mr.Smith"]
500
599
  @producer.params["pbl"] = ["BLUEPRINT"]
600
+ @producer.params["isbn"] = "9784797372274"
501
601
  @producer.colophon(@output)
502
602
  expect = <<EOT
503
603
  <?xml version="1.0" encoding="UTF-8"?>
504
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
505
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
604
+ <!DOCTYPE html>
605
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
506
606
  <head>
507
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
508
- <meta http-equiv="Content-Style-Type" content="text/css"/>
509
- <meta name="generator" content="Re:VIEW"/>
607
+ <meta charset="UTF-8" />
608
+ <meta name="generator" content="Re:VIEW" />
510
609
  <title>Colophon</title>
511
610
  </head>
512
611
  <body>
@@ -518,6 +617,7 @@ EOT
518
617
  <table class="colophon">
519
618
  <tr><th>Author</th><td>Mr.Smith</td></tr>
520
619
  <tr><th>Publisher</th><td>BLUEPRINT</td></tr>
620
+ <tr><th>ISBN</th><td>978-4-79737-227-4</td></tr>
521
621
  </table>
522
622
  </div>
523
623
  </body>
@@ -526,6 +626,42 @@ EOT
526
626
  assert_equal expect, @output.string
527
627
  end
528
628
 
629
+ 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"]
636
+ @producer.colophon(@output)
637
+ expect = <<EOT
638
+ <?xml version="1.0" encoding="UTF-8"?>
639
+ <!DOCTYPE html>
640
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
641
+ <head>
642
+ <meta charset="UTF-8" />
643
+ <meta name="generator" content="Re:VIEW" />
644
+ <title>Colophon</title>
645
+ </head>
646
+ <body>
647
+ <div class="colophon">
648
+ <p class="title">&lt;&amp;Sample Book&gt;<br /><span class="subtitle">Sample&lt;&gt;Subtitle</span></p>
649
+ <div class="pubhistory">
650
+ <p>published by Jan. 1, 2011</p>
651
+ </div>
652
+ <table class="colophon">
653
+ <tr><th>Author</th><td>Mr.Smith, Mr.&amp;Anderson</td></tr>
654
+ <tr><th>Publisher</th><td>BLUEPRINT, COPY&lt;&gt;EDIT</td></tr>
655
+ <tr><th>ISBN</th><td>978-4-79737-227-4</td></tr>
656
+ </table>
657
+ <p class="copyright">COPYRIGHT 2016 &lt;&gt;<br />&amp; REVIEW</p>
658
+ </div>
659
+ </body>
660
+ </html>
661
+ EOT
662
+ assert_equal expect, @output.string
663
+ end
664
+
529
665
  def test_colophon_pht
530
666
  @producer.params["aut"] = ["Mr.Smith"]
531
667
  @producer.params["pbl"] = ["BLUEPRINT"]
@@ -533,12 +669,11 @@ EOT
533
669
  @producer.colophon(@output)
534
670
  expect = <<EOT
535
671
  <?xml version="1.0" encoding="UTF-8"?>
536
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
537
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
672
+ <!DOCTYPE html>
673
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
538
674
  <head>
539
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
540
- <meta http-equiv="Content-Style-Type" content="text/css"/>
541
- <meta name="generator" content="Re:VIEW"/>
675
+ <meta charset="UTF-8" />
676
+ <meta name="generator" content="Re:VIEW" />
542
677
  <title>Colophon</title>
543
678
  </head>
544
679
  <body>
@@ -559,6 +694,21 @@ EOT
559
694
  assert_equal expect, @output.string
560
695
  end
561
696
 
697
+ def test_isbn13
698
+ @producer.params["isbn"] = "9784797372274"
699
+ assert_equal "978-4-79737-227-4", @producer.isbn_hyphen
700
+ end
701
+
702
+ def test_isbn10
703
+ @producer.params["isbn"] = "4797372273"
704
+ assert_equal "4-79737-227-3", @producer.isbn_hyphen
705
+ end
706
+
707
+ def test_isbn_nil
708
+ @producer.params["isbn"] = nil
709
+ assert_equal nil, @producer.isbn_hyphen
710
+ end
711
+
562
712
  # def test_duplicate_id
563
713
  # stage3
564
714
  # assert_raise(Error) do
@@ -566,4 +716,69 @@ EOT
566
716
  # end
567
717
  # end
568
718
 
719
+ def test_title
720
+ @producer.params["aut"] = ["Mr.Smith"]
721
+ @producer.params["pbl"] = ["BLUEPRINT"]
722
+ @producer.titlepage(@output)
723
+ expect = <<EOT
724
+ <?xml version="1.0" encoding="UTF-8"?>
725
+ <!DOCTYPE html>
726
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
727
+ <head>
728
+ <meta charset="UTF-8" />
729
+ <meta name="generator" content="Re:VIEW" />
730
+ <title>Sample Book</title>
731
+ </head>
732
+ <body>
733
+ <h1 class="tp-title">Sample Book</h1>
734
+ <p>
735
+ <br />
736
+ <br />
737
+ </p>
738
+ <h2 class="tp-author">Mr.Smith</h2>
739
+ <p>
740
+ <br />
741
+ <br />
742
+ <br />
743
+ <br />
744
+ </p>
745
+ <h3 class="tp-publisher">BLUEPRINT</h3>
746
+ </body>
747
+ </html>
748
+ EOT
749
+ assert_equal expect, @output.string
750
+ end
751
+
752
+ def test_title_single_value_param
753
+ @producer.params["aut"] = "Mr.Smith"
754
+ @producer.params["pbl"] = "BLUEPRINT"
755
+ @producer.titlepage(@output)
756
+ expect = <<EOT
757
+ <?xml version="1.0" encoding="UTF-8"?>
758
+ <!DOCTYPE html>
759
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
760
+ <head>
761
+ <meta charset="UTF-8" />
762
+ <meta name="generator" content="Re:VIEW" />
763
+ <title>Sample Book</title>
764
+ </head>
765
+ <body>
766
+ <h1 class="tp-title">Sample Book</h1>
767
+ <p>
768
+ <br />
769
+ <br />
770
+ </p>
771
+ <h2 class="tp-author">Mr.Smith</h2>
772
+ <p>
773
+ <br />
774
+ <br />
775
+ <br />
776
+ <br />
777
+ </p>
778
+ <h3 class="tp-publisher">BLUEPRINT</h3>
779
+ </body>
780
+ </html>
781
+ EOT
782
+ assert_equal expect, @output.string
783
+ end
569
784
  end
@@ -24,12 +24,12 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
24
24
  end
25
25
 
26
26
  def test_epubmaker_cmd
27
- if RUBY_VERSION !~ /^1.8/
27
+ if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
28
28
  config = prepare_samplebook(@tmpdir1)
29
29
  builddir = @tmpdir1 + "/" + config['bookname'] + '-epub'
30
30
  assert ! File.exist?(builddir)
31
31
 
32
- ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
32
+ ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG["EXEEXT"]
33
33
  Dir.chdir(@tmpdir1) do
34
34
  system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} config.yml 1>/dev/null 2>/dev/null")
35
35
  end
@@ -0,0 +1,60 @@
1
+ require 'test_helper'
2
+ require 'review/extentions/hash'
3
+
4
+ class TestExtentionsHash < Test::Unit::TestCase
5
+ def test_deep_merge_simple
6
+ assert_equal({:a => 1, :b => 3, :c => 4},
7
+ {:a => 1, :b => 2}.deep_merge({:b => 3, :c => 4}))
8
+ end
9
+ def test_deep_empty_r
10
+ assert_equal({:b => 3, :c => 4},
11
+ {}.deep_merge({:b => 3, :c => 4}))
12
+ end
13
+ def test_deep_empty_l
14
+ assert_equal({:a => 1, :b => 2},
15
+ {:a => 1, :b => 2}.deep_merge({}))
16
+ end
17
+ def test_deep_merge_nested
18
+ assert_equal({:a => {:aa => 1, :ab => 2},
19
+ :b => {:ba => 5, :bb => 4, :bc => 6},
20
+ :c => {:ca => 1}},
21
+ {:a => {:aa => 1, :ab => 2},
22
+ :b => {:ba => 3, :bb => 4}}.deep_merge({:b => {:ba => 5, :bc => 6},
23
+ :c => {:ca => 1}}))
24
+ end
25
+ def test_deep_merge_with_array
26
+ assert_equal({:a => "string", :b => ["BA"],
27
+ :c => {:ca => [:cab => "CAB"], :cb => 3}},
28
+
29
+ {:a => 1, :b => ["shouldoverriden"],
30
+ :c => {:ca => [:caa => "shouldoverriden"], :cb => 3}}.
31
+ deep_merge({:a => "string", :b => ["BA"],
32
+ :c => {:ca => [:cab => "CAB"]}}))
33
+ end
34
+
35
+ def test_deep_merge_b_simple
36
+ a = {:a => 1, :b => 2}
37
+ a.deep_merge!({:b => 3, :c => 4})
38
+ assert_equal({:a => 1, :b => 3, :c => 4}, a)
39
+ end
40
+ def test_deep_b_empty_r
41
+ a = {}
42
+ a.deep_merge!({:b => 3, :c => 4})
43
+ assert_equal({:b => 3, :c => 4}, a)
44
+ end
45
+ def test_deep_b_empty_l
46
+ a = {:a => 1, :b => 2}
47
+ a.deep_merge!({})
48
+ assert_equal({:a => 1, :b => 2}, a)
49
+ end
50
+ def test_deep_merge_b_nested
51
+ a = {:a => {:aa => 1, :ab => 2},
52
+ :b => {:ba => 3, :bb => 4}}
53
+ a.deep_merge!({:b => {:ba => 5, :bc => 6},
54
+ :c => {:ca => 1}})
55
+ assert_equal({:a => {:aa => 1, :ab => 2},
56
+ :b => {:ba => 5, :bb => 4, :bc => 6},
57
+ :c => {:ca => 1}},
58
+ a)
59
+ end
60
+ end
@@ -1,53 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
2
2
  require 'test/unit'
3
3
 
4
- def compile_document(str, force_to_s=true)
5
- @compiler.setup_parser(str)
6
- @compiler.parse("Document")
7
- if force_to_s
8
- @compiler.result.to_doc
9
- else
10
- @compiler.result
11
- end
12
- end
13
-
14
- def compile_block(str, force_to_s=true)
15
- @compiler.setup_parser(str)
16
- @compiler.parse("Document")
17
- if force_to_s
18
- @compiler.result.to_doc
19
- else
20
- @compiler.result
21
- end
22
- end
23
-
24
- def compile_inline(str, force_to_s=true)
25
- @compiler.setup_parser(str)
26
- @compiler.parse("Paragraph")
27
- if force_to_s
28
- ## @compiler.result.map(&:to_doc).join
29
- @compiler.result.to_doc
30
- else
31
- @compiler.result
32
- end
33
- end
34
-
35
- def compile_blockelem(str, force_to_s=true)
36
- @compiler.setup_parser(str)
37
- @compiler.parse("BlockElement")
38
- if force_to_s
39
- @compiler.result.to_doc
40
- else
41
- @compiler.result
42
- end
43
- end
44
-
45
- def compile_headline(str)
46
- @compiler.setup_parser(str)
47
- @compiler.parse("Headline")
48
- @compiler.result.to_doc
49
- end
50
-
51
4
  def touch_file(path)
52
5
  File.open(path, "w").close
53
6
  path
@@ -63,6 +16,10 @@ def prepare_samplebook(srcdir)
63
16
  YAML.load(File.open(srcdir + "/config.yml"))
64
17
  end
65
18
 
19
+ def compile_inline(text)
20
+ @builder.compile_inline(text)
21
+ end
22
+
66
23
  def compile_block(text)
67
24
  method_name = "compile_block_#{@builder.target_name}"
68
25
  if !self.respond_to?(method_name, true)