epub-parser 0.2.1 → 0.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cad6963a6325a736ef8f5006e9b0a037e0718070
4
- data.tar.gz: d1ef1c2fbb7dd77791524c39cab200eecee063ad
3
+ metadata.gz: 5064ac374ce37d6547455f140004939cc0fb6beb
4
+ data.tar.gz: 210f062f461f4ae37f84709953e1f1f029ddba44
5
5
  SHA512:
6
- metadata.gz: 05c2b6004493b0f41d6b3ba7e9f32f6aed5c171f34f9477d39d7a10493d2dce2e711c49816fc26784ff25deb7a966c9b297cc1e1a0d12398920bccf17aacc2cc
7
- data.tar.gz: b4d737ae179399f3f159561d103a5b52bd2dc9c7c17e5fed8115cb1b1a0dca296ba5d60c8840f72b425d3d222503de6dd07fc3aceac1adde72ca744a7d3af3d4
6
+ metadata.gz: 726184ddb137eaceed9774eb81bcf3ea36b9896495b247a115dbc89d12f628af2ccc7d0f8abb87baec30e8fa44c0bcd4f40b0175297f5e21922d7f3696c58628
7
+ data.tar.gz: 0d5c3e0d8a4afc8410088ef77daeb59d28f37caf1a349ddfd4eeeb693d0364dce61a19e3cc69c6d79032f51fc3b24c8b20fb5303f389aa6e6f975111edf983d9
data/.yardopts CHANGED
@@ -10,4 +10,4 @@ docs/EpubOpen.markdown
10
10
  docs/Navigation.markdown
11
11
  docs/Searcher.markdown
12
12
  docs/UnpackedArchive.markdown
13
- docs/ExtractContentsFromWeb.markdown
13
+ docs/AggregateContentsFromWeb.markdown
@@ -1,6 +1,11 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 0.2.2
5
+ -----
6
+
7
+ * [BUGFIX]Item#entry_name returns normalized IRI
8
+
4
9
  0.2.1
5
10
  -----
6
11
 
@@ -150,6 +150,10 @@ If you find other gems, please tell me or request a pull request.
150
150
  RECENT CHANGES
151
151
  --------------
152
152
 
153
+ ### 0.2.2
154
+
155
+ * [BUGFIX]Item#entry_name returns normalized IRI
156
+
153
157
  ### 0.2.1
154
158
 
155
159
  * Remove deprecated `EPUB::Constants::MediaType::UnsupportedError`. Use `UnsupportedMediatType` instead.
@@ -1,9 +1,9 @@
1
- {file:docs/Home.markdown} > **{file:docs/ExtractContentsFromWeb.markdown}**
1
+ {file:docs/Home.markdown} > **{file:docs/AggregateContentsFromWeb.markdown}**
2
2
 
3
- Extract Contents From the Web
3
+ Aggregate Contents From the Web
4
4
  =============================
5
5
 
6
- From version 0.2.1, EPUB Parser can parse unpacked(unzipped) EPUB files on the web and extract contents in the books.
6
+ From version 0.2.1, EPUB Parser can parse unpacked(unzipped) EPUB files on the web and aggregate contents in the books.
7
7
 
8
8
  Let's get contents of pretty cmmic Page Blanche from IDPF's GitHub repository: https://github.com/IDPF/epub3-samples/tree/master/30/page-blanche
9
9
 
@@ -21,13 +21,13 @@ EPUB Parser can treat the URI as EPUB book file path and parse contents from it
21
21
  The trick is to set {EPUB::OCF::PhysicalContainer.adapter container adapter} to {EPUB::OCF::PhysicalContainer::UnpackedURI :UnpackedURI}. It makes it possible to parse EPUB book from the web.
22
22
  Now we can play with EPUB books as always!
23
23
 
