gepub 1.0.8 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6279f47052dbbe90014ca6653faf663043872dabd364f3cabadc9c2e82ae8262
4
- data.tar.gz: 79e0d32c97a46879c7b6597c48bbeb1253e96bd89c3d5f2c04d307d35c544118
3
+ metadata.gz: a40e301ce8bfa736313ddbb2509269f296c510f268856b34e7fe7b94ee5c04d5
4
+ data.tar.gz: c0cb10bd080753ec17bb44f2e3c2066334a832c5e5d48572f17f6c21664660b9
5
5
  SHA512:
6
- metadata.gz: bdb6373fc9a484abfd0c041fc989313b6c3033d6c192fd0688b80597fefc1f64aa49cecd56539c67aed9669f1b623ad2c500d046d47bda02853ffb3f6d3dd525
7
- data.tar.gz: 2cf23f8b402e491e4dff1b3a6b69a6e9ca6130139716a991d447e0b670bd04249dc0d030b247936a070bbaf7cdd8aa58f6ebb64313cd549a2879d5f0c1ccafdd
6
+ metadata.gz: 93f8cf62e343eb77bb8e06ea54204dc683c0b5d4269f0d2a4dafcbb3c4d3cff7d7cd0e2a89df6f39537facd81409a9bd757af3a4171585b64e68397f1d3f884f
7
+ data.tar.gz: 81096c282027e255a8f89d5bf6803b55eb8b9f1168c5a2509821836a037299614f26b3511e487831ceaa3b841ed3d5a1076b968f527f4f3ea0acab700916cd53
@@ -4,26 +4,19 @@ jobs:
4
4
  test:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.4, 2.5, 2.6, 2.7, jruby]
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@master
13
+ - uses: actions/checkout@v2
19
14
  - name: Set up Ruby
20
- uses: eregon/use-ruby-action@master
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
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ DisabledByDefault: true
3
+
4
+ Layout/IndentationStyle:
5
+ Enabled: true
6
+ EnforcedStyle: spaces
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ gemspec
5
5
 
6
6
  # workarond : simplecov 0.18 with cc-reporter is broken
7
7
  # https://github.com/codeclimate/test-reporter/issues/418
