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 +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.markdown +5 -0
- data/README.markdown +4 -0
- data/docs/{ExtractContentsFromWeb.markdown → AggregateContentsFromWeb.markdown} +6 -6
- data/docs/Home.markdown +1 -1
- data/examples/{extract-contents-from-web.rb → aggregate-contents-from-web.rb} +0 -0
- data/lib/epub/parser/version.rb +1 -1
- data/lib/epub/publication/package/manifest.rb +4 -1
- data/test/test_publication.rb +15 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5064ac374ce37d6547455f140004939cc0fb6beb
|
4
|
+
data.tar.gz: 210f062f461f4ae37f84709953e1f1f029ddba44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 726184ddb137eaceed9774eb81bcf3ea36b9896495b247a115dbc89d12f628af2ccc7d0f8abb87baec30e8fa44c0bcd4f40b0175297f5e21922d7f3696c58628
|
7
|
+
data.tar.gz: 0d5c3e0d8a4afc8410088ef77daeb59d28f37caf1a349ddfd4eeeb693d0364dce61a19e3cc69c6d79032f51fc3b24c8b20fb5303f389aa6e6f975111edf983d9
|
data/.yardopts
CHANGED
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -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/
|
1
|
+
{file:docs/Home.markdown} > **{file:docs/AggregateContentsFromWeb.markdown}**
|
2
2
|
|
3
|
-
|
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
|
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/
|
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/
|
26
|
+
{include:file:examples/aggregate-contents-from-web.rb}
|
27
27
|
|
28
28
|
Execution:
|
29
29
|
|
30
|
-
$ ruby examples/
|
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
|
data/docs/Home.markdown
CHANGED
@@ -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/
|
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
|
|
File without changes
|
data/lib/epub/parser/version.rb
CHANGED
@@ -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.
|
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
|
data/test/test_publication.rb
CHANGED
@@ -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.
|
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-
|
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/
|
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
|