epubinfo_with_toc 0.4.5 → 0.5.0
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,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzRhZWZjNDMwYzM0ZGI0MTY3YTk2ZjFlZjNjYjIzMmZhNGVlZGVmNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODllZDgzNGVhNDVlNTAxNjhjNWQyMjllNzViMmQ4ODBlODVkYmRlNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTdmODFlMmUwODJkNDJkYjg0MWJhNmYwODA1ZjFiOTMzYWE5MDYzZTVlNjMx
|
10
|
+
ZjFlYzM2YjkzZTc0OGE1ODU0MTgxZjU5YWQ0YWE2OGZmMDdlZDIwMTlkNjJm
|
11
|
+
Y2I0MzVhMzk5NGE5OWJmYmQ0OWZlOTI4MGMzNTkzZGZmYjFlYzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTU4MzMyNDY2NmYyZWFhYzY3Y2NiYzBhYWI2MGIzZGExNjZkYjVmMjc0OWFl
|
14
|
+
MTVlM2FiNmI3NjBkNTE4YWI2ODI1OTYzODQyODNhYzZmMmFjMDdkODZlZDNj
|
15
|
+
NmZmMGRhZTNkOTYyOWI2Yzk3ZWVkNmQzOTFmNTE4NzZkZTE4ZGY=
|
data/README.md
CHANGED
@@ -50,16 +50,16 @@ pages1_4 = book.table_of_contents.resources[0..3]
|
|
50
50
|
|
51
51
|
### Querying for a list of specific resources
|
52
52
|
```ruby
|
53
|
-
images = book.table_of_contents.images
|
54
|
-
fonts = book.table_of_contents.fonts
|
55
|
-
videos = book.table_of_contents.videos
|
56
|
-
js = book.table_of_contents.javascripts
|
57
|
-
css = book.table_of_contents.css
|
53
|
+
images = book.table_of_contents.resources.images
|
54
|
+
fonts = book.table_of_contents.resources.fonts
|
55
|
+
videos = book.table_of_contents.resources.videos
|
56
|
+
js = book.table_of_contents.resources.javascripts
|
57
|
+
css = book.table_of_contents.resources.css
|
58
58
|
```
|
59
59
|
|
60
60
|
### Get a list of all the different mime-types used
|
61
61
|
```ruby
|
62
|
-
types = book.table_of_contents.types
|
62
|
+
types = book.table_of_contents.resources.types
|
63
63
|
```
|
64
64
|
|
65
65
|
### print SPINE text
|
@@ -71,6 +71,9 @@ end
|
|
71
71
|
```
|
72
72
|
|
73
73
|
## Changelog
|
74
|
+
**0.5.0** *Januari 11,2014*
|
75
|
+
|
76
|
+
* A lot of bugfixing
|
74
77
|
|
75
78
|
**0.4.4** *October 24,2013*
|
76
79
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
require_relative 'table_of_contents/resource'
|
2
|
+
require_relative 'table_of_contents/navigation'
|
2
3
|
|
3
4
|
module EPUBInfo
|
4
5
|
module Models
|
@@ -12,6 +13,7 @@ module EPUBInfo
|
|
12
13
|
metadata = document.css('metadata')
|
13
14
|
self.spine = metadata.xpath('//spine')
|
14
15
|
self.manifest = metadata.xpath('//manifest')
|
16
|
+
self.ncx = Navigation.new(self)
|
15
17
|
self.parser = parser
|
16
18
|
end
|
17
19
|
|
@@ -44,6 +46,7 @@ module EPUBInfo
|
|
44
46
|
attr_accessor :manifest
|
45
47
|
attr_accessor :parser
|
46
48
|
attr_accessor :spine
|
49
|
+
attr_accessor :ncx
|
47
50
|
|
48
51
|
private
|
49
52
|
def load_toc_file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Navigation
|
2
|
+
def initialize(table_of_contents)
|
3
|
+
@table_of_contents = table_of_contents
|
4
|
+
end
|
5
|
+
|
6
|
+
def path
|
7
|
+
@table_of_contents.path
|
8
|
+
end
|
9
|
+
|
10
|
+
def nav_map
|
11
|
+
ncx_doc = Nokogiri::XML(@table_of_contents.parser.zip_file.read(path))
|
12
|
+
ncx_doc.remove_namespaces!
|
13
|
+
|
14
|
+
if ncx_doc
|
15
|
+
map = ncx_doc.xpath('//navMap/navPoint').map do |navpoint|
|
16
|
+
{'label' =>(navpoint % 'navLabel/text').content , 'path' => (navpoint % 'content').attr('src')}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -30,7 +30,7 @@ class Resource
|
|
30
30
|
|
31
31
|
if reference.is_a?(String)
|
32
32
|
reference_data = self.to_a.map do |r|
|
33
|
-
r[:uri] if r[:id].eql?(reference) || r[:uri].eql?(reference)
|
33
|
+
r[:uri] if r[:id].eql?(reference) || r[:uri].eql?(reference) || r[:uri_ref].eql?(reference)
|
34
34
|
end.compact
|
35
35
|
|
36
36
|
if reference_data && !reference_data.empty?
|
@@ -64,6 +64,19 @@ class Resource
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def ncx
|
68
|
+
@ncx ||=
|
69
|
+
begin
|
70
|
+
@table_of_contents.ncx.nav_map.map do |n|
|
71
|
+
path = URI.decode(n['path'])
|
72
|
+
{:uri_ref => path,
|
73
|
+
:text => n['label'],
|
74
|
+
:uri => @table_of_contents.parser.zip_file.entries.map { |p| p.name }.select { |s| s.match(path.gsub(/\#.*$/, '')) }.first
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
67
80
|
def images
|
68
81
|
@images ||= self.to_a.select {|r| r[:type] =~ /image/}
|
69
82
|
end
|
@@ -105,8 +118,10 @@ class Resource
|
|
105
118
|
end
|
106
119
|
|
107
120
|
#TODO:make this an OpenStruct
|
121
|
+
|
122
|
+
uri = @table_of_contents.parser.zip_file.entries.map { |p| p.name }.select { |s| s.match(uri.gsub(/\#.*$/, '')) }.first
|
108
123
|
resources << {:id => id,
|
109
|
-
:uri =>
|
124
|
+
:uri => uri,
|
110
125
|
:uri_ref => uri_ref,
|
111
126
|
:text => label,
|
112
127
|
:type => mime_type,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epubinfo_with_toc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christof Dorner
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ! '>'
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ! '>'
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 1.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: nokogiri
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +110,7 @@ files:
|
|
110
110
|
- lib/epubinfo/models/identifier.rb
|
111
111
|
- lib/epubinfo/models/person.rb
|
112
112
|
- lib/epubinfo/models/table_of_contents.rb
|
113
|
-
- lib/epubinfo/models/table_of_contents/
|
113
|
+
- lib/epubinfo/models/table_of_contents/navigation.rb
|
114
114
|
- lib/epubinfo/models/table_of_contents/resource.rb
|
115
115
|
- lib/epubinfo/parser.rb
|
116
116
|
- lib/epubinfo/utils.rb
|
@@ -141,4 +141,3 @@ signing_key:
|
|
141
141
|
specification_version: 4
|
142
142
|
summary: Extracts metadata information from EPUB files
|
143
143
|
test_files: []
|
144
|
-
has_rdoc:
|