gepub 1.0.10 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/test.yml +4 -11
- data/.rubocop.yml +6 -0
- data/Gemfile +1 -1
- data/README.md +6 -2
- data/Rakefile +1 -1
- data/gepub.gemspec +4 -2
- data/lib/gepub/book.rb +10 -5
- data/lib/gepub/book_add_item.rb +6 -4
- data/lib/gepub/item.rb +13 -7
- data/lib/gepub/metadata.rb +1 -1
- data/lib/gepub/metadata_add.rb +36 -34
- data/lib/gepub/version.rb +1 -1
- data/tools/generate_function.rb +41 -36
- metadata +38 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d719e4054e3b1ab330d8af93992edfc35ebaa355878ee0c623709ddff612f3d
|
4
|
+
data.tar.gz: d20aa19004c3591f7e17a5275fd957b5b1650514a8206ffe301e162fbec2a4af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9070b08171d351372c4a46e0ac489d2a077f3dd106d52346358a895a4ac9036e9162699e7f72124381a7d53903c96dcaa438ef6a31d2b0d1832267cff4ba4b8a
|
7
|
+
data.tar.gz: c9914d0a1340504905c09b2afc591a6aa99c15e5ba219958dcbcb56fdbdb2caa5702950ef614b97977521088e0e30b068eae1098c048a946e6423eeb2e6dee9b
|
data/.github/FUNDING.yml
ADDED
data/.github/workflows/test.yml
CHANGED
@@ -4,26 +4,19 @@ jobs:
|
|
4
4
|
test:
|
5
5
|
strategy:
|
6
6
|
matrix:
|
7
|
-
ruby: [2.
|
7
|
+
ruby: [2.5, 2.6, 2.7, 3.0, jruby]
|
8
8
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
9
|
-
exclude:
|
10
|
-
# TODO: https://github.com/sparklemotion/nokogiri/issues/1961
|
11
|
-
# exclude windows with ruby 2.7 ; nokogiri is not supported for the present
|
12
|
-
- ruby: 2.7
|
13
|
-
platform: windows-latest
|
14
9
|
runs-on: ${{ matrix.platform }}
|
15
10
|
env:
|
16
11
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
17
12
|
steps:
|
18
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v2
|
19
14
|
- name: Set up Ruby
|
20
|
-
uses:
|
15
|
+
uses: ruby/setup-ruby@v1
|
21
16
|
with:
|
22
17
|
ruby-version: ${{ matrix.ruby }}
|
23
18
|
- name: setup gems
|
24
|
-
run:
|
25
|
-
gem install bundler
|
26
|
-
bundle install
|
19
|
+
run: bundle install --jobs 4 --retry 3
|
27
20
|
- name: run test and publish code coverage
|
28
21
|
if: runner.os == 'Linux' && matrix.ruby == '2.7' && env.CC_TEST_REPORTER_ID != ''
|
29
22
|
uses: paambaati/codeclimate-action@v2.3.0
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/acd6df07e071a4bbb399/test_coverage)](https://codeclimate.com/github/skoji/gepub/test_coverage)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/gepub.svg)](http://badge.fury.io/rb/gepub)
|
7
7
|
|
8
|
-
* http://rdoc.info/github/skoji/gepub/
|
8
|
+
* http://rdoc.info/github/skoji/gepub/main/frames
|
9
9
|
|
10
10
|
## DESCRIPTION:
|
11
11
|
|
@@ -103,9 +103,13 @@ epubname = File.join(File.dirname(__FILE__), 'example_test.epub')
|
|
103
103
|
# auto-generated nav file will not appear on spine.
|
104
104
|
book.generate_epub(epubname)
|
105
105
|
```
|
106
|
-
* [examples in this repository](https://github.com/skoji/gepub/tree/
|
106
|
+
* [examples in this repository](https://github.com/skoji/gepub/tree/main/examples/)
|
107
107
|
|
108
108
|
## INSTALL:
|
109
109
|
|
110
110
|
* gem install gepub
|
111
111
|
|
112
|
+
## DONATE:
|
113
|
+
|
114
|
+
* Bitcoin Address: `1M69AwoxpgPZsp5KStLUEjP7so5dHVfDTH`
|
115
|
+
|
data/Rakefile
CHANGED
data/gepub.gemspec
CHANGED
@@ -16,8 +16,10 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 1.
|
20
|
-
s.add_runtime_dependency "rubyzip", "> 1.1.1", "< 2.
|
19
|
+
s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 1.13"
|
20
|
+
s.add_runtime_dependency "rubyzip", "> 1.1.1", "< 2.4"
|
21
|
+
s.add_development_dependency "epubcheck-ruby"
|
21
22
|
s.add_development_dependency "rake"
|
22
23
|
s.add_development_dependency "rspec"
|
24
|
+
s.add_development_dependency "rubocop"
|
23
25
|
end
|
data/lib/gepub/book.rb
CHANGED
@@ -266,7 +266,7 @@ EOF
|
|
266
266
|
|
267
267
|
def nav_doc(title = 'Table of Contents')
|
268
268
|
# handle cascaded toc
|
269
|
-
start_level = @toc && @toc[0][:level] || 1
|
269
|
+
start_level = @toc && !@toc.empty? && @toc[0][:level] || 1
|
270
270
|
stacked_toc = {level: start_level, tocs: [] }
|
271
271
|
@toc.inject(stacked_toc) do |current_stack, toc_entry|
|
272
272
|
toc_entry_level = toc_entry[:level] || 1
|
@@ -316,6 +316,9 @@ EOF
|
|
316
316
|
# build nav
|
317
317
|
builder = Nokogiri::XML::Builder.new {
|
318
318
|
|doc|
|
319
|
+
unless version.to_f < 3.0
|
320
|
+
doc.doc.create_internal_subset('html', nil, nil )
|
321
|
+
end
|
319
322
|
doc.html('xmlns' => "http://www.w3.org/1999/xhtml",'xmlns:epub' => "http://www.idpf.org/2007/ops") {
|
320
323
|
doc.head {
|
321
324
|
doc.title title
|
@@ -428,7 +431,7 @@ EOF
|
|
428
431
|
|_x,item|
|
429
432
|
item.media_type == 'application/x-dtbncx+xml'
|
430
433
|
}.size == 0
|
431
|
-
if (@toc.size == 0)
|
434
|
+
if (@toc.size == 0 && !@package.spine.itemref_list.empty?)
|
432
435
|
@toc << { :item => @package.manifest.item_list[@package.spine.itemref_list[0].idref] }
|
433
436
|
end
|
434
437
|
add_item('toc.ncx', id: 'ncx', content: StringIO.new(ncx_xml))
|
@@ -467,10 +470,12 @@ EOF
|
|
467
470
|
item_attributes.each do |attr, val|
|
468
471
|
next if val.nil?
|
469
472
|
method_name = if attr == :toc_text
|
470
|
-
|
473
|
+
""
|
474
|
+
elsif attr == :property
|
475
|
+
"add_"
|
471
476
|
else
|
472
|
-
"
|
473
|
-
end
|
477
|
+
"set_"
|
478
|
+
end + attr.to_s
|
474
479
|
item.send(method_name, val)
|
475
480
|
end
|
476
481
|
item
|
data/lib/gepub/book_add_item.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
|
+
## this file is automatically generated by tools/generate_function.rb . do not edit this code directly.
|
2
|
+
|
1
3
|
module GEPUB
|
2
4
|
class Book
|
3
5
|
# add an item(i.e. html, images, audios, etc) to Book.
|
4
6
|
# the added item will be referenced by the first argument in the EPUB container.
|
5
7
|
def add_item(href, deprecated_content = nil, deprecated_id = nil, deprecated_attributes = nil, content: nil,
|
6
|
-
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,
|
8
|
+
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
|
7
9
|
attributes: {})
|
8
10
|
content, id, attributes = handle_deprecated_add_item_arguments(deprecated_content, deprecated_id, deprecated_attributes, content, id, attributes)
|
9
|
-
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text }, attributes: attributes, ordered: false)
|
11
|
+
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text,property: property }, attributes: attributes, ordered: false)
|
10
12
|
end
|
11
13
|
|
12
14
|
# same as add_item, but the item will be added to spine of the EPUB.
|
13
15
|
def add_ordered_item(href, deprecated_content = nil, deprecated_id = nil, deprecated_attributes = nil, content:nil,
|
14
|
-
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,
|
16
|
+
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
|
15
17
|
attributes: {})
|
16
18
|
content, id, attributes = handle_deprecated_add_item_arguments(deprecated_content, deprecated_id, deprecated_attributes, content, id, attributes)
|
17
|
-
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text }, attributes: attributes, ordered: true)
|
19
|
+
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text,property: property }, attributes: attributes, ordered: true)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/gepub/item.rb
CHANGED
@@ -97,9 +97,7 @@ module GEPUB
|
|
97
97
|
# guess and set content property from contents.
|
98
98
|
def guess_content_property
|
99
99
|
if File.extname(self.href) =~ /.x?html/ && @attributes['media-type'] === 'application/xhtml+xml'
|
100
|
-
@attributes['properties']
|
101
|
-
|x| x == 'svg' || x == 'mathml' || x == 'switch' || x == 'remote-resources'
|
102
|
-
}
|
100
|
+
@attributes['properties'] ||= []
|
103
101
|
parsed = Nokogiri::XML::Document.parse(@content)
|
104
102
|
return unless parsed.root.node_name === "html"
|
105
103
|
ns_prefix = parsed.namespaces.invert['http://www.w3.org/1999/xhtml']
|
@@ -108,9 +106,10 @@ module GEPUB
|
|
108
106
|
else
|
109
107
|
prefix = "#{ns_prefix}:"
|
110
108
|
end
|
109
|
+
images = parsed.xpath("//#{prefix}img[starts-with(@src,'http')]")
|
111
110
|
videos = parsed.xpath("//#{prefix}video[starts-with(@src,'http')]") + parsed.xpath("//#{prefix}video/#{prefix}source[starts-with(@src,'http')]")
|
112
111
|
audios = parsed.xpath("//#{prefix}audio[starts-with(@src,'http')]") + parsed.xpath("//#{prefix}audio/#{prefix}source[starts-with(@src,'http')]")
|
113
|
-
if videos.size > 0 || audios.size > 0
|
112
|
+
if images.size > 0 || videos.size > 0 || audios.size > 0
|
114
113
|
self.add_property('remote-resources')
|
115
114
|
end
|
116
115
|
if parsed.xpath("//p:math", { 'p' => 'http://www.w3.org/1998/Math/MathML' }).size > 0
|
@@ -139,12 +138,19 @@ module GEPUB
|
|
139
138
|
self
|
140
139
|
end
|
141
140
|
|
142
|
-
# add content
|
141
|
+
# add content from io or file to the item
|
143
142
|
def add_content(io_or_filename)
|
144
|
-
io = io_or_filename
|
145
143
|
if io_or_filename.class == String
|
146
|
-
|
144
|
+
File.open(io_or_filename, mode='r') do |f|
|
145
|
+
add_content_io f
|
146
|
+
end
|
147
|
+
else
|
148
|
+
add_content_io io_or_filename
|
147
149
|
end
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
def add_content_io(io)
|
148
154
|
io.binmode
|
149
155
|
@content = io.read
|
150
156
|
if File.extname(self.href) =~ /x?html$/
|
data/lib/gepub/metadata.rb
CHANGED
data/lib/gepub/metadata_add.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
## this file is automatically generated by tools/generate_function.rb . do not edit this code directly.
|
2
|
+
|
1
3
|
module GEPUB
|
2
|
-
|
4
|
+
class Metadata
|
3
5
|
CONTENT_NODE_LIST = ['identifier', 'title', 'language', 'contributor', 'creator', 'coverage', 'date','description','format','publisher','relation','rights','source','subject','type'].each {
|
4
6
|
|node|
|
5
7
|
define_method(node + '_list') { @content_nodes[node].dup.sort_as_meta }
|
@@ -14,7 +16,7 @@ module GEPUB
|
|
14
16
|
|
15
17
|
define_method(node, ->(content=UNASSIGNED, deprecated_id=nil, id:nil,
|
16
18
|
title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
|
17
|
-
|
19
|
+
lang: nil, alternates: {}) {
|
18
20
|
if unassigned?(content)
|
19
21
|
get_first_node(node)
|
20
22
|
else
|
@@ -48,7 +50,7 @@ module GEPUB
|
|
48
50
|
|
49
51
|
def add_title(content, deprecated_id = nil, deprecated_title_type = nil, id: nil,
|
50
52
|
title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
|
51
|
-
|
53
|
+
lang: nil, alternates: {})
|
52
54
|
if deprecated_id
|
53
55
|
warn 'second argument for add_title is deprecated. use id: instead'
|
54
56
|
id = deprecated_id
|
@@ -58,15 +60,15 @@ module GEPUB
|
|
58
60
|
title_type = deprecated_title_type
|
59
61
|
end
|
60
62
|
meta = add_metadata('title', content, id: id,
|
61
|
-
|
62
|
-
|
63
|
+
title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
|
64
|
+
lang: lang, alternates: alternates)
|
63
65
|
yield meta if block_given?
|
64
66
|
meta
|
65
67
|
end
|
66
68
|
|
67
69
|
def add_person(name, content, deprecated_id = nil, deprecated_role = nil, id: nil,
|
68
|
-
|
69
|
-
|
70
|
+
title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
|
71
|
+
lang: nil, alternates: {})
|
70
72
|
if deprecated_id
|
71
73
|
warn 'second argument for add_person is deprecated. use id: instead'
|
72
74
|
id = deprecated_id
|
@@ -76,15 +78,15 @@ module GEPUB
|
|
76
78
|
role = deprecated_role
|
77
79
|
end
|
78
80
|
meta = add_metadata(name, content, id: id,
|
79
|
-
|
80
|
-
|
81
|
+
title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
|
82
|
+
lang: lang, alternates: alternates)
|
81
83
|
yield meta if block_given?
|
82
84
|
meta
|
83
85
|
end
|
84
86
|
|
85
87
|
def add_creator(content, deprecated_id = nil, deprecated_role = nil, id: nil,
|
86
88
|
title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
|
87
|
-
|
89
|
+
lang: nil, alternates: {})
|
88
90
|
if deprecated_id
|
89
91
|
warn 'second argument for add_creator is deprecated. use id: instead'
|
90
92
|
id = deprecated_id
|
@@ -93,17 +95,17 @@ module GEPUB
|
|
93
95
|
warn 'third argument for add_creator is deprecated. use role: instead'
|
94
96
|
role = deprecated_role
|
95
97
|
end
|
96
|
-
|
98
|
+
role = 'aut' if role.nil?
|
97
99
|
meta = add_person('creator', content, id: id,
|
98
|
-
|
99
|
-
|
100
|
+
title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
|
101
|
+
lang: lang, alternates: alternates)
|
100
102
|
yield meta if block_given?
|
101
103
|
meta
|
102
104
|
end
|
103
105
|
|
104
106
|
def add_contributor(content, deprecated_id = nil, deprecated_role = nil, id: nil,
|
105
107
|
title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
|
106
|
-
|
108
|
+
lang: nil, alternates: {})
|
107
109
|
if deprecated_id
|
108
110
|
warn 'second argument for add_contributor is deprecated. use id: instead'
|
109
111
|
id = deprecated_id
|
@@ -113,30 +115,30 @@ module GEPUB
|
|
113
115
|
role = deprecated_role
|
114
116
|
end
|
115
117
|
meta = add_person('contributor', content, id: id,
|
116
|
-
|
117
|
-
|
118
|
+
title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
|
119
|
+
lang: lang, alternates: alternates)
|
118
120
|
yield meta if block_given?
|
119
121
|
meta
|
120
122
|
end
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
124
|
+
def add_metadata(name, content, id: nil, itemclass: Meta,
|
125
|
+
title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
|
126
|
+
lang: nil, alternates: {}
|
127
|
+
)
|
128
|
+
meta = add_metadata_internal(name, content, id: id, itemclass: itemclass)
|
127
129
|
[{ value: title_type, name: 'title-type'},{ value: identifier_type, name: 'identifier-type'},{ value: display_seq, name: 'display-seq'},{ value: file_as, name: 'file-as'},{ value: group_position, name: 'group-position'},{ value: role, name: 'role'}].each do |refiner|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
130
|
+
if refiner[:value]
|
131
|
+
meta.refine(refiner[:name], refiner[:value])
|
132
|
+
end
|
133
|
+
end
|
134
|
+
if lang
|
135
|
+
meta.lang = lang
|
136
|
+
end
|
137
|
+
if alternates
|
138
|
+
meta.add_alternates alternates
|
139
|
+
end
|
138
140
|
yield meta if block_given?
|
139
|
-
|
140
|
-
|
141
|
-
|
141
|
+
meta
|
142
|
+
end
|
143
|
+
end
|
142
144
|
end
|
data/lib/gepub/version.rb
CHANGED
data/tools/generate_function.rb
CHANGED
@@ -4,10 +4,13 @@ attrs = GEPUB::Item::ATTRIBUTES.select do |attr|
|
|
4
4
|
end.map do |attr|
|
5
5
|
attr.sub('-', '_')
|
6
6
|
end
|
7
|
-
attrs << "toc_text"
|
7
|
+
attrs << "toc_text"
|
8
|
+
attrs << "property"
|
8
9
|
attrs_arguments_string = attrs.map { |attr| "#{attr}: nil" }.join(',')
|
9
10
|
attrs_internal_string = "{ " + attrs.map { |attr| "#{attr}: #{attr}"}.join(',') + " }"
|
10
11
|
File.write(File.join(File.dirname(__FILE__), "../lib/gepub/book_add_item.rb"), <<EOF)
|
12
|
+
## this file is automatically generated by tools/generate_function.rb . do not edit this code directly.
|
13
|
+
|
11
14
|
module GEPUB
|
12
15
|
class Book
|
13
16
|
# add an item(i.e. html, images, audios, etc) to Book.
|
@@ -34,7 +37,7 @@ require_relative '../lib/gepub/dsl_util.rb'
|
|
34
37
|
require_relative '../lib/gepub/meta.rb'
|
35
38
|
|
36
39
|
refiners = GEPUB::Meta::REFINERS.map do |refiner|
|
37
|
-
|
40
|
+
refiner.sub('-', '_')
|
38
41
|
end
|
39
42
|
|
40
43
|
refiners_arguments_string = refiners.map { |refiner| "#{refiner}: nil" }.join(',')
|
@@ -45,8 +48,10 @@ meta_attr_arguments_string = "lang: nil, alternates: {}"
|
|
45
48
|
meta_attr_arguments_set_string = "lang: lang, alternates: alternates"
|
46
49
|
|
47
50
|
File.write(File.join(File.dirname(__FILE__), "../lib/gepub/metadata_add.rb"), <<EOF)
|
51
|
+
## this file is automatically generated by tools/generate_function.rb . do not edit this code directly.
|
52
|
+
|
48
53
|
module GEPUB
|
49
|
-
|
54
|
+
class Metadata
|
50
55
|
CONTENT_NODE_LIST = ['identifier', 'title', 'language', 'contributor', 'creator', 'coverage', 'date','description','format','publisher','relation','rights','source','subject','type'].each {
|
51
56
|
|node|
|
52
57
|
define_method(node + '_list') { @content_nodes[node].dup.sort_as_meta }
|
@@ -61,7 +66,7 @@ module GEPUB
|
|
61
66
|
|
62
67
|
define_method(node, ->(content=UNASSIGNED, deprecated_id=nil, id:nil,
|
63
68
|
#{refiners_arguments_string},
|
64
|
-
|
69
|
+
#{meta_attr_arguments_string}) {
|
65
70
|
if unassigned?(content)
|
66
71
|
get_first_node(node)
|
67
72
|
else
|
@@ -95,7 +100,7 @@ module GEPUB
|
|
95
100
|
|
96
101
|
def add_title(content, deprecated_id = nil, deprecated_title_type = nil, id: nil,
|
97
102
|
#{refiners_arguments_string},
|
98
|
-
|
103
|
+
#{meta_attr_arguments_string})
|
99
104
|
if deprecated_id
|
100
105
|
warn 'second argument for add_title is deprecated. use id: instead'
|
101
106
|
id = deprecated_id
|
@@ -105,15 +110,15 @@ module GEPUB
|
|
105
110
|
title_type = deprecated_title_type
|
106
111
|
end
|
107
112
|
meta = add_metadata('title', content, id: id,
|
108
|
-
|
109
|
-
|
113
|
+
#{refiners_arguments_set_string},
|
114
|
+
#{meta_attr_arguments_set_string})
|
110
115
|
yield meta if block_given?
|
111
116
|
meta
|
112
117
|
end
|
113
118
|
|
114
119
|
def add_person(name, content, deprecated_id = nil, deprecated_role = nil, id: nil,
|
115
|
-
|
116
|
-
|
120
|
+
#{refiners_arguments_string},
|
121
|
+
#{meta_attr_arguments_string})
|
117
122
|
if deprecated_id
|
118
123
|
warn 'second argument for add_person is deprecated. use id: instead'
|
119
124
|
id = deprecated_id
|
@@ -123,15 +128,15 @@ module GEPUB
|
|
123
128
|
role = deprecated_role
|
124
129
|
end
|
125
130
|
meta = add_metadata(name, content, id: id,
|
126
|
-
|
127
|
-
|
131
|
+
#{refiners_arguments_set_string},
|
132
|
+
#{meta_attr_arguments_set_string})
|
128
133
|
yield meta if block_given?
|
129
134
|
meta
|
130
135
|
end
|
131
136
|
|
132
137
|
def add_creator(content, deprecated_id = nil, deprecated_role = nil, id: nil,
|
133
138
|
#{refiners_arguments_string},
|
134
|
-
|
139
|
+
#{meta_attr_arguments_string})
|
135
140
|
if deprecated_id
|
136
141
|
warn 'second argument for add_creator is deprecated. use id: instead'
|
137
142
|
id = deprecated_id
|
@@ -140,17 +145,17 @@ module GEPUB
|
|
140
145
|
warn 'third argument for add_creator is deprecated. use role: instead'
|
141
146
|
role = deprecated_role
|
142
147
|
end
|
143
|
-
|
148
|
+
role = 'aut' if role.nil?
|
144
149
|
meta = add_person('creator', content, id: id,
|
145
|
-
|
146
|
-
|
150
|
+
#{refiners_arguments_set_string},
|
151
|
+
#{meta_attr_arguments_set_string})
|
147
152
|
yield meta if block_given?
|
148
153
|
meta
|
149
154
|
end
|
150
155
|
|
151
156
|
def add_contributor(content, deprecated_id = nil, deprecated_role = nil, id: nil,
|
152
157
|
#{refiners_arguments_string},
|
153
|
-
|
158
|
+
#{meta_attr_arguments_string})
|
154
159
|
if deprecated_id
|
155
160
|
warn 'second argument for add_contributor is deprecated. use id: instead'
|
156
161
|
id = deprecated_id
|
@@ -160,32 +165,32 @@ module GEPUB
|
|
160
165
|
role = deprecated_role
|
161
166
|
end
|
162
167
|
meta = add_person('contributor', content, id: id,
|
163
|
-
|
164
|
-
|
168
|
+
#{refiners_arguments_set_string},
|
169
|
+
#{meta_attr_arguments_set_string})
|
165
170
|
yield meta if block_given?
|
166
171
|
meta
|
167
172
|
end
|
168
173
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
+
def add_metadata(name, content, id: nil, itemclass: Meta,
|
175
|
+
#{refiners_arguments_string},
|
176
|
+
#{meta_attr_arguments_string}
|
177
|
+
)
|
178
|
+
meta = add_metadata_internal(name, content, id: id, itemclass: itemclass)
|
174
179
|
#{refiners_string}.each do |refiner|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
180
|
+
if refiner[:value]
|
181
|
+
meta.refine(refiner[:name], refiner[:value])
|
182
|
+
end
|
183
|
+
end
|
184
|
+
if lang
|
185
|
+
meta.lang = lang
|
186
|
+
end
|
187
|
+
if alternates
|
188
|
+
meta.add_alternates alternates
|
189
|
+
end
|
185
190
|
yield meta if block_given?
|
186
|
-
|
187
|
-
|
188
|
-
|
191
|
+
meta
|
192
|
+
end
|
193
|
+
end
|
189
194
|
end
|
190
195
|
EOF
|
191
196
|
|
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: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOJIMA Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.8.2
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '1.
|
22
|
+
version: '1.13'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.8.2
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.13'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rubyzip
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 1.1.1
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '2.
|
42
|
+
version: '2.4'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,21 @@ dependencies:
|
|
49
49
|
version: 1.1.1
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '2.
|
52
|
+
version: '2.4'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: epubcheck-ruby
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: rake
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +92,20 @@ dependencies:
|
|
78
92
|
- - ">="
|
79
93
|
- !ruby/object:Gem::Version
|
80
94
|
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rubocop
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
81
109
|
description: gepub is a generic EPUB parser/generator. Generates and parse EPUB2 and
|
82
110
|
EPUB3
|
83
111
|
email:
|
@@ -89,9 +117,12 @@ extensions: []
|
|
89
117
|
extra_rdoc_files: []
|
90
118
|
files:
|
91
119
|
- ".gitattributes"
|
120
|
+
- ".github/FUNDING.yml"
|
121
|
+
- ".github/dependabot.yml"
|
92
122
|
- ".github/workflows/gempush.yml"
|
93
123
|
- ".github/workflows/test.yml"
|
94
124
|
- ".gitignore"
|
125
|
+
- ".rubocop.yml"
|
95
126
|
- Gemfile
|
96
127
|
- LICENSE.txt
|
97
128
|
- README.md
|
@@ -146,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
177
|
- !ruby/object:Gem::Version
|
147
178
|
version: '0'
|
148
179
|
requirements: []
|
149
|
-
rubygems_version: 3.0.3
|
180
|
+
rubygems_version: 3.0.3.1
|
150
181
|
signing_key:
|
151
182
|
specification_version: 4
|
152
183
|
summary: a generic EPUB library for Ruby.
|