gepub 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/gepub.gemspec +1 -2
  4. data/lib/gepub/version.rb +1 -1
  5. metadata +4 -110
  6. data/spec/bindings_spec.rb +0 -34
  7. data/spec/book_spec.rb +0 -307
  8. data/spec/builder_spec.rb +0 -614
  9. data/spec/example_spec.rb +0 -192
  10. data/spec/fixtures/builder/img/cover.jpg +0 -0
  11. data/spec/fixtures/builder/resources/noise.m4 +0 -0
  12. data/spec/fixtures/builder/resources/noise_2.m4a +0 -0
  13. data/spec/fixtures/builder/text/cover.xhtml +0 -11
  14. data/spec/fixtures/builder/text/localresource.conf +0 -2
  15. data/spec/fixtures/builder/text/memo.txt +0 -1
  16. data/spec/fixtures/builder/text/nav.xhtml +0 -12
  17. data/spec/fixtures/epubcheck-4.1.1/CHANGELOG.txt +0 -92
  18. data/spec/fixtures/epubcheck-4.1.1/LICENSE.txt +0 -28
  19. data/spec/fixtures/epubcheck-4.1.1/README.txt +0 -101
  20. data/spec/fixtures/epubcheck-4.1.1/THIRD-PARTY.txt +0 -60
  21. data/spec/fixtures/epubcheck-4.1.1/epubcheck.jar +0 -0
  22. data/spec/fixtures/epubcheck-4.1.1/lib/Saxon-HE-9.8.0-8.jar +0 -0
  23. data/spec/fixtures/epubcheck-4.1.1/lib/animal-sniffer-annotations-1.14.jar +0 -0
  24. data/spec/fixtures/epubcheck-4.1.1/lib/checker-compat-qual-2.0.0.jar +0 -0
  25. data/spec/fixtures/epubcheck-4.1.1/lib/common-image-3.4.1.jar +0 -0
  26. data/spec/fixtures/epubcheck-4.1.1/lib/common-io-3.4.1.jar +0 -0
  27. data/spec/fixtures/epubcheck-4.1.1/lib/common-lang-3.4.1.jar +0 -0
  28. data/spec/fixtures/epubcheck-4.1.1/lib/commons-compress-1.18.jar +0 -0
  29. data/spec/fixtures/epubcheck-4.1.1/lib/error_prone_annotations-2.1.3.jar +0 -0
  30. data/spec/fixtures/epubcheck-4.1.1/lib/guava-24.0-android.jar +0 -0
  31. data/spec/fixtures/epubcheck-4.1.1/lib/imageio-core-3.4.1.jar +0 -0
  32. data/spec/fixtures/epubcheck-4.1.1/lib/imageio-jpeg-3.4.1.jar +0 -0
  33. data/spec/fixtures/epubcheck-4.1.1/lib/imageio-metadata-3.4.1.jar +0 -0
  34. data/spec/fixtures/epubcheck-4.1.1/lib/j2objc-annotations-1.1.jar +0 -0
  35. data/spec/fixtures/epubcheck-4.1.1/lib/jackson-core-asl-1.9.12.jar +0 -0
  36. data/spec/fixtures/epubcheck-4.1.1/lib/jackson-mapper-asl-1.9.12.jar +0 -0
  37. data/spec/fixtures/epubcheck-4.1.1/lib/jing-20120724.0.0.jar +0 -0
  38. data/spec/fixtures/epubcheck-4.1.1/lib/jsr305-1.3.9.jar +0 -0
  39. data/spec/fixtures/epubcheck-4.1.1/lib/sac-1.3.jar +0 -0
  40. data/spec/fixtures/epubcheck-4.1.1/licenses/Apache-2.0.txt +0 -201
  41. data/spec/fixtures/epubcheck-4.1.1/licenses/BSD-3-Clause.txt +0 -27
  42. data/spec/fixtures/epubcheck-4.1.1/licenses/MPL-1.0.txt +0 -360
  43. data/spec/fixtures/epubcheck-4.1.1/licenses/W3C.txt +0 -16
  44. data/spec/fixtures/testdata/0.html +0 -12
  45. data/spec/fixtures/testdata/1.html +0 -10
  46. data/spec/fixtures/testdata/image1.jpg +0 -0
  47. data/spec/fixtures/testdata/package_2_0.opf +0 -23
  48. data/spec/fixtures/testdata/test.opf +0 -69
  49. data/spec/fixtures/testdata/test2.opf +0 -63
  50. data/spec/fixtures/testdata/test_with_bindings.opf +0 -67
  51. data/spec/fixtures/testdata/wasteland-20120118.epub +0 -0
  52. data/spec/gepub_deprectad_api_spec.rb +0 -229
  53. data/spec/gepub_spec.rb +0 -229
  54. data/spec/manifest_spec.rb +0 -36
  55. data/spec/metadata_spec.rb +0 -219
  56. data/spec/package_spec.rb +0 -150
  57. data/spec/spec_helper.rb +0 -57
  58. data/spec/spine_spec.rb +0 -55
