eepub 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eepub/epub.rb +16 -7
- data/lib/eepub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52fbfd183089157649fb9784374b79ebbae527ba
|
4
|
+
data.tar.gz: 75ab452c76d5dab0473feeb9c80be18be909f4a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68fd2bad5e3febe6070d6966548447bde98bcba3023de7b619dab789bd26409127f09053fcb8dd96d598d719a2b83f031481905a6d7be9bbc270c9cf935724f3
|
7
|
+
data.tar.gz: e20e6a42c7b2d2f22b780a8fe7c07d9050b04bebf77f8bb7369ffffecab43b2510056716aec897efd8d770528def6b23b63f2a0ad26fe9b8709582c783d263f1
|
data/lib/eepub/epub.rb
CHANGED
@@ -27,9 +27,9 @@ module Eepub
|
|
27
27
|
|
28
28
|
def title
|
29
29
|
@title ||= Zip::File.open(path) {|zip|
|
30
|
-
rootfile_doc =
|
30
|
+
rootfile_doc = parse_xml(find_rootfile_entry(zip))
|
31
31
|
|
32
|
-
|
32
|
+
get_title_element(rootfile_doc).text
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
@@ -39,10 +39,10 @@ module Eepub
|
|
39
39
|
FileUtils.cp path, to unless path == to
|
40
40
|
|
41
41
|
Zip::File.open to do |zip|
|
42
|
-
rootfile_entry =
|
43
|
-
rootfile_doc = rootfile_entry
|
42
|
+
rootfile_entry = find_rootfile_entry(zip)
|
43
|
+
rootfile_doc = parse_xml(rootfile_entry)
|
44
44
|
|
45
|
-
|
45
|
+
get_title_element(rootfile_doc).text = title
|
46
46
|
|
47
47
|
zip.get_output_stream rootfile_entry.name, &rootfile_doc.method(:write)
|
48
48
|
zip.commit
|
@@ -51,11 +51,20 @@ module Eepub
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
def
|
55
|
-
container_doc = zip.find_entry('META-INF/container.xml')
|
54
|
+
def find_rootfile_entry(zip)
|
55
|
+
container_doc = parse_xml(zip.find_entry('META-INF/container.xml'))
|
56
56
|
rootfile_path = REXML::XPath.first(container_doc, '//container:rootfile/@full-path', XMLNS.slice('container')).value
|
57
57
|
|
58
58
|
zip.find_entry(rootfile_path)
|
59
59
|
end
|
60
|
+
|
61
|
+
def parse_xml(entry)
|
62
|
+
content = entry.get_input_stream.read
|
63
|
+
REXML::Document.new(content)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_title_element(doc)
|
67
|
+
REXML::XPath.first(doc, '//dc:title', XMLNS.slice('dc'))
|
68
|
+
end
|
60
69
|
end
|
61
70
|
end
|
data/lib/eepub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eepub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keita Urashima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|