24
- As an example, I will show you a script to download all the files of specified EPUB book to local directory(source code is available in repository's examples/extract-contents-from-web.rb).
24
+ As an example, I will show you a script to download all the files of specified EPUB book to local directory(source code is available in repository's examples/aggregate-contents-from-web.rb).
25
25
 
26
- {include:file:examples/extract-contents-from-web.rb}
26
+ {include:file:examples/aggregate-contents-from-web.rb}
27
27
 
28
28
  Execution:
29
29
 
30
- $ ruby examples/extract-contents-from-web.rb https://raw.githubusercontent.com/IDPF/epub3-samples/master/30/page-blanche/
30
+ $ ruby examples/aggregate-contents-from-web.rb https://raw.githubusercontent.com/IDPF/epub3-samples/master/30/page-blanche/
31
31
  Started downloading EPUB contents...
32
32
  from: https://raw.githubusercontent.com/IDPF/epub3-samples/master/30/page-blanche/
33
33
  to: /tmp/epub-parser20150703-13148-ghdtfq
@@ -101,7 +101,7 @@ More documentations are avaiable in:
101
101
  * {file:docs/Navigation.markdown}
102
102
  * {file:docs/Searcher.markdown}
103
103
  * {file:docs/UnpackedArchive.markdown}
104
- * {file:docs/ExtractContentsFromWeb.markdown}
104
+ * {file:docs/AggregateContentsFromWeb.markdown}
105
105
 
106
106
  If you installed EPUB Parser via gem command, you can also generate documentaiton by your own([rubygems-yardoc][] gem is needed):
107
107
 
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  class Parser
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -100,8 +100,11 @@ module EPUB
100
100
 
101
101
  # full path in archive
102
102
  def entry_name
103
+ dummy_root_iri = Addressable::URI.parse('http://example.net/') # FIXME: Use constant
103
104
  rootfile = manifest.package.book.ocf.container.rootfile.full_path
104
- Addressable::URI.unescape(rootfile + href.normalize.request_uri)
105
+ en = Addressable::URI.unencode((dummy_root_iri + rootfile + href).normalize.request_uri)
106
+ en.slice!(0) if en.start_with? '/'
107
+ en
105
108
  end
106
109
 
107
110
  def read
@@ -302,6 +302,21 @@ class TestPublication < Test::Unit::TestCase
302
302
  item = epub.package.manifest[id]
303
303
  assert_equal encoding, item.read.encoding
304
304
  end
305
+
306
+ def test_entry_name_returns_normalized_iri
307
+ item = Package::Manifest::Item.new
308
+ item.href = Addressable::URI.parse('../style.css')
309
+ obj = Object.new
310
+ stub(item).manifest {obj}
311
+ stub(obj).package {obj}
312
+ stub(obj).book {obj}
313
+ stub(obj).ocf {obj}
314
+ stub(obj).container {obj}
315
+ stub(obj).rootfile {obj}
316
+ stub(obj).full_path {Addressable::URI.parse('OPS/contents.opf')}
317
+
318
+ assert_equal 'style.css', item.entry_name
319
+ end
305
320
  end
306
321
  end
307
322
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -283,9 +283,9 @@ files:
283
283
  - Rakefile
284
284
  - bin/epub-open
285
285
  - bin/epubinfo
286
+ - docs/AggregateContentsFromWeb.markdown
286
287
  - docs/EpubOpen.markdown
287
288
  - docs/Epubinfo.markdown
288
- - docs/ExtractContentsFromWeb.markdown
289
289
  - docs/FixedLayout.markdown
290
290
  - docs/Home.markdown
291
291
  - docs/Item.markdown
@@ -294,7 +294,7 @@ files:
294
294
  - docs/Searcher.markdown
295
295
  - docs/UnpackedArchive.markdown
296
296
  - epub-parser.gemspec
297
- - examples/extract-contents-from-web.rb
297
+ - examples/aggregate-contents-from-web.rb
298
298
  - features/epubinfo.feature
299
299
  - features/step_definitions/epubinfo_steps.rb
300
300
  - features/support/env.rb