@@ -1,16 +0,0 @@
1
- W3C® SOFTWARE NOTICE AND LICENSE
2
-
3
- Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
4
-
5
- This W3C work (including software, documents, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
6
-
7
- Permission to use, copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications, that you make:
8
-
9
- The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
10
- Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, a short notice of the following form (hypertext is preferred, text is permitted) should be used within the body of any redistributed or derivative code: "Copyright © [$date-of-software] World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/"
11
- Notice of any changes or modifications to the W3C files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
12
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
13
-
14
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
15
-
16
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <title>gepuber test book</title>
5
- <link rel="stylesheet" type="text/css" href="gepuber.css"></link>
6
- </head>
7
- <body>
8
- <div>
9
- <img class="cover" src="img/cover.jpg" alt="cover" />
10
- </div>
11
- </body>
12
- </html>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <title>gepuber test book: page 1</title>
5
- <link rel="stylesheet" type="text/css" href="gepuber.css"></link>
6
- </head>
7
- <body>
8
- <p>contents comes here</p>
9
- </body>
10
- </html>
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="BookId">
3
- <metadata xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/">
4
- <dc:title>thetitle</dc:title>
5
- <dc:creator>theauthor</dc:creator>
6
- <dc:contributor>contributors contributors!</dc:contributor>
7
- <dc:publisher>thepublisher</dc:publisher>
8
- <dc:date>2010-05-05</dc:date>
9
- <dc:identifier id="BookId">http://example.jp/foobar/</dc:identifier>
10
- <dc:language>ja</dc:language>
11
- <meta name="cover" content="cover-image" />
12
- </metadata>
13
- <manifest>
14
- <item id="cover-image" href="img/cover.jpg" properties="cover-image" media-type="image/jpeg" />
15
- <item id="c1" href="text/foobar.xhtml" media-type="application/xhtml+xml"/>
16
- <item id="c2" href="text/barbar.xhtml" media-type="application/xhtml+xml"/>
17
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
18
- </manifest>
19
- <spine toc="ncx">
20
- <itemref idref="c1"/>
21
- <itemref idref="c2"/>
22
- </spine>
23
- </package>
@@ -1,69 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
-
3
- <package xmlns="http://www.idpf.org/2007/opf" version="3.0"
4
- unique-identifier="pub-id"
5
- xml:lang="ja"
6
- prefix="foaf: http://xmlns.com/foaf/spec/
7
- rendition: http://www.idpf.org/vocab/rendition/#"
8
- >
9
- <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" >
10
- <dc:identifier id="pub-id">urn:uuid:1234567890</dc:identifier>
11
- <meta refines="#pub-id" property="identifier-type" scheme="xsd:string">uuid</meta>
12
- <dc:identifier id="pub-id2">http://example.jp/epub/test/url</dc:identifier>
13
- <meta refines="#pub-id2" property="identifier-type" scheme="xsd:string">uri</meta>
14
-
15
- <dc:title id="series">Series Title</dc:title>
16
- <meta refines="#series" property="title-type">collection</meta>
17
- <meta refines="#series" property="display-seq">2</meta>
18
- <dc:title id="title">TheTitle</dc:title>
19
- <meta refines="#title" property="title-type">main</meta>
20
- <meta refines="#title" property="display-seq">1</meta>
21
-
22
- <dc:language id="pub-lang">ja</dc:language>
23
-
24
- <dc:creator id="author1">最初の著者</dc:creator>
25
- <meta refines="#author1" property="role" scheme="marc:relators">aut</meta>
26
- <meta refines="#author1" property="display-seq">1</meta>
27
- <meta refines="#author1" property="file-as">さいしょのちょしゃ</meta>
28
- <dc:creator id="author3">三人目</dc:creator>
29
- <meta refines="#author3" property="role" scheme="marc:relators">prg</meta>
30
- <meta refines="#author3" property="display-seq">3</meta>
31
- <meta refines="#author3" property="file-as">さんにんめ</meta>
32
- <dc:creator id="author2">ふたりめ</dc:creator>
33
- <meta refines="#author2" property="role" scheme="marc:relators">aut</meta>
34
- <meta refines="#author2" property="display-seq">2</meta>
35
- <meta refines="#author2" property="file-as">ふたりめ</meta>
36
-
37
-
38
- <dc:publisher id="publisher">小嶋智</dc:publisher>
39
-
40
- <meta property="dcterms:issued" id="issued">2012-02-12T15:00:00Z</meta>
41
- <meta property="dcterms:modified" id="modified">2012-02-12T19:00:00Z</meta>
42
-
43
- <meta property="rendition:layout">pre-paginated</meta>
44
- <meta property="rendition:spread">both</meta>
45
-
46
- <meta name="cover" content="cover-image" />
47
- </metadata>
48
-
49
-
50
- <manifest>
51
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
52
- <item id="cover" href="cover/cover.xhtml" media-type="application/xhtml+xml" />
53
- <item id="cover-image" href="img/cover.jpg" properties="cover-image" media-type="image/jpeg" />
54
- <item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" />
55
- <item id="nav" href="nav.xhtml" properties="nav" media-type="application/xhtml+xml" />
56
- <item id="chap1" href="chap1.xhtml" media-type="application/xhtml+xml" />
57
- <item id="css" href="style/default.css" media-type="text/css" />
58
- <item id="object" href="img/test.png" media-type="image/png" />
59
- <item id="object2" href="resource/image.jpg" media-type="image/jpg" />
60
- </manifest>
61
-
62
- <spine toc="ncx" page-progression-direction="ltr">
63
- <itemref idref="cover" linear="no" />
64
- <itemref idref="toc" linear="yes" />
65
- <itemref idref="chap1" linear="yes" />
66
- <itemref idref="nav" linear="no" />
67
- </spine>
68
-
69
- </package>
@@ -1,63 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
-
3
- <package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="pub-id" xml:lang="ja">
4
- <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" >
5
- <dc:identifier id="pub-id">urn:uuid:1234567890</dc:identifier>
6
- <meta refines="#pub-id" property="identifier-type" scheme="xsd:string">uuid</meta>
7
- <dc:identifier id="pub-id2">http://example.jp/epub/test/url</dc:identifier>
8
- <meta refines="#pub-id2" property="identifier-type" scheme="xsd:string">uri</meta>
9
-
10
- <dc:title id="title">TheTitle</dc:title>
11
- <meta refines="#title" property="title-type">main</meta>
12
- <meta refines="#title" property="display-seq">2</meta>
13
- <dc:title id="series">Series Title</dc:title>
14
- <meta refines="#series" property="title-type">collection</meta>
15
- <meta refines="#series" property="display-seq">3</meta>
16
- <dc:title id="subtitle">subTitle diplaies first</dc:title>
17
- <meta refines="#subtitle" property="title-type">subtitle</meta>
18
- <meta refines="#subtitle" property="display-seq">1</meta>
19
-
20
- <dc:language id="pub-lang">ja</dc:language>
21
-
22
- <dc:creator id="author1">最初の著者</dc:creator>
23
- <meta refines="#author1" property="role" scheme="marc:relators">aut</meta>
24
- <meta refines="#author1" property="display-seq">1</meta>
25
- <meta refines="#author1" property="file-as">さいしょのちょしゃ</meta>
26
- <dc:creator id="author3">三人目</dc:creator>
27
- <meta refines="#author3" property="role" scheme="marc:relators">prg</meta>
28
- <meta refines="#author3" property="display-seq">3</meta>
29
- <meta refines="#author3" property="file-as">さんにんめ</meta>
30
- <dc:creator id="author2">ふたりめ</dc:creator>
31
- <meta refines="#author2" property="role" scheme="marc:relators">aut</meta>
32
- <meta refines="#author2" property="display-seq">2</meta>
33
- <meta refines="#author2" property="file-as">ふたりめ</meta>
34
-
35
-
36
- <dc:publisher id="publisher">小嶋智</dc:publisher>
37
-
38
- <meta property="dcterms:issued" id="issued">2012-02-12T15:00:00Z</meta>
39
- <meta property="dcterms:modified" id="modified">2012-02-12T19:00:00Z</meta>
40
- <meta name="cover" content="cover-image" />
41
- </metadata>
42
-
43
-
44
- <manifest>
45
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
46
- <item id="cover" href="cover/cover.xhtml" media-type="application/xhtml+xml" />
47
- <item id="cover-image" href="img/cover.jpg" properties="cover-image" media-type="image/jpeg" />
48
- <item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" />
49
- <item id="nav" href="nav.xhtml" properties="nav" media-type="application/xhtml+xml" />
50
- <item id="chap1" href="chap1.xhtml" media-type="application/xhtml+xml" />
51
- <item id="css" href="style/default.css" media-type="text/css" />
52
- <item id="object" href="img/test.png" media-type="image/png" />
53
- <item id="object2" href="resource/image.jpg" media-type="image/jpg" />
54
- </manifest>
55
-
56
- <spine toc="ncx" page-progression-direction="ltr">
57
- <itemref idref="cover" linear="no" />
58
- <itemref idref="toc" linear="yes" />
59
- <itemref idref="chap1" linear="yes" />
60
- <itemref idref="nav" linear="no" />
61
- </spine>
62
-
63
- </package>
@@ -1,67 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
-
3
- <package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="pub-id" xml:lang="ja">
4
- <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" >
5
- <dc:identifier id="pub-id">urn:uuid:1234567890</dc:identifier>
6
- <meta refines="#pub-id" property="identifier-type" scheme="xsd:string">uuid</meta>
7
- <dc:identifier id="pub-id2">http://example.jp/epub/test/url</dc:identifier>
8
- <meta refines="#pub-id2" property="identifier-type" scheme="xsd:string">uri</meta>
9
-
10
- <dc:title id="series">Series Title</dc:title>
11
- <meta refines="#series" property="title-type">collection</meta>
12
- <meta refines="#series" property="display-seq">2</meta>
13
- <dc:title id="title">TheTitle</dc:title>
14
- <meta refines="#title" property="title-type">main</meta>
15
- <meta refines="#title" property="display-seq">1</meta>
16
-
17
- <dc:language id="pub-lang">ja</dc:language>
18
-
19
- <dc:creator id="author1">最初の著者</dc:creator>
20
- <meta refines="#author1" property="role" scheme="marc:relators">aut</meta>
21
- <meta refines="#author1" property="display-seq">1</meta>
22
- <meta refines="#author1" property="file-as">さいしょのちょしゃ</meta>
23
- <dc:creator id="author3">三人目</dc:creator>
24
- <meta refines="#author3" property="role" scheme="marc:relators">prg</meta>
25
- <meta refines="#author3" property="display-seq">3</meta>
26
- <meta refines="#author3" property="file-as">さんにんめ</meta>
27
- <dc:creator id="author2">ふたりめ</dc:creator>
28
- <meta refines="#author2" property="role" scheme="marc:relators">aut</meta>
29
- <meta refines="#author2" property="display-seq">2</meta>
30
- <meta refines="#author2" property="file-as">ふたりめ</meta>
31
-
32
-
33
- <dc:publisher id="publisher">小嶋智</dc:publisher>
34
-
35
- <meta property="dcterms:issued" id="issued">2012-02-12T15:00:00Z</meta>
36
- <meta property="dcterms:modified" id="modified">2012-02-12T19:00:00Z</meta>
37
- <meta name="cover" content="cover-image" />
38
- </metadata>
39
-
40
-
41
- <manifest>
42
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
43
- <item id="cover" href="cover/cover.xhtml" media-type="application/xhtml+xml" />
44
- <item id="cover-image" href="img/cover.jpg" properties="cover-image" media-type="image/jpeg" />
45
- <item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" />
46
- <item id="nav" href="nav.xhtml" properties="nav" media-type="application/xhtml+xml" />
47
- <item id="chap1" href="chap1.xhtml" media-type="application/xhtml+xml" />
48
- <item id="css" href="style/default.css" media-type="text/css" />
49
- <item id="object" href="img/test.png" media-type="image/png" />
50
- <item id="object2" href="resource/image.jpg" media-type="image/jpg" />
51
- <item id="h" href="h_foo.html" media-type="application/xhtml+xml" properties="scripted" />
52
- <item id="v" href="v_foo.html" media-type="application/xhtml+xml" properties="scripted" />
53
- </manifest>
54
-
55
- <spine toc="ncx" page-progression-direction="ltr">
56
- <itemref idref="cover" linear="no" />
57
- <itemref idref="toc" linear="yes" />
58
- <itemref idref="chap1" linear="yes" />
59
- <itemref idref="nav" linear="no" />
60
- </spine>
61
-
62
- <bindings>
63
- <mediaType handler="h" media-type="application/x-foreign-type" />
64
- <mediaType handler="v" media-type="application/x-other-foreign-type" />
65
- </bindings>
66
-
67
- </package>
@@ -1,229 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require File.dirname(__FILE__) + '/spec_helper.rb'
3
- require 'rubygems'
4
- require 'nokogiri'
5
-
6
- describe GEPUB::Item do
7
- it "should return atttributes" do
8
- item = GEPUB::Item.new('theid', 'foo/bar.bar', 'application/xhtml+xml')
9
- expect(item.itemid).to eq('theid')
10
- expect(item.href).to eq('foo/bar.bar')
11
- expect(item.mediatype).to eq('application/xhtml+xml')
12
- end
13
-
14
- it "should handle html" do
15
- item = GEPUB::Item.new('id', 'text/foo.html')
16
- expect(item.mediatype).to eq('application/xhtml+xml')
17
- end
18
-
19
- it "should handle xhtml" do
20
- item = GEPUB::Item.new('id', 'text/foo.xhtml')
21
- expect(item.mediatype).to eq('application/xhtml+xml')
22
- end
23
-
24
- it "should handle JPG" do
25
- item = GEPUB::Item.new('id', 'img/foo.JPG')
26
- expect(item.mediatype).to eq('image/jpeg')
27
- end
28
-
29
- it "should handle css" do
30
- item = GEPUB::Item.new('id', 'img/foo.css')
31
- expect(item.mediatype).to eq('text/css')
32
- end
33
-
34
- it "should handle javascript" do
35
- item = GEPUB::Item.new('id', 'js/jQuery.js')
36
- expect(item.mediatype).to eq('text/javascript')
37
- end
38
-
39
- end
40
-
41
- describe GEPUB::Book do
42
- before do
43
- @book = GEPUB::Book.new('OEPBS/package.opf')
44
- @book.title = 'thetitle'
45
- @book.creator = "theauthor"
46
- @book.contributor = "contributors contributors!"
47
- @book.publisher = "thepublisher"
48
- @book.date = "2010-05-05"
49
- @book.identifier = "http://example.jp/foobar/"
50
- @book.language = 'ja'
51
- item1 = @book.add_item('text/foobar.xhtml',nil, 'c1')
52
- item1.add_content(StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c1</title></head><body><p>the first page</p></body></html>'))
53
- @book.spine.push(item1)
54
-
55
- item2 = @book.add_ordered_item('text/barbar.xhtml',
56
- StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c2</title></head><body><p>second page, whith is test chapter.</p></body></html>'),
57
- 'c2')
58
- item2.toc_text 'test chapter'
59
-
60
- item3 = @book.add_item('text/handler.xhtml',
61
- StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c2</title><script>alert("foo");</script></head><body><p>this is scripted item</p></body></html>')
62
- )
63
- item3.add_property('scripted')
64
- item3.is_handler_of('application/x-some-media-type')
65
- @item3_id = item3.id
66
-
67
- nav_string = <<EOF
68
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
69
- <head></head>
70
- <body>
71
- <nav epub:type="toc" id="toc">
72
- <h1>Table of contents</h1>
73
- <ol>
74
- <li><a href="foobar.xhtml">Chapter 1</a> </li>
75
- <li> <a href="barbar.xhtml">Chapter 2</a></li>
76
- </ol>
77
- </nav>
78
- </body>
79
- </html>
80
- EOF
81
- item3 = @book.add_ordered_item('text/nav.xhtml', StringIO.new(nav_string), 'nav').add_property('nav')
82
- end
83
-
84
- it "should have title" do
85
- expect(@book.title.to_s).to eq('thetitle')
86
- end
87
-
88
- it "should generate correct ncx" do
89
- ncx = Nokogiri::XML.parse(@book.ncx_xml).root
90
- expect(ncx.name).to eq('ncx')
91
- expect(ncx.attributes['version'].value).to eq('2005-1')
92
- ncx.namespaces['xmlns'] == 'http://www.daisy.org/z3986/2005/ncx/'
93
- end
94
-
95
- it "should have correct head in ncx" do
96
- head = Nokogiri::XML.parse(@book.ncx_xml).at_xpath('/xmlns:ncx/xmlns:head')
97
- expect(head).not_to be_nil
98
- expect(head.at_xpath("xmlns:meta[@name='dtb:uid']")['content']).to eq("http://example.jp/foobar/")
99
- expect(head.xpath("xmlns:meta[@name='dtb:depth']").size).to be > 0
100
- expect(head.xpath("xmlns:meta[@name='dtb:totalPageCount']").size).to be > 0
101
- expect(head.xpath("xmlns:meta[@name='dtb:maxPageNumber']").size).to be > 0
102
- end
103
-
104
- it "should have correct ncx doctitle" do
105
- doctitle = Nokogiri::XML.parse(@book.ncx_xml).root
106
-
107
- expect(doctitle.xpath('xmlns:docTitle').size).to be > 0
108
- expect(doctitle.at_xpath('xmlns:docTitle/xmlns:text').text).to eq('thetitle')
109
- end
110
-
111
- it "should correct ncx navmap" do
112
- ncx = Nokogiri::XML::parse(@book.ncx_xml).root
113
-
114
- expect(ncx.xpath('xmlns:navMap').size).to be > 0
115
- nav_point = ncx.at_xpath('xmlns:navMap/xmlns:navPoint')
116
- expect(nav_point['id']).to eq('c2_')
117
- expect(nav_point['playOrder']).to eq('1')
118
-
119
- expect(nav_point.at_xpath('xmlns:navLabel/xmlns:text').content).to eq('test chapter')
120
- nav_point.at_xpath('xmlns:content')['src'] == 'foobar2.html'
121
-
122
- end
123
-
124
- it "should create correct opf" do
125
- opf = Nokogiri::XML.parse(@book.opf_xml).root
126
- expect(opf.name).to eq('package')
127
- expect(opf.namespaces['xmlns']).to eq('http://www.idpf.org/2007/opf')
128
- expect(opf['version']).to eq('3.0')
129
- expect(opf['unique-identifier']).to eq('BookId')
130
- end
131
-
132
- it "should have correct metadata in opf" do
133
- opf = Nokogiri::XML.parse(@book.opf_xml).root
134
- metadata = opf.xpath('xmlns:metadata').first
135
- expect(metadata.at_xpath('dc:language', metadata.namespaces).content).to eq('ja')
136
- #TODO: check metadata
137
- end
138
-
139
- it "should have correct manifest and spine in opf" do
140
- opf = Nokogiri::XML.parse(@book.opf_xml).root
141
-
142
- manifest = opf.at_xpath('xmlns:manifest')
143
- expect(manifest.at_xpath('xmlns:item[@id="c1"]')['href']).to eq('text/foobar.xhtml')
144
- expect(manifest.at_xpath('xmlns:item[@id="c1"]')['media-type']).to eq('application/xhtml+xml')
145
-
146
- spine = opf.at_xpath('xmlns:spine')
147
- expect(spine['toc']).to eq('ncx')
148
- expect(spine.at_xpath('xmlns:itemref')['idref']).to eq('c1')
149
- end
150
-
151
- it "should have correct bindings in opf" do
152
- opf = Nokogiri::XML.parse(@book.opf_xml).root
153
- bindings = opf.at_xpath('xmlns:bindings')
154
- expect(bindings.at_xpath('xmlns:mediaType')['handler']).to eq(@item3_id)
155
- expect(bindings.at_xpath('xmlns:mediaType')['media-type']).to eq('application/x-some-media-type')
156
- end
157
-
158
- it "should have correct cover image id" do
159
- item = @book.add_item("img/img.jpg").cover_image
160
-
161
- opf = Nokogiri::XML.parse(@book.opf_xml).root
162
-
163
- metadata = opf.at_xpath('xmlns:metadata')
164
- meta = metadata.at_xpath("xmlns:meta[@name='cover']")
165
- expect(meta['content']).to eq(item.itemid)
166
- end
167
-
168
- it "should generate correct epub" do
169
- epubname = File.join(File.dirname(__FILE__), 'testepub.epub')
170
- @book.generate_epub(epubname)
171
- epubcheck(epubname)
172
- end
173
- it "should generate correct epub with buffer" do
174
- epubname = File.join(File.dirname(__FILE__), 'testepub_buf.epub')
175
- File.open(epubname, 'wb') {
176
- |io|
177
- io.write @book.generate_epub_stream.string
178
- }
179
- epubcheck(epubname)
180
- end
181
-
182
- it "should generate correct epub2.0" do
183
- epubname = File.join(File.dirname(__FILE__), 'testepub2.epub')
184
- @book = GEPUB::Book.new('OEPBS/package.opf', { 'version' => '2.0'} )
185
- @book.title = 'thetitle'
186
- @book.creator = "theauthor"
187
- @book.contributor = "contributors contributors!"
188
- @book.publisher = "thepublisher"
189
- @book.date = "2010-05-05"
190
- @book.identifier = "http://example.jp/foobar/"
191
- @book.language = 'ja'
192
- item1 = @book.add_item('text/foobar.xhtml',nil, 'c1')
193
- item1.add_content(StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c1</title></head><body><p>the first page</p></body></html>'))
194
- @book.spine.push(item1)
195
- item2 = @book.add_ordered_item('text/barbar.xhtml',
196
- StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c2</title></head><body><p>second page, whith is test chapter.</p></body></html>'),
197
- 'c2')
198
- item2.toc_text 'test chapter'
199
- @book.generate_epub(epubname)
200
- epubcheck(epubname)
201
- end
202
- it 'should generate epub with extra file' do
203
- epubname = File.join(File.dirname(__FILE__), 'testepub3.epub')
204
- @book.add_optional_file('META-INF/foobar.xml', StringIO.new('<foo></foo>'))
205
- @book.generate_epub(epubname)
206
- epubcheck(epubname)
207
- end
208
-
209
- it 'should generate valid EPUB when @toc is empty' do
210
- epubname = File.join(File.dirname(__FILE__), 'testepub4.epub')
211
- @book = GEPUB::Book.new('OEPBS/package.opf', { 'version' => '3.0'} )
212
- @book.title = 'thetitle'
213
- @book.creator = "theauthor"
214
- @book.contributor = "contributors contributors!"
215
- @book.publisher = "thepublisher"
216
- @book.date = "2015-05-05"
217
- @book.identifier = "http://example.jp/foobar/"
218
- @book.language = 'ja'
219
- item1 = @book.add_item('text/foobar.xhtml',nil, 'c1')
220
- item1.add_content(StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c1</title></head><body><p>the first page</p></body></html>'))
221
- @book.spine.push(item1)
222
- item2 = @book.add_ordered_item('text/barbar.xhtml',
223
- StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c2</title></head><body><p>second page, whith is test chapter.</p></body></html>'),
224
- 'c2')
225
- @book.generate_epub(epubname)
226
- epubcheck(epubname)
227
-
228
- end
229
- end