epub-parser 0.1.5 → 0.1.6
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/.travis.yml +1 -0
- data/.yardopts +2 -0
- data/CHANGELOG.markdown +18 -0
- data/README.markdown +40 -11
- data/bin/epub-open +1 -1
- data/bin/epubinfo +14 -14
- data/docs/Home.markdown +3 -2
- data/docs/Item.markdown +3 -3
- data/docs/Navigation.markdown +58 -0
- data/docs/Publication.markdown +54 -0
- data/epub-parser.gemspec +1 -2
- data/lib/epub.rb +5 -83
- data/lib/epub/book.rb +1 -1
- data/lib/epub/book/features.rb +85 -0
- data/lib/epub/constants.rb +2 -0
- data/lib/epub/content_document/navigation.rb +31 -4
- data/lib/epub/content_document/xhtml.rb +1 -1
- data/lib/epub/inspector.rb +9 -7
- data/lib/epub/parser.rb +1 -1
- data/lib/epub/parser/content_document.rb +5 -1
- data/lib/epub/parser/ocf.rb +2 -2
- data/lib/epub/parser/publication.rb +46 -87
- data/lib/epub/parser/version.rb +1 -1
- data/lib/epub/publication/fixed_layout.rb +2 -3
- data/lib/epub/publication/package/guide.rb +19 -14
- data/lib/epub/publication/package/manifest.rb +36 -6
- data/lib/epub/publication/package/metadata.rb +27 -8
- data/lib/epub/publication/package/spine.rb +10 -3
- data/test/fixtures/book/OPS/nav.xhtml +1 -1
- data/test/fixtures/book/OPS//343/203/253/343/203/274/343/203/210/343/203/225/343/202/241/343/202/244/343/203/253.opf +2 -1
- data/test/helper.rb +1 -1
- data/test/test_content_document.rb +41 -2
- data/test/test_epub.rb +0 -7
- data/test/test_parser.rb +4 -4
- data/test/test_parser_content_document.rb +2 -0
- data/test/test_parser_publication.rb +4 -0
- data/test/test_publication.rb +60 -0
- metadata +55 -67
- data/lib/method_decorators/deprecated.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f7f0d3749c5bf1d34ab527c94ac0905a3fa30f
|
4
|
+
data.tar.gz: d88e97de68e8b5d81c27d5921ce2fbe3ebd99e7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e2a88587ff96a480845cee7a99b624b4ee86d373ac659ace2f89b1cd597fed87156c9ffb487ee37b7a87f81a225f0f86b0f47c17d45c4150a70b594638afbdc
|
7
|
+
data.tar.gz: b7634902c0e838a66e4852c62d1356d8cfeb9b9ab84b371a8cba654057fd2c440f8b14e1a92e14311c42670c9557ac3f51e2638d118abdf330de9d750417d7a0
|
data/.travis.yml
CHANGED
data/.yardopts
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
|
+
0.1.6
|
4
|
+
-----
|
5
|
+
* Remove `EPUB.parse` method
|
6
|
+
* Remove `EPUB::Publication::Package::Metadata#to_hash`
|
7
|
+
* Add `EPUB::Publication::Package::Metadata::Identifier` for ad-hoc `scheme` attribute and `#isbn?` method
|
8
|
+
* Remove `MethodDecorators::Deprecated`
|
9
|
+
* Make `EPUB::Parser::OCF::CONTAINER_FILE` and other constants deprecated
|
10
|
+
* Make `EPUB::Publication::Package::Metadata::Link#rel` a `Set`
|
11
|
+
* Add exception class `EPUB::Constants::MediaType::UnsupportedMediaType`
|
12
|
+
* Make `EPUB::Constants::MediaType::UnsupportedError` deprecated. Use `UnsupportedMediatType` instead
|
13
|
+
* Add `EPUB::Publication::Package::Item#cover_image?`
|
14
|
+
* Add `EPUB::Book::Features` module and move methods of `EPUB` module to it(Thanks, [takahashim][]!)
|
15
|
+
* Make including `EPUB` deprecated
|
16
|
+
* Parse `hidden` attribute of `nav` elements
|
17
|
+
* [Experimental]Add `EPUB::ContentDocument::Navigation::Item#traverse`
|
18
|
+
|
19
|
+
[takahashim]: https://github.com/takahashim
|
20
|
+
|
3
21
|
0.1.5
|
4
22
|
-----
|
5
23
|
* Add `ContentDocument::XHTML#title`
|
data/README.markdown
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
EPUB Parser
|
2
2
|
===========
|
3
3
|
[](http://travis-ci.org/KitaitiMakoto/epub-parser)
|
4
|
+
[](https://gemnasium.com/KitaitiMakoto/epub-parser)
|
4
5
|
|
5
6
|
INSTALLATION
|
6
7
|
-------
|
@@ -15,9 +16,12 @@ USAGE
|
|
15
16
|
require 'epub/parser'
|
16
17
|
|
17
18
|
book = EPUB::Parser.parse('book.epub')
|
19
|
+
book.metadata.titles # => Array of EPUB::Publication::Package::Metadata::Title. Main title, subtitle, etc...
|
20
|
+
book.metadata.title # => Title string including all titles
|
21
|
+
book.metadata.creators # => Creators(authors)
|
18
22
|
book.each_page_on_spine do |page|
|
19
23
|
page.media_type # => "application/xhtml+xml"
|
20
|
-
page.entry_name
|
24
|
+
page.entry_name # => "OPS/nav.xhtml" entry name in EPUB package(zip archive)
|
21
25
|
page.read # => raw content document
|
22
26
|
page.content_document.nokogiri # => Nokogiri::XML::Document. The same to Nokogiri.XML(page.read)
|
23
27
|
# do something more
|
@@ -67,7 +71,7 @@ IRB starts. `self` becomes the EPUB book and can access to methods of `EPUB`.
|
|
67
71
|
metadata.creators
|
68
72
|
=> [Author 1, Author2, ...]
|
69
73
|
resources.first.properties
|
70
|
-
=>
|
74
|
+
=> #<Set: {"nav"}> # You know that first resource of this book is nav document
|
71
75
|
nav = resources.first
|
72
76
|
=> ...
|
73
77
|
nav.href
|
@@ -88,18 +92,47 @@ See {file:docs/EpubOpen} for more info.
|
|
88
92
|
|
89
93
|
REQUIREMENTS
|
90
94
|
------------
|
91
|
-
* Ruby 1.9.
|
95
|
+
* Ruby 1.9.3 or later
|
92
96
|
* C compiler to compile Zip/Ruby and Nokogiri
|
93
97
|
|
98
|
+
Related Gems
|
99
|
+
------------
|
100
|
+
* [gepub](https://github.com/skoji/gepub) - a generic EPUB library for Ruby
|
101
|
+
* [epubinfo](https://github.com/chdorner/epubinfo) - Extracts metadata information from EPUB files. Supports EPUB2 and EPUB3 formats.
|
102
|
+
* [ReVIEW](https://github.com/kmuto/review) - ReVIEW is a easy-to-use digital publishing system for books and ebooks.
|
103
|
+
* [epzip](https://github.com/takahashim/epzip) - epzip is EPUB packing tool. It's just only doing 'zip.' :)
|
104
|
+
* [eeepub](https://github.com/jugyo/eeepub) - EeePub is a Ruby ePub generator
|
105
|
+
* [epub-maker](https://github.com/KitaitiMakoto/epub-maker) - This library supports making and editing EPUB books based on this EPUB Parser library
|
106
|
+
|
107
|
+
If you find other gems, please tell me or request a pull request.
|
108
|
+
|
94
109
|
RECENT CHANGES
|
95
110
|
--------------
|
111
|
+
### 0.1.6
|
112
|
+
* Remove `EPUB.parse` method
|
113
|
+
* Remove `EPUB::Publication::Package::Metadata#to_hash`
|
114
|
+
* Add `EPUB::Publication::Package::Metadata::Identifier`
|
115
|
+
* Remove `MethodDecorators::Deprecated`
|
116
|
+
* Make `EPUB::Parser::OCF::CONTAINER_FILE` and other constants deprecated
|
117
|
+
* Make `EPUB::Publication::Package::Metadata::Link#rel` a `Set`
|
118
|
+
* Add exception class `EPUB::Constants::MediaType::UnsupportedMediaType`
|
119
|
+
* Make `EPUB::Constants::MediaType::UnsupportedError` deprecated
|
120
|
+
* Add `EPUB::Publication::Package::Item#find_item_by_relative_iri`
|
121
|
+
* Add `EPUB::Publication::Package::Item#cover_image?`
|
122
|
+
* Add `EPUB::Book::Features` module and move methods of `EPUB` module to it.(Thanks, [takahashim][]!)
|
123
|
+
* Make including `EPUB` deprecated
|
124
|
+
* Parse `hidden` attribute of `nav` elements
|
125
|
+
* [Experimental]Add `EPUB::ContentDocument::Navigation::Item#traverse`
|
126
|
+
|
127
|
+
[takahashim]: https://github.com/takahashim
|
128
|
+
|
96
129
|
### 0.1.5
|
97
130
|
* Add `ContentDocument::XHTML#title`
|
98
131
|
* Add `Manifest::Item#xhtml?`
|
99
132
|
* Add `--words` and `--char` options to `epubinfo` command
|
100
133
|
* API change: `OCF::Container::Rootfile#full_path` became Addressable::URI object rather than `String`
|
101
134
|
* Add `ContentDocument::XHTML#rexml` and `#nokogiri`
|
102
|
-
* Inspect more
|
135
|
+
* Inspect more readably
|
103
136
|
|
104
137
|
### 0.1.4
|
105
138
|
* [Fixed-Layout Documents][fixed-layout] support
|
@@ -109,17 +142,12 @@ RECENT CHANGES
|
|
109
142
|
|
110
143
|
[fixed-layout]: http://www.idpf.org/epub/fxl/
|
111
144
|
|
112
|
-
### 0.1.3
|
113
|
-
* Add a command-line tool `epub-open`
|
114
|
-
* Add support for XHTML Navigation Document
|
115
|
-
* Make `EPUB::Publication::Package::Metadata#to_hash` obsolete. Use `#to_h` instead
|
116
|
-
* Add utility methods `EPUB#description`, `EPUB#date` and `EPUB#unique_identifier`
|
117
|
-
|
118
145
|
See {file:CHANGELOG.markdown} for older changelogs and details.
|
119
146
|
|
120
147
|
TODOS
|
121
148
|
-----
|
122
|
-
*
|
149
|
+
* EPUB 3.0.1
|
150
|
+
* Multiple rootfiles
|
123
151
|
* Help features for `epub-open` tool
|
124
152
|
* Vocabulary Association Mechanisms
|
125
153
|
* Implementing navigation document and so on
|
@@ -133,6 +161,7 @@ TODOS
|
|
133
161
|
|
134
162
|
DONE
|
135
163
|
----
|
164
|
+
* Simple inspect for `epub-open` tool
|
136
165
|
* Using zip library instead of `unzip` command, which has security issue
|
137
166
|
* Modify methods around fallback to see `bindings` element in the package
|
138
167
|
* Content Document(only for Navigation Documents)
|
data/bin/epub-open
CHANGED
data/bin/epubinfo
CHANGED
@@ -11,9 +11,7 @@ Usage: epubinfo [options] EPUBFILE
|
|
11
11
|
EOB
|
12
12
|
opt.version = EPUB::Parser::VERSION
|
13
13
|
formats = [:line, :json, :yaml]
|
14
|
-
|
15
|
-
nl_last = nl_formats.pop
|
16
|
-
opt.on '-f', '--format=FORMAT', formats, "format of output(#{nl_formats.join(', ')} or #{nl_last}), defaults to line(for console)" do |format|
|
14
|
+
opt.on '-f', '--format=FORMAT', formats, "format of output(#{formats[0..-2].join(', ')} or #{formats.last}), defaults to line(for console)" do |format|
|
17
15
|
options[:format] = format
|
18
16
|
end
|
19
17
|
opt.on '--words', 'count words of content documents' do
|
@@ -38,21 +36,23 @@ data.merge!(book.metadata.to_h)
|
|
38
36
|
data['Unique identifier'] = [book.metadata.unique_identifier]
|
39
37
|
data['EPUB Version'] = [book.package.version]
|
40
38
|
counts = {:chars => 0, :words => 0}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
if options[:words] or options[:chars]
|
40
|
+
book.resources.select(&:xhtml?).each do |xhtml|
|
41
|
+
begin
|
42
|
+
doc = xhtml.content_document.nokogiri
|
43
|
+
body = doc.search('body').first
|
44
|
+
content = body.content
|
45
|
+
if body
|
46
|
+
counts[:words] += content.scan(/\S+/).length
|
47
|
+
counts[:chars] += content.gsub(/\r|\n/, '').length
|
48
|
+
end
|
49
|
+
rescue => error
|
50
|
+
warn "#{xhtml.href}: #{error}"
|
49
51
|
end
|
50
|
-
rescue => error
|
51
|
-
warn "#{xhtml.href}: #{error}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
data['Words'] = [counts[:words]] if options[:words]
|
55
|
-
data['
|
55
|
+
data['Characters'] = [counts[:chars]] if options[:chars]
|
56
56
|
if options[:format] == :line
|
57
57
|
key_width = data.keys.map {|k| k.length}.max + 3
|
58
58
|
data.each_pair do |k, v|
|
data/docs/Home.markdown
CHANGED
@@ -61,7 +61,7 @@ By the way, although `book` above is a {EPUB::Book} object, all features are pro
|
|
61
61
|
require 'epub'
|
62
62
|
|
63
63
|
class YourBook < ActiveRecord::Base
|
64
|
-
include EPUB
|
64
|
+
include EPUB::Book::Features
|
65
65
|
end
|
66
66
|
|
67
67
|
book = EPUB::Parser.parse(
|
@@ -92,13 +92,14 @@ You are also able to find YourBook object for the first:
|
|
92
92
|
|
93
93
|
More documentations are avaiable in:
|
94
94
|
|
95
|
+
* {file:docs/Publication.markdown}
|
95
96
|
* {file:docs/Item.markdown}
|
96
97
|
* {file:docs/FixedLayout.markdown}
|
97
98
|
|
98
99
|
Requirements
|
99
100
|
------------
|
100
101
|
|
101
|
-
*
|
102
|
+
* Ruby 1.9.3 or later
|
102
103
|
* C compiler to compile Zip/Ruby and Nokogiri
|
103
104
|
|
104
105
|
Note
|
data/docs/Item.markdown
CHANGED
@@ -66,15 +66,15 @@ Also you can use {EPUB::Publication::Package::Manifest::Item#use_fallback_chain
|
|
66
66
|
|
67
67
|
If item's media type is, for instance, 'image/x-eps', the fallback is used.
|
68
68
|
If the fallback item's media type is 'image/png', `png` variable means the item, if not, "fallback of fallback" will be checked.
|
69
|
-
Finally you can use the item you want, or {EPUB::Constants::MediaType::
|
69
|
+
Finally you can use the item you want, or {EPUB::Constants::MediaType::UnsupportedMediaType EPUB::MediaType::UnsupportedMediaType} exception will be raised(if no item you can accept found).
|
70
70
|
Therefore, you should `rescue` clause:
|
71
71
|
|
72
72
|
# :unsupported option can also be used
|
73
|
-
# fallback chain will be followed until EPUB's Core Media Types found or
|
73
|
+
# fallback chain will be followed until EPUB's Core Media Types found or UnsupportedMediaType raised
|
74
74
|
begin
|
75
75
|
item.use_fallback_chain :unsupported => 'application/pdf' do |page|
|
76
76
|
# do something with item with core media type
|
77
77
|
end
|
78
|
-
rescue EPUB::MediaType::
|
78
|
+
rescue EPUB::MediaType::UnsupportedMediaType => evar
|
79
79
|
# error handling
|
80
80
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
{file:docs/Home.markdown} > **{file:docs/Navigation.markdown}**
|
2
|
+
|
3
|
+
Traversing
|
4
|
+
==========
|
5
|
+
|
6
|
+
Example to show tree of Table of Contents:
|
7
|
+
|
8
|
+
nav = book.manifest.navs.first.content_document # => EPUB::ContentDocument::Navigation
|
9
|
+
toc = nav.toc # => EPUB::ContentDocument::Navigation::Navigation
|
10
|
+
toc_tree = ''
|
11
|
+
toc.traverse do |item, depth|
|
12
|
+
item # => EPUB::ContentDocument::Navigation::Item
|
13
|
+
depth # => Integer
|
14
|
+
toc_tree << "#{' ' * depth * 2}#{item.text}\n"
|
15
|
+
end
|
16
|
+
puts toc_tree
|
17
|
+
THE CONTENTS
|
18
|
+
SECTION IV FAIRY STORIES—MODERN FANTASTIC TALES
|
19
|
+
BIBLIOGRAPHY
|
20
|
+
INTRODUCTORY
|
21
|
+
Abram S. Isaacs
|
22
|
+
190 A FOUR-LEAVED CLOVER
|
23
|
+
|
24
|
+
I. The Rabbi and the Diadem
|
25
|
+
|
26
|
+
|
27
|
+
II. Friendship
|
28
|
+
|
29
|
+
|
30
|
+
III. True Charity
|
31
|
+
|
32
|
+
|
33
|
+
IV. An Eastern Garden
|
34
|
+
|
35
|
+
Samuel Taylor Coleridge
|
36
|
+
191 THE LORD HELPETH MAN AND BEAST
|
37
|
+
Hans Christian Andersen
|
38
|
+
192 THE REAL PRINCESS
|
39
|
+
193 THE EMPEROR'S NEW CLOTHES
|
40
|
+
194 THE NIGHTINGALE
|
41
|
+
195 THE FIR TREE
|
42
|
+
196 THE TINDER-BOX
|
43
|
+
197 THE HARDY TIN SOLDIER
|
44
|
+
198 THE UGLY DUCKLING
|
45
|
+
Frances Browne
|
46
|
+
199 THE STORY OF FAIRYFOOT
|
47
|
+
Oscar Wilde
|
48
|
+
200 THE HAPPY PRINCE
|
49
|
+
Raymond MacDonald Alden
|
50
|
+
201 THE KNIGHTS OF THE SILVER SHIELD
|
51
|
+
Jean Ingelow
|
52
|
+
202 THE PRINCE'S DREAM
|
53
|
+
Frank R. Stockton
|
54
|
+
203 OLD PIPES AND THE DRYAD
|
55
|
+
John Ruskin
|
56
|
+
204 THE KING OF THE GOLDEN RIVER OR THE BLACK BROTHERS
|
57
|
+
|
58
|
+
**NOTE**: This API is not stable.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{file:docs/Home.markdown} > **{file:docs/Publication.markdow}**
|
2
|
+
|
3
|
+
Publication(Information about EPUB book)
|
4
|
+
========================================
|
5
|
+
|
6
|
+
EPUB Publications is information about EPUB books.
|
7
|
+
|
8
|
+
EPUB Parser represents it as {EPUB::Publication} module and classes under the namespace and you can access them such like `EPUB::Parser.parse("path/to/book.epub").package`
|
9
|
+
|
10
|
+
Let
|
11
|
+
|
12
|
+
book = EPUB::Parser.parse("path/to/book.epub")
|
13
|
+
|
14
|
+
for continuing.
|
15
|
+
|
16
|
+
Five Models
|
17
|
+
-----------
|
18
|
+
|
19
|
+
`book.package` is a package document, a root of information tree about the book, and it has attributes to access five major models of the publication; {EPUB::Publication::Package::Metadata Metadata}, {EPUB::Publication::Package::Manifest Manifest}, {EPUB::Publication::Package::Spine Spine}, {EPUB::Publication::Package::Guide Guide} and {EPUB::Publication::Package::Bindings Bindings}.
|
20
|
+
|
21
|
+
Each of them has information the book in the way its own.
|
22
|
+
|
23
|
+
Metadata
|
24
|
+
--------
|
25
|
+
|
26
|
+
{EPUB::Publication::Package::Metadata Metadata} is literally metadata of the book, including identifiers, titles, languages, links and so on.
|
27
|
+
|
28
|
+
You can access them by:
|
29
|
+
|
30
|
+
md = book.package.metadata # => EPUB::Publication::Package::Metadata
|
31
|
+
md.titles # => [#<EPUB::Publication::Package::Metadata::Title...>, #<EPUB::Publication::Package::Metadata::Title...>, ...]
|
32
|
+
# ...
|
33
|
+
|
34
|
+
Manifest
|
35
|
+
--------
|
36
|
+
|
37
|
+
Spine
|
38
|
+
-----
|
39
|
+
|
40
|
+
Guide
|
41
|
+
-----
|
42
|
+
|
43
|
+
Bindings
|
44
|
+
--------
|
45
|
+
|
46
|
+
Package
|
47
|
+
-------
|
48
|
+
|
49
|
+
References
|
50
|
+
----------
|
51
|
+
|
52
|
+
* [EPUB Publications 3.0][publications] on IDPF site
|
53
|
+
|
54
|
+
[publications]: http://www.idpf.org/epub/30/spec/epub30-publications.html
|
data/epub-parser.gemspec
CHANGED
@@ -45,6 +45,5 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.add_runtime_dependency 'enumerabler'
|
46
46
|
s.add_runtime_dependency 'zipruby'
|
47
47
|
s.add_runtime_dependency 'nokogiri', '~> 1.6'
|
48
|
-
s.add_runtime_dependency 'addressable'
|
49
|
-
s.add_runtime_dependency 'method_decorators', '0.9.3'
|
48
|
+
s.add_runtime_dependency 'addressable', '>= 2.3.5'
|
50
49
|
end
|
data/lib/epub.rb
CHANGED
@@ -1,92 +1,14 @@
|
|
1
|
-
require 'method_decorators/deprecated'
|
2
1
|
require 'epub/inspector'
|
3
2
|
require 'epub/ocf'
|
4
3
|
require 'epub/publication'
|
5
4
|
require 'epub/content_document'
|
5
|
+
require 'epub/book/features'
|
6
6
|
|
7
7
|
module EPUB
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
define_method "#{mod}=" do |obj|
|
13
|
-
instance_variable_set "@#{mod}", obj
|
14
|
-
obj.book = self
|
8
|
+
class << self
|
9
|
+
def included(base)
|
10
|
+
warn 'Including EPUB module is deprecated. Include EPUB::Book::Features instead.'
|
11
|
+
base.__send__ :include, EPUB::Book::Features
|
15
12
|
end
|
16
13
|
end
|
17
|
-
|
18
|
-
def parse(file, options = {})
|
19
|
-
@epub_file = file
|
20
|
-
options = options.merge({:book => self})
|
21
|
-
Parser.parse(file, options)
|
22
|
-
end
|
23
|
-
|
24
|
-
Publication::Package::CONTENT_MODELS.each do |model|
|
25
|
-
define_method model do
|
26
|
-
package.__send__(model)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
%w[ title main_title subtitle short_title collection_title edition_title extended_title description date unique_identifier ].each do |met|
|
31
|
-
define_method met do
|
32
|
-
metadata.__send__(met)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
%w[nav].each do |met|
|
37
|
-
define_method met do
|
38
|
-
manifest.__send__ met
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# @overload each_page_on_spine(&blk)
|
43
|
-
# iterate over items in order of spine when block given
|
44
|
-
# @yieldparam item [Publication::Package::Manifest::Item]
|
45
|
-
# @overload each_page_on_spine
|
46
|
-
# @return [Enumerator] which iterates over {Publication::Package::Manifest::Item}s in order of spine when block not given
|
47
|
-
def each_page_on_spine(&blk)
|
48
|
-
enum = package.spine.items
|
49
|
-
if block_given?
|
50
|
-
enum.each &blk
|
51
|
-
else
|
52
|
-
enum
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def each_page_on_toc(&blk)
|
57
|
-
raise NotImplementedError
|
58
|
-
end
|
59
|
-
|
60
|
-
# @overload each_content(&blk)
|
61
|
-
# iterate all items over when block given
|
62
|
-
# @yieldparam item [Publication::Package::Manifest::Item]
|
63
|
-
# @overload each_content
|
64
|
-
# @return [Enumerator] which iterates over all {Publication::Package::Manifest::Item}s in EPUB package when block not given
|
65
|
-
def each_content(&blk)
|
66
|
-
enum = manifest.items
|
67
|
-
if block_given?
|
68
|
-
enum.each &blk
|
69
|
-
else
|
70
|
-
enum.to_enum
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def other_navigation
|
75
|
-
raise NotImplementedError
|
76
|
-
end
|
77
|
-
|
78
|
-
# @return [Array<Publication::Package::Manifest::Item>] All {Publication::Package::Manifest::Item}s in EPUB package
|
79
|
-
def resources
|
80
|
-
manifest.items
|
81
|
-
end
|
82
|
-
|
83
|
-
# Syntax sugar
|
84
|
-
def rootfile_path
|
85
|
-
ocf.container.rootfile.full_path.to_s
|
86
|
-
end
|
87
|
-
|
88
|
-
# Syntax sugar
|
89
|
-
def cover_image
|
90
|
-
manifest.cover_image
|
91
|
-
end
|
92
14
|
end
|