eepub 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eepub.gemspec +0 -1
- data/lib/eepub/epub.rb +10 -14
- data/lib/eepub/version.rb +1 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a03a7f0d557df85b37ddfe0d051d7a8ad7c1237
|
4
|
+
data.tar.gz: c959ec316cc35d15bf4ff5a161ded27973a825ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3639ea2af82b48b313435f3dfba5597a32e7fcc74d108677ea7c24208923fa81f266a12e5e1f7077d7a3a4777f090521fe334d5ecd02f2148040be5523fbe12f
|
7
|
+
data.tar.gz: 56e6fd6e9becee705928da1bd5d7ee7662ddbcc389eb053d0d431461163dd933aa5a6cf39c4967668724527cd34d559f5ce5ac5c11d33d9158daa02b4fef2972
|
data/eepub.gemspec
CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
|
-
spec.add_runtime_dependency 'nokogiri'
|
20
19
|
spec.add_runtime_dependency 'rubyzip'
|
21
20
|
|
22
21
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
data/lib/eepub/epub.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'zip'
|
3
1
|
require 'fileutils'
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'zip'
|
4
4
|
|
5
5
|
module Eepub
|
6
6
|
class Epub
|
@@ -12,9 +12,9 @@ module Eepub
|
|
12
12
|
|
13
13
|
def title
|
14
14
|
@title ||= Zip::File.open(@path) {|zip|
|
15
|
-
package_xml =
|
15
|
+
package_xml = REXML::Document.new(package_entry(zip).get_input_stream)
|
16
16
|
|
17
|
-
package_xml.
|
17
|
+
package_xml.elements['//dc:title'].text
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
@@ -25,10 +25,10 @@ module Eepub
|
|
25
25
|
|
26
26
|
Zip::File.open to do |zip|
|
27
27
|
entry = package_entry(zip)
|
28
|
-
xml =
|
29
|
-
title_node = xml.
|
28
|
+
xml = REXML::Document.new(entry.get_input_stream)
|
29
|
+
title_node = xml.elements['//dc:title']
|
30
30
|
|
31
|
-
title_node.
|
31
|
+
title_node.text = title
|
32
32
|
|
33
33
|
zip.get_output_stream entry.name do |stream|
|
34
34
|
stream.write xml.to_s
|
@@ -41,15 +41,11 @@ module Eepub
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def package_entry(zip)
|
44
|
-
|
45
|
-
|
46
|
-
path
|
44
|
+
container_entry = zip.find_entry('META-INF/container.xml')
|
45
|
+
container_xml = REXML::Document.new(container_entry.get_input_stream)
|
46
|
+
path = container_xml.elements['//rootfile/@full-path'].value
|
47
47
|
|
48
48
|
zip.find_entry(path)
|
49
49
|
end
|
50
|
-
|
51
|
-
def container_entry(zip)
|
52
|
-
zip.find_entry('META-INF/container.xml')
|
53
|
-
end
|
54
50
|
end
|
55
51
|
end
|
data/lib/eepub/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eepub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keita Urashima
|
@@ -10,20 +10,6 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: nokogiri
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rubyzip
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|