epub-parser 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d7e6e2104c4c77f435607cc2b05936b405dad9e18d29d316c98633f9e7df35e
4
- data.tar.gz: 03b8c36a39101d777fa0e6026436898f4136df2bd4acfa83f173da7baa750ca1
3
+ metadata.gz: ee9d5ae3802a16461fd85224ecf47f4b2eafc6181e0c84761a9108a61b5890f1
4
+ data.tar.gz: 24d6b8164c849969121e9b4975e366a1683e7367096214d5c78ec6f3676e12f0
5
5
  SHA512:
6
- metadata.gz: 2f3d5ce0f4d7847cb0e171dfc7741bb0b1899e9e4300746b8e447f0ba2cc5be2eb6700ace854aac6b39b7cddab069e4f83d14f1a930dcb0becbcb5b32c955105
7
- data.tar.gz: 96a793271073777e2ae68666018d0e627b7b59edc108a8ed08c085bd0d09cfe4a808f5cc787bdbc8dba28d978e29af92d2e2bd222b2b049d6b4a28b1747f10dc
6
+ metadata.gz: 45c6d1b877698ab09620ecd079c805fd873fde3e77210e76a251bf416390fd1d17fcb5ea4246f55d4616640952e7db00dca5f3635f6829d429851c24cf6ecec2
7
+ data.tar.gz: 97e70f781221ef0036761d84fd1ae718f543588a04ce78b5209e068604c9d2b6c33ce68c57f51499420e65710cf260c86cb8016c5ee8674c21db56c348af8ad6
@@ -1,6 +1,10 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 0.3.5
5
+ -----
6
+ * [BUG FIX]Fix a bug that {EPUB::ContentDocument::Navigation::Item#item} is `nil` when `href` includes double dots(`..`)(Thanks [aelkiss][]!)
7
+
4
8
  0.3.4
5
9
  -----
6
10
 
@@ -159,6 +159,10 @@ If you find other gems, please tell me or request a pull request.
159
159
  RECENT CHANGES
160
160
  --------------
161
161
 
162
+ ### 0.3.5
163
+
164
+ * [BUG FIX]Fix a bug that {EPUB::ContentDocument::Navigation::Item#item} is `nil` when `href` includes double dots(`..`)(Thanks [aelkiss][]!)
165
+
162
166
  ### 0.3.4
163
167
 
164
168
  * Add {EPUB::Publication::Package#full_path} and {EPUB::Publication::Package#rootfile}
@@ -82,9 +82,13 @@ module EPUB
82
82
  item.text = extract_attribute(a_or_span, 'title').to_s if item.text.nil? || item.text.empty?
83
83
  end
84
84
  item.href = extract_attribute(a_or_span, 'href')
85
- item.item = @item.manifest.items.find {|it|
86
- it.full_path == @item.full_path + item.href.request_uri
87
- }
85
+ # TODO: too dirty and with potential performance issue
86
+ full_path = EPUB::Publication::Package::Manifest::Item::DUMMY_ROOT_IRI + @item.manifest.package.full_path + @item.href + item.href
87
+ full_path.scheme = nil
88
+ full_path.host = nil
89
+ full_path.path = full_path.path[1..-1]
90
+ full_path.fragment = nil
91
+ item.item = @item.manifest.items.find {|it| it.full_path == full_path}
88
92
  end
89
93
  item.items = element.xpath('./xhtml:ol[1]/xhtml:li', EPUB::NAMESPACES).map {|li| parse_navigation_item(li)}
90
94
 
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  class Parser
3
- VERSION = "0.3.4"
3
+ VERSION = "0.3.5"
4
4
  end
5
5
  end
@@ -3,5 +3,6 @@
3
3
  <rootfiles>
4
4
  <rootfile full-path="OPS/ルートファイル.opf" media-type="application/oebps-package+xml" />
5
5
  <rootfile full-path="nested/dir/content.opf" media-type="application/oebps-package+xml" />
6
+ <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml" />
6
7
  </rootfiles>
7
8
  </container>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html>
3
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <title>Chapter 1</title>
7
+ </head>
8
+ <body><div class="chapter-heading"> <h1 class="chapter-number">1</h1> <h1 class="chapter-title">Chapter 1</h1> </div> <div class="chapter-content"><p class="no-indent">This is the first sentence. This is the next sentence. This is all for Chapter 1.</p> <p><br/></p> </div> </body></html>
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <package xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:media="http://www.idpf.org/epub/vocab/overlays/#" version="3.0" unique-identifier="BookId" xml:lang="en" prefix="ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/">
3
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
4
+ <dc:identifier id="BookId">af6e04ec-ca74-4951-a5cd-f0572885a7f9</dc:identifier>
5
+ <meta refines="#BookId" property="identifier-type" scheme="onix:codelist5">22</meta>
6
+ <meta property="dcterms:identifier" id="meta-identifier">BookId</meta>
7
+ <dc:title>Test</dc:title>
8
+ <meta property="dcterms:title" id="meta-title">Test</meta>
9
+ <dc:language>en</dc:language>
10
+ <meta property="dcterms:language" id="meta-language">en</meta>
11
+ <meta property="dcterms:modified">2017-12-05T20:55:41Z</meta>
12
+ <dc:creator id="creator">anonymous</dc:creator>
13
+ <meta refines="#creator" property="file-as">anonymous</meta>
14
+ <meta property="dcterms:publisher">anonymous</meta>
15
+ <dc:publisher>anonymous</dc:publisher>
16
+ <meta property="dcterms:date">2017-12-5</meta>
17
+ <dc:date>2017-12-5</dc:date>
18
+ <meta property="dcterms:rights">see MIT-LICENSE</meta>
19
+ <dc:rights>see MIT-LICENSE</dc:rights>
20
+ <meta name="cover" content="image_cover"/>
21
+ </metadata>
22
+ <manifest>
23
+ <item id="toc" href="../OEBPS/toc.xhtml" media-type="application/xhtml+xml" properties="nav"/>
24
+ <item id="content_2_chapter-1" href="../OEBPS/2_chapter-1.xhtml" media-type="application/xhtml+xml"/>
25
+ </manifest>
26
+ <spine toc="ncx">
27
+ <itemref idref="toc"/>
28
+ <itemref idref="content_2_chapter-1"/>
29
+ </spine>
30
+ </package>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
3
+ <head>
4
+ <title>Test</title>
5
+ <meta charset="UTF-8"/>
6
+ </head>
7
+ <body>
8
+ <h1 class="chapter-title">Contents</h1>
9
+ <nav id="toc" epub:type="toc">
10
+ <ol class="toc">
11
+ <li class="toc-chapter">
12
+ <a href="../OEBPS/2_chapter-1.xhtml" epub:type="bodymatter">Chapter 1</a>
13
+ <ol class="toc">
14
+
15
+ </ol>
16
+ </li>
17
+ </ol>
18
+ </nav>
19
+ </body>
20
+ </html>
@@ -125,5 +125,12 @@ class TestContentDocument < Test::Unit::TestCase
125
125
 
126
126
  assert_equal "nested/dir/text/2_chapter-1.xhtml", package.manifest.nav.content_document.navigation.items.first.item.full_path.path
127
127
  end
128
+
129
+ def test_navigation_with_double_dots
130
+ book = EPUB::Parser.parse("test/fixtures/book.epub")
131
+ package = book.packages[2]
132
+
133
+ assert_equal "OEBPS/2_chapter-1.xhtml", package.manifest.nav.content_document.navigation.items.first.item.full_path.to_s
134
+ end
128
135
  end
129
136
  end
@@ -17,7 +17,7 @@ class TestParserOCF < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_parsed_container_has_two_rootfiles
20
- assert_equal 2, @parser.parse_container(@container_xml).rootfiles.length
20
+ assert_equal 3, @parser.parse_container(@container_xml).rootfiles.length
21
21
  end
22
22
 
23
23
  def test_parse_container_can_find_primary_rootfile
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require_relative 'helper'
2
3
  require 'epub/publication'
3
4
 
@@ -301,8 +302,10 @@ class TestPublication < Test::Unit::TestCase
301
302
  item = EPUB::Publication::Package::Manifest::Item.new
302
303
  item.media_type = 'application/xhtml+xml'
303
304
  item.properties = %w[nav]
305
+ item.href = "nav.xhtml"
304
306
  stub(item).read {File.read(File.expand_path('../fixtures/book/OPS/nav.xhtml', __FILE__))}
305
- stub(item).manifest.stub!.items {[]}
307
+ stub(item.manifest).items {[]}
308
+ stub(item.manifest).package.stub!.full_path {Addressable::URI.parse("OPS/ルートファイル.opf")}
306
309
 
307
310
  assert_instance_of EPUB::ContentDocument::Navigation, item.content_document
308
311
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
@@ -360,6 +360,9 @@ files:
360
360
  - man/epubinfo.1.ronn
361
361
  - test/fixtures/book/META-INF/container.xml
362
362
  - test/fixtures/book/META-INF/metadata.xml
363
+ - test/fixtures/book/OEBPS/2_chapter-1.xhtml
364
+ - test/fixtures/book/OEBPS/content.opf
365
+ - test/fixtures/book/OEBPS/toc.xhtml
363
366
  - test/fixtures/book/OPS/%E6%97%A5%E6%9C%AC%E8%AA%9E.xhtml
364
367
  - test/fixtures/book/OPS/case-sensitive.xhtml
365
368
  - test/fixtures/book/OPS/containing space.xhtml