gepub 1.0.10 → 1.0.11

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: b78a10be8680f2fe6e66a12950adc4b3c326bc4f4232630db8da6a66281a4cbb
4
- data.tar.gz: 7bd76c8e13b4540ac8d7fae3f7fd79a85c9eafbdd4c24386d1033deaf8bf365b
3
+ metadata.gz: 294cefe070bfd2c4a87e0fd46c45f10f08f75857045ad62ed02b83694ca9e9ae
4
+ data.tar.gz: 1df169f042577cd0ae74db3565e92f7f70b0b87fd9bafd7de5e3802574ab1578
5
5
  SHA512:
6
- metadata.gz: 7981683e1eef0e903341b0af576bc47cfe415aaec26205aa90c98da86a763317cf2fa5602adda23065964ecd8c9f0287176bd3321763ca174dfbea663f53de25
7
- data.tar.gz: 0bf3e8c606da8ec39e21eeb2f992a238084ef45b3ab3f722389a21d47bd37e47af4c89d6f818dbe73805a77813fe4c21df17acee8624c0946d2bc3dc6e9b1333
6
+ metadata.gz: 403d05c6d0a0d0121526d5ce92c8e95dfcb11aae052c84af6bec3303f8039b56852cc64fd4e1d171c715ad2b728a6eee2cee6043cedca2576999c7ccf1f35ae8
7
+ data.tar.gz: 89e1b455c6d1653fc4ec60ada97da3da50d508260ce5309ca3ec3aceabecd528b1941723ac5a4e594ec0bb34ea99d7ef64a5c4c573f22d5dc7627ea9e8d4b3f0
@@ -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
@@ -428,7 +428,7 @@ EOF
428
428
  |_x,item|
429
429
  item.media_type == 'application/x-dtbncx+xml'
430
430
  }.size == 0
431
- if (@toc.size == 0)
431
+ if (@toc.size == 0 && !@package.spine.itemref_list.empty?)
432
432
  @toc << { :item => @package.manifest.item_list[@package.spine.itemref_list[0].idref] }
433
433
  end
434
434
  add_item('toc.ncx', id: 'ncx', content: StringIO.new(ncx_xml))
@@ -467,10 +467,12 @@ EOF
467
467
  item_attributes.each do |attr, val|
468
468
  next if val.nil?
469
469
  method_name = if attr == :toc_text
470
- attr.to_s
470
+ ""
471
+ elsif attr == :property
472
+ "add_"
471
473
  else
472
- "add_" + attr.to_s
473
- end
474
+ "set_"
475
+ end + attr.to_s
474
476
  item.send(method_name, val)
475
477
  end
476
478
  item
@@ -3,18 +3,18 @@ module GEPUB
3
3
  # add an item(i.e. html, images, audios, etc) to Book.
4
4
  # the added item will be referenced by the first argument in the EPUB container.
5
5
  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,
6
+ id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
7
7
  attributes: {})
8
8
  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)
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,property: property }, attributes: attributes, ordered: false)
10
10
  end
11
11
 
12
12
  # same as add_item, but the item will be added to spine of the EPUB.
13
13
  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,
14
+ id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
15
15
  attributes: {})
16
16
  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)
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,property: property }, attributes: attributes, ordered: true)
18
18
  end
19
19
  end
20
20
  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']
@@ -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,4 +1,4 @@
1
1
  module GEPUB
2
2
  # GEPUB gem version
3
- VERSION = "1.0.10"
3
+ VERSION = "1.0.11"
4
4
  end
@@ -4,7 +4,8 @@ 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)
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.10
4
+ version: 1.0.11
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-12 00:00:00.000000000 Z
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri