test/test_epub3maker.rb in review-2.0.0.beta1 vs test/test_epub3maker.rb in review-2.0.0

- old
+ new

@@ -67,11 +67,11 @@ </metadata> <manifest> <item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/> <item id="sample" href="sample.html" media-type="application/xhtml+xml"/> </manifest> - <spine> + <spine page-progression-direction="ltr"> <itemref idref="sample" linear="no"/> </spine> <guide> <reference type="cover" title="Cover" href="sample.html"/> <reference type="toc" title="Table of Contents" href="sample-toc.html"/> @@ -79,10 +79,84 @@ </package> EOT assert_equal expect, @output.string end + def test_stage1_opf_ebpaj + @producer.merge_params({"opf_prefix"=>{"ebpaj"=>"http://www.ebpaj.jp/"},"opf_meta"=>{"ebpaj:guide-version" => "1.1.2"}}) + @producer.opf(@output) + expect = <<EOT +<?xml version="1.0" encoding="UTF-8"?> +<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en" prefix="ebpaj: http://www.ebpaj.jp/"> + <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> + <dc:title id="title">Sample Book</dc:title> + <dc:language id="language">en</dc:language> + <dc:date id="date">2011-01-01</dc:date> + <meta property="dcterms:modified">2014-12-13T14:15:16Z</meta> + <dc:identifier id="BookId">http://example.jp/</dc:identifier> + <meta property="ebpaj:guide-version">1.1.2</meta> + </metadata> + <manifest> + <item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/> + <item id="sample" href="sample.html" media-type="application/xhtml+xml"/> + </manifest> + <spine page-progression-direction="ltr"> + <itemref idref="sample" linear="no"/> + </spine> + <guide> + <reference type="cover" title="Cover" href="sample.html"/> + <reference type="toc" title="Table of Contents" href="sample-toc.html"/> + </guide> +</package> +EOT + assert_equal expect, @output.string + end + + def test_stage1_opf_fileas + @producer.params["title"] = {"name" => "これは書籍です", "file-as" => "コレハショセキデス"} + @producer.params["aut"] = [{"name" => "著者A", "file-as" => "チョシャA"}, {"name" => "著者B", "file-as" => "チョシャB"}] + @producer.params["pbl"] = [{"name" => "出版社", "file-as" => "シュッパンシャ"}] + @producer.opf(@output) + expect = <<EOT +<?xml version="1.0" encoding="UTF-8"?> +<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en"> + <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> + <dc:title id="title">これは書籍です</dc:title> + <meta refines="#title" property="file-as">コレハショセキデス</meta> + <dc:language id="language">en</dc:language> + <dc:date id="date">2011-01-01</dc:date> + <meta property="dcterms:modified">2014-12-13T14:15:16Z</meta> + <dc:identifier id="BookId">http://example.jp/</dc:identifier> + <dc:creator id="aut-0">著者A</dc:creator> + <meta refines="#aut-0" property="role" scheme="marc:relators">aut</meta> + <meta refines="#aut-0" property="file-as">チョシャA</meta> + <dc:creator id="aut-1">著者B</dc:creator> + <meta refines="#aut-1" property="role" scheme="marc:relators">aut</meta> + <meta refines="#aut-1" property="file-as">チョシャB</meta> + <dc:contributor id="pbl-0">出版社</dc:contributor> + <meta refines="#pbl-0" property="role" scheme="marc:relators">pbl</meta> + <meta refines="#pbl-0" property="file-as">シュッパンシャ</meta> + <dc:publisher id="pub-pbl-0">出版社</dc:publisher> + <meta refines="#pub-pbl-0" property="role" scheme="marc:relators">pbl</meta> + <meta refines="#pub-pbl-0" property="file-as">シュッパンシャ</meta> + </metadata> + <manifest> + <item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/> + <item id="sample" href="sample.html" media-type="application/xhtml+xml"/> + </manifest> + <spine page-progression-direction="ltr"> + <itemref idref="sample" linear="no"/> + </spine> + <guide> + <reference type="cover" title="Cover" href="sample.html"/> + <reference type="toc" title="Table of Contents" href="sample-toc.html"/> + </guide> +</package> +EOT + assert_equal expect, @output.string + end + def test_stage1_ncx @producer.ncx(@output) expect = <<EOT <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> @@ -134,11 +208,11 @@ <manifest> <item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/> <item id="sample" href="sample.html" media-type="application/xhtml+xml"/> <item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/> </manifest> - <spine> + <spine page-progression-direction="ltr"> <itemref idref="sample" linear="no"/> <itemref idref="ch01-html"/> </spine> <guide> <reference type="cover" title="Cover" href="sample.html"/> @@ -248,11 +322,11 @@ <item id="sample-JPEG" href="sample.JPEG" media-type="image/jpeg"/> <item id="sample-SvG" href="sample.SvG" media-type="image/svg+xml"/> <item id="sample-GIF" href="sample.GIF" media-type="image/gif"/> <item id="sample-css" href="sample.css" media-type="text/css"/> </manifest> - <spine> + <spine page-progression-direction="ltr"> <itemref idref="sample" linear="no"/> <itemref idref="ch01-html"/> <itemref idref="ch02-html"/> <itemref idref="ch03-html"/> <itemref idref="ch04-html"/> @@ -462,9 +536,87 @@ </body> </html> EOT assert_equal expect, @output.string end + + def test_colophon_history + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["pbl"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.merge_params({"language" => "ja"}) + history = @producer.instance_eval{ @epub.colophon_history } + expect = <<EOT + <div class="pubhistory"> + <p>2011年1月1日 発行</p> + </div> +EOT + assert_equal expect, history + end + + def test_colophon_history_2 + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["pbl"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.merge_params({"language" => "ja", + "history" => [[ + "2011-08-03 v1.0.0版発行", + "2012-02-15 v1.1.0版発行", + ]] }) + history = @producer.instance_eval{ @epub.colophon_history } + expect = <<EOT + <div class="pubhistory"> + <p>2011年8月3日 v1.0.0版発行</p> + <p>2012年2月15日 v1.1.0版発行</p> + </div> +EOT + assert_equal expect, history + end + + def test_colophon_history_date + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["pbl"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.merge_params({"language" => "ja", + "history" => [[ + "2011-08-03", + "2012-02-15", + ]] }) + history = @producer.instance_eval{ @epub.colophon_history } + expect = <<EOT + <div class="pubhistory"> + <p>2011年8月3日 初版第1刷 発行</p> + <p>2012年2月15日 初版第2刷 発行</p> + </div> +EOT + assert_equal expect, history + end + + def test_colophon_history_date2 + @producer.params["aut"] = ["Mr.Smith"] + @producer.params["pbl"] = ["BLUEPRINT"] + @producer.params["pht"] = ["Mrs.Smith"] + @producer.merge_params({"language" => "ja", + "history" => [[ + "2011-08-03", + "2012-02-15", + ],[ + "2012-10-01", + ],[ + "2013-03-01", + ]] }) + history = @producer.instance_eval{ @epub.colophon_history } + expect = <<EOT + <div class="pubhistory"> + <p>2011年8月3日 初版第1刷 発行</p> + <p>2012年2月15日 初版第2刷 発行</p> + <p>2012年10月1日 第2版第1刷 発行</p> + <p>2013年3月1日 第3版第1刷 発行</p> + </div> +EOT + assert_equal expect, history + end + # def test_duplicate_id # stage3 # assert_raise(Error) do # @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})