gepub 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/examples/generate_example.rb +7 -7
- data/examples/new_book_example.rb +12 -14
- data/lib/gepub/builder.rb +6 -2
- data/lib/gepub/meta.rb +1 -1
- data/lib/gepub/metadata.rb +14 -6
- data/lib/gepub/package.rb +5 -1
- data/lib/gepub/version.rb +1 -1
- data/spec/metadata_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c4bd8231fb2f42f3d42f2909605224d3ac30b9ccc52736fc158d1340810e5b3
|
4
|
+
data.tar.gz: f6834698805f386ce33b3eff1cba78de141e1f98ee2a9b5f3ee4ea9d588681c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5650ce85cec97fec3aa6da1031c15c8042a0f44008bdabd3b9f54936de48ddee6066b1e67bc1dc791e7259f13bb4f5120dba61587bdbbe7247e26106cee97fa6
|
7
|
+
data.tar.gz: 0d30aafeb4f8cd0d5a1b8f3ca239aa5a18142c7b8c00135dfcba7f1d7034bfad87f072b57cc6ccc6cba0d2601863ae3f691594de468c93acc0f05400efd050a9
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ a generic EPUB parser/generator library.
|
|
22
22
|
|
23
23
|
If you are using GEPUB::Builder from your code and do not like its behaviour(e.g. the block inside is evaluated as inside the Builder instance), please consider using GEPUB::Book directly.
|
24
24
|
|
25
|
-
**
|
25
|
+
**GEPUB::Builder will be obsolete in gepub 0.7. GEPUB::Book#new will be enhanced instead of Builder DSL.**
|
26
26
|
|
27
27
|
|
28
28
|
## SYNOPSIS:
|
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'gepub'
|
4
4
|
|
5
5
|
book = GEPUB::Book.new
|
6
|
-
book.
|
6
|
+
book.primary_identifier('http://example.jp/bookid_in_url', 'BookID', 'URL')
|
7
7
|
book.language = 'ja'
|
8
8
|
|
9
9
|
# you can add metadata and its property using block
|
@@ -18,18 +18,18 @@ book.add_title('GEPUBサンプル文書', nil, GEPUB::TITLE_TYPE::MAIN) {
|
|
18
18
|
'th' => 'GEPUB ตัวอย่าง (ญี่ปุ่น)')
|
19
19
|
}
|
20
20
|
# you can do the same thing using method chain
|
21
|
-
book.add_title('これはあくまでサンプルです',nil, GEPUB::TITLE_TYPE::SUBTITLE).
|
21
|
+
book.add_title('これはあくまでサンプルです',nil, GEPUB::TITLE_TYPE::SUBTITLE).display_seq(1).add_alternates('en' => 'this book is just a sample.')
|
22
22
|
book.add_creator('小嶋智') {
|
23
23
|
|creator|
|
24
24
|
creator.display_seq = 1
|
25
25
|
creator.add_alternates('en' => 'KOJIMA Satoshi')
|
26
26
|
}
|
27
|
-
book.add_contributor('電書部').
|
28
|
-
book.add_contributor('アサガヤデンショ').
|
29
|
-
book.add_contributor('湘南電書鼎談').
|
30
|
-
book.add_contributor('電子雑誌トルタル').
|
27
|
+
book.add_contributor('電書部').display_seq(1).add_alternates('en' => 'Denshobu')
|
28
|
+
book.add_contributor('アサガヤデンショ').display_seq(2).add_alternates('en' => 'Asagaya Densho')
|
29
|
+
book.add_contributor('湘南電書鼎談').display_seq(3).add_alternates('en' => 'Shonan Densho Teidan')
|
30
|
+
book.add_contributor('電子雑誌トルタル').display_seq(4).add_alternates('en' => 'eMagazine Torutaru')
|
31
31
|
|
32
|
-
imgfile = File.join(File.dirname(__FILE__), '
|
32
|
+
imgfile = File.join(File.dirname(__FILE__), 'image1.jpg')
|
33
33
|
File.open(imgfile) do
|
34
34
|
|io|
|
35
35
|
book.add_item('img/image1.jpg',io).cover_image
|
@@ -1,20 +1,18 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'gepub'
|
3
3
|
|
4
|
-
GEPUB::Book.new do |book|
|
5
|
-
book.
|
6
|
-
book.
|
7
|
-
book.
|
8
|
-
book.
|
9
|
-
book.
|
4
|
+
gbook = GEPUB::Book.new do |book|
|
5
|
+
book.identifier = 'http://example.jp/bookid_in_url'
|
6
|
+
book.title = 'GEPUB Sample Book'
|
7
|
+
book.creator = 'KOJIMA Satoshi'
|
8
|
+
book.contributor = '電書部'
|
9
|
+
book.add_contributor 'アサガヤデンショ'
|
10
|
+
book.add_contributor '電子雑誌トルタル'
|
11
|
+
book.language = 'ja'
|
10
12
|
|
11
|
-
book.ordered
|
12
|
-
book.add_item('name')
|
13
|
-
|
14
|
-
item.content = StringIO.new()
|
15
|
-
end
|
16
|
-
}
|
13
|
+
book.ordered do
|
14
|
+
item = book.add_item('name.xhtml')
|
15
|
+
item.add_content StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c1</title></head><body><p>the first page</p></body></html>')end
|
17
16
|
end
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
gbook.generate_epub("test.epub")
|
data/lib/gepub/builder.rb
CHANGED
@@ -190,7 +190,9 @@ module GEPUB
|
|
190
190
|
# define base methods.
|
191
191
|
GEPUB::Metadata::CONTENT_NODE_LIST.each {
|
192
192
|
|name|
|
193
|
-
|
193
|
+
if !["title", "creator", "contributor"].include?(name)
|
194
|
+
define_method(name) { |val| @last_defined_item = MetaItem.new(@book.send("add_#{name}".to_sym, val, nil)) }
|
195
|
+
end
|
194
196
|
}
|
195
197
|
|
196
198
|
GEPUB::TITLE_TYPE::TYPES.each {
|
@@ -205,7 +207,9 @@ module GEPUB
|
|
205
207
|
else
|
206
208
|
methodname = type
|
207
209
|
end
|
208
|
-
|
210
|
+
if methodname != "collection"
|
211
|
+
define_method(methodname) { |val| @last_defined_item = MetaItem.new(@book.add_title(val, nil, type)) }
|
212
|
+
end
|
209
213
|
}
|
210
214
|
|
211
215
|
def collection(val, count = 1)
|
data/lib/gepub/meta.rb
CHANGED
data/lib/gepub/metadata.rb
CHANGED
@@ -119,6 +119,8 @@ module GEPUB
|
|
119
119
|
end
|
120
120
|
}
|
121
121
|
|
122
|
+
next if node == 'title'
|
123
|
+
|
122
124
|
define_method(node, ->(content=UNASSIGNED, id=nil) {
|
123
125
|
if unassigned?(content)
|
124
126
|
get_first_node(node)
|
@@ -128,11 +130,6 @@ module GEPUB
|
|
128
130
|
end
|
129
131
|
})
|
130
132
|
|
131
|
-
define_method('add_' + node) {
|
132
|
-
|content, id|
|
133
|
-
add_metadata(node, content, id)
|
134
|
-
}
|
135
|
-
|
136
133
|
define_method('set_' + node) {
|
137
134
|
|content, id|
|
138
135
|
warn "obsolete : set_#{node}. use #{node} instead."
|
@@ -143,7 +140,18 @@ module GEPUB
|
|
143
140
|
define_method(node+'=') {
|
144
141
|
|content|
|
145
142
|
send(node + "_clear")
|
146
|
-
|
143
|
+
if node == 'date'
|
144
|
+
add_date(content, nil)
|
145
|
+
else
|
146
|
+
add_metadata(node, content, nil)
|
147
|
+
end
|
148
|
+
}
|
149
|
+
|
150
|
+
next if ["identifier", "date", "creator", "contributor"].include?(node)
|
151
|
+
|
152
|
+
define_method('add_' + node) {
|
153
|
+
|content, id|
|
154
|
+
add_metadata(node, content, id)
|
147
155
|
}
|
148
156
|
}
|
149
157
|
|
data/lib/gepub/package.rb
CHANGED
@@ -11,7 +11,11 @@ module GEPUB
|
|
11
11
|
def_delegators :@manifest, :item_by_href
|
12
12
|
def_delegators :@metadata, *Metadata::CONTENT_NODE_LIST.map {
|
13
13
|
|x|
|
14
|
-
|
14
|
+
if x == "identifier"
|
15
|
+
["#{x}_list", "set_#{x}", "add_#{x}"]
|
16
|
+
else
|
17
|
+
["#{x}", "#{x}_list", "set_#{x}", "#{x}=", "add_#{x}"]
|
18
|
+
end
|
15
19
|
}.flatten
|
16
20
|
def_delegators :@metadata, :set_lastmodified
|
17
21
|
def_delegators :@metadata, :lastmodified
|
data/lib/gepub/version.rb
CHANGED
data/spec/metadata_spec.rb
CHANGED
@@ -153,6 +153,13 @@ describe GEPUB::Metadata do
|
|
153
153
|
expect(metadata.date.to_s).to eq('2012-02-27T20:00:00Z')
|
154
154
|
end
|
155
155
|
|
156
|
+
it 'should handle date with `date=` method and Time object' do
|
157
|
+
metadata = GEPUB::Metadata.new
|
158
|
+
a = Time.parse '2012-02-27 20:00:00 UTC'
|
159
|
+
metadata.date = a
|
160
|
+
expect(metadata.date.to_s).to eq('2012-02-27T20:00:00Z')
|
161
|
+
end
|
162
|
+
|
156
163
|
it 'should handle date with Time object by content = ' do
|
157
164
|
metadata = GEPUB::Metadata.new
|
158
165
|
a = Time.parse '2012-02-27 20:00:00 UTC'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gepub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOJIMA Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|