8
- gem 'simplecov', '~> 0.10', '< 0.18', require: false
8
+ gem 'simplecov', '~> 0.21', require: false
data/README.md CHANGED
@@ -103,7 +103,7 @@ 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/master/examples/)
106
+ * [examples in this repository](https://github.com/skoji/gepub/tree/main/examples/)
107
107
 
108
108
  ## INSTALL:
109
109
 
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  # also generates 'lib/gepub/book_add_item.rb'
16
16
  file 'lib/gepub/metadata_add.rb' => 'tools/generate_function.rb' do
17
- sh %Q(ruby tools/generate_function.rb)
17
+ sh %Q(ruby tools/generate_function.rb)
18
18
  end
19
19
 
20
20
  desc 'auto generate code'
@@ -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.11"
20
- s.add_runtime_dependency "rubyzip", "> 1.1.1", "< 2.3"
19
+ s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 1.12"
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
@@ -183,7 +183,14 @@ module GEPUB
183
183
 
184
184
  # write EPUB to stream specified by the argument.
185
185
  def write_to_epub_container(epub)
186
- epub.put_next_entry('mimetype', '', '', Zip::Entry::STORED)
186
+ mod_time = Zip::DOSTime.now
187
+ unless (last_mod = lastmodified).nil?
188
+ tm = last_mod.content
189
+ mod_time = Zip::DOSTime.local(tm.year, tm.month, tm.day, tm.hour, tm.min, tm.sec)
190
+ end
191
+
192
+ mimetype_entry = Zip::Entry.new(nil, 'mimetype', nil, nil, nil, nil, nil, nil, mod_time)
193
+ epub.put_next_entry(mimetype_entry, nil, nil, Zip::Entry::STORED)
187
194
  epub << "application/epub+zip"
188
195
 
189
196
  entries = {}
@@ -203,7 +210,8 @@ module GEPUB
203
210
 
204
211
  entries.sort_by { |k,_v| k }.each {
205
212
  |k,v|
206
- epub.put_next_entry(k)
213
+ zip_entry = Zip::Entry.new(nil, k, nil, nil, nil, nil, nil, nil, mod_time)
214
+ epub.put_next_entry(zip_entry)
207
215
  epub << v.force_encoding('us-ascii')
208
216
  }
209
217
  end
@@ -258,7 +266,7 @@ EOF
258
266
 
259
267
  def nav_doc(title = 'Table of Contents')
260
268
  # handle cascaded toc
261
- start_level = @toc && @toc[0][:level] || 1
269
+ start_level = @toc && !@toc.empty? && @toc[0][:level] || 1
262
270
  stacked_toc = {level: start_level, tocs: [] }
263
271
  @toc.inject(stacked_toc) do |current_stack, toc_entry|
264
272
  toc_entry_level = toc_entry[:level] || 1
@@ -308,6 +316,9 @@ EOF
308
316
  # build nav
309
317
  builder = Nokogiri::XML::Builder.new {
310
318
  |doc|
319
+ unless version.to_f < 3.0
320
+ doc.doc.create_internal_subset('html', nil, nil )
321
+ end
311
322
  doc.html('xmlns' => "http://www.w3.org/1999/xhtml",'xmlns:epub' => "http://www.idpf.org/2007/ops") {
312
323
  doc.head {
313
324
  doc.title title
@@ -420,7 +431,7 @@ EOF
420
431
  |_x,item|
421
432
  item.media_type == 'application/x-dtbncx+xml'
422
433
  }.size == 0
423
- if (@toc.size == 0)
434
+ if (@toc.size == 0 && !@package.spine.itemref_list.empty?)
424
435
  @toc << { :item => @package.manifest.item_list[@package.spine.itemref_list[0].idref] }
425
436
  end
426
437
  add_item('toc.ncx', id: 'ncx', content: StringIO.new(ncx_xml))
@@ -459,10 +470,12 @@ EOF
459
470
  item_attributes.each do |attr, val|
460
471
  next if val.nil?
461
472
  method_name = if attr == :toc_text
462
- attr.to_s
473
+ ""
474
+ elsif attr == :property
475
+ "add_"
463
476
  else
464
- "add_" + attr.to_s
465
- end
477
+ "set_"
478
+ end + attr.to_s
466
479
  item.send(method_name, val)
467
480
  end
468
481
  item
@@ -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
@@ -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'] = (@attributes['properties'] || []).reject {
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 form io or file to the item
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
- io = File.new(io_or_filename)
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$/
@@ -171,7 +171,7 @@ module GEPUB
171
171
  end
172
172
 
173
173
  def identifier_by_id(id)
174
- @content_nodes['identifier'].each {
174
+ (@content_nodes['identifier'] || []).each {
175
175
  |x|
176
176
  return x.content if x['id'] == id
177
177
  }
@@ -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
- class Metadata
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
- lang: nil, alternates: {}) {
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
- lang: nil, alternates: {})
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
- title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
62
- lang: lang, alternates: alternates)
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
- title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
69
- lang: nil, alternates: {})
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
- title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
80
- lang: lang, alternates: alternates)
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
- lang: nil, alternates: {})
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
- role = 'aut' if role.nil?
98
+ role = 'aut' if role.nil?
97
99
  meta = add_person('creator', content, id: id,
98
- title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
99
- lang: lang, alternates: alternates)
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
- lang: nil, alternates: {})
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
- title_type: title_type,identifier_type: identifier_type,display_seq: display_seq,file_as: file_as,group_position: group_position,role: role,
117
- lang: lang, alternates: alternates)
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
- def add_metadata(name, content, id: nil, itemclass: Meta,
123
- title_type: nil,identifier_type: nil,display_seq: nil,file_as: nil,group_position: nil,role: nil,
124
- lang: nil, alternates: {}
125
- )
126
- meta = add_metadata_internal(name, content, id: id, itemclass: itemclass)
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
- if refiner[:value]
129
- meta.refine(refiner[:name], refiner[:value])
130
- end
131
- end
132
- if lang
133
- meta.lang = lang
134
- end
135
- if alternates
136
- meta.add_alternates alternates
137
- end
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
- meta
140
- end
141
- end
141
+ meta
142
+ end
143
+ end
142
144
  end
@@ -1,4 +1,4 @@
1
1
  module GEPUB
2
2
  # GEPUB gem version
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.13"
4
4
  end
@@ -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
- refiner.sub('-', '_')
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
- class Metadata
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
- #{meta_attr_arguments_string}) {
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
- #{meta_attr_arguments_string})
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
- #{refiners_arguments_set_string},
109
- #{meta_attr_arguments_set_string})
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
- #{refiners_arguments_string},
116
- #{meta_attr_arguments_string})
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
- #{refiners_arguments_set_string},
127
- #{meta_attr_arguments_set_string})
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
- #{meta_attr_arguments_string})
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
- role = 'aut' if role.nil?
148
+ role = 'aut' if role.nil?
144
149
  meta = add_person('creator', content, id: id,
145
- #{refiners_arguments_set_string},
146
- #{meta_attr_arguments_set_string})
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
- #{meta_attr_arguments_string})
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
- #{refiners_arguments_set_string},
164
- #{meta_attr_arguments_set_string})
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
- def add_metadata(name, content, id: nil, itemclass: Meta,
170
- #{refiners_arguments_string},
171
- #{meta_attr_arguments_string}
172
- )
173
- meta = add_metadata_internal(name, content, id: id, itemclass: itemclass)
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
- if refiner[:value]
176
- meta.refine(refiner[:name], refiner[:value])
177
- end
178
- end
179
- if lang
180
- meta.lang = lang
181
- end
182
- if alternates
183
- meta.add_alternates alternates
184
- end
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
- meta
187
- end
188
- end
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.8
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOJIMA Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-10 00:00:00.000000000 Z
11
+ date: 2021-01-31 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.11'
22
+ version: '1.12'
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.11'
32
+ version: '1.12'
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.3'
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.3'
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:
@@ -92,6 +120,7 @@ files:
92
120
  - ".github/workflows/gempush.yml"
93
121
  - ".github/workflows/test.yml"
94
122
  - ".gitignore"
123
+ - ".rubocop.yml"
95
124
  - Gemfile
96
125
  - LICENSE.txt
97
126
  - README.md