eepub 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/eepub/epub.rb +5 -3
- data/lib/eepub/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b04605903997480b36c48aa960bf80095fb696
|
4
|
+
data.tar.gz: 195e16dfea1d1fb68d9bd457a48aa31405048e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a2a82aa4336a89d8d2ad72819db5d6cae49a1daec5ecd990652544b14b7c3dbb198b283add247ca98af050c4ccc7587f01fc8e2e6575369ad1112eda9f53f4
|
7
|
+
data.tar.gz: 777e60cd6b7373f3297ca3919052c77af2eaad3113d65439d7a297ea9c962db5f424577c46489c5c63f3f5218b0f96be59883f9795a760a435ee4a253c528b7e
|
data/README.md
CHANGED
@@ -28,7 +28,11 @@ epub = Eepub.load_from('path/to/example.epub')
|
|
28
28
|
epub.title #=> 'Example book'
|
29
29
|
epub.title = 'UPDATED'
|
30
30
|
|
31
|
-
|
31
|
+
# in-place update
|
32
|
+
epub.save!
|
33
|
+
|
34
|
+
# save to another file
|
35
|
+
epub.save! to: 'path/to/updated.epub'
|
32
36
|
```
|
33
37
|
|
34
38
|
## Development
|
data/lib/eepub/epub.rb
CHANGED
@@ -8,6 +8,8 @@ module Eepub
|
|
8
8
|
@path = path
|
9
9
|
end
|
10
10
|
|
11
|
+
attr_reader :path
|
12
|
+
|
11
13
|
def title
|
12
14
|
@title ||= Zip::File.open(@path) {|zip|
|
13
15
|
package_xml = Nokogiri::XML.parse(package_entry(zip).get_input_stream)
|
@@ -18,10 +20,10 @@ module Eepub
|
|
18
20
|
|
19
21
|
attr_writer :title
|
20
22
|
|
21
|
-
def
|
22
|
-
FileUtils.cp
|
23
|
+
def save!(to: path)
|
24
|
+
FileUtils.cp path, to unless path == to
|
23
25
|
|
24
|
-
Zip::File.open
|
26
|
+
Zip::File.open to do |zip|
|
25
27
|
entry = package_entry(zip)
|
26
28
|
xml = Nokogiri::XML.parse(entry.get_input_stream)
|
27
29
|
title_node = xml.at_xpath('//dc:title', dc: 'http://purl.org/dc/elements/1.1/')
|
data/lib/eepub/version.rb
CHANGED