gepub 1.0.14 → 1.0.15

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: 3d719e4054e3b1ab330d8af93992edfc35ebaa355878ee0c623709ddff612f3d
4
- data.tar.gz: d20aa19004c3591f7e17a5275fd957b5b1650514a8206ffe301e162fbec2a4af
3
+ metadata.gz: 19218e13519e47532dee8d0a4f1c45a3acaa65dd105b4fcd1b09774f9f482bd6
4
+ data.tar.gz: abeb56bc8baa0d505f75af8403eb4e59a86aa386aeac83040c2dcf9fc2f5b45e
5
5
  SHA512:
6
- metadata.gz: 9070b08171d351372c4a46e0ac489d2a077f3dd106d52346358a895a4ac9036e9162699e7f72124381a7d53903c96dcaa438ef6a31d2b0d1832267cff4ba4b8a
7
- data.tar.gz: c9914d0a1340504905c09b2afc591a6aa99c15e5ba219958dcbcb56fdbdb2caa5702950ef614b97977521088e0e30b068eae1098c048a946e6423eeb2e6dee9b
6
+ metadata.gz: d1c20a5567c1033fceafbe660f8bc2b227b3a269125d1da4b58d2183fb13f24a4f7e56242100e37b662f03a17ebb744fc686151782ef2d8fb36c9d94ef39275b
7
+ data.tar.gz: 6dcf08c29ca933edba399cd1ffbb001196d8d8ef74cb62bcb8619135eddec743975b1654b5c3ce57342d91da7c8166949057591da1d3e429c1f326967544077e
data/gepub.gemspec CHANGED
@@ -16,7 +16,7 @@ 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.13"
19
+ s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 2.0"
20
20
  s.add_runtime_dependency "rubyzip", "> 1.1.1", "< 2.4"
21
21
  s.add_development_dependency "epubcheck-ruby"
22
22
  s.add_development_dependency "rake"
@@ -3,6 +3,8 @@ require 'nokogiri'
3
3
  module GEPUB
4
4
  class Bindings
5
5
  include XMLUtil
6
+ include InspectMixin
7
+
6
8
  class MediaType
7
9
  attr_accessor :handler, :media_type
8
10
  def initialize(handler, media_type)
data/lib/gepub/book.rb CHANGED
@@ -79,6 +79,8 @@ module GEPUB
79
79
  # set page-proression-direction attribute to spine.
80
80
 
81
81
  class Book
82
+ include InspectMixin
83
+
82
84
  MIMETYPE='mimetype'
83
85
  MIMETYPE_CONTENTS='application/epub+zip'
84
86
  CONTAINER='META-INF/container.xml'
@@ -0,0 +1,26 @@
1
+ module GEPUB
2
+ module InspectMixin
3
+ def inspect
4
+ result = instance_variables.each
5
+ .with_object({}) { |name, h| h[name] = instance_variable_get(name) }
6
+ .reject { |name, value| value.nil? }
7
+ .map { |name, value|
8
+ case value
9
+ when true, false, Symbol, Numeric, Array, Hash
10
+ "#{name}=#{value.inspect}"
11
+ when String
12
+ if value.length > 80
13
+ "#{name}=(omitted)"
14
+ else
15
+ "#{name}=#{value.inspect}"
16
+ end
17
+ else
18
+ "#{name}=#<#{value.class.name}>"
19
+ end
20
+ }
21
+ .join(' ')
22
+
23
+ "#<#{self.class.name} " + result + '>'
24
+ end
25
+ end
26
+ end
data/lib/gepub/item.rb CHANGED
@@ -6,6 +6,8 @@ module GEPUB
6
6
  # #id, #id=, #set_id, #href, #href=, #set_href, #media_type, #media_type=, #set_media_type,
7
7
  # #fallback, #fallback=, #set_fallback, #media_overlay, #media_overlay=, #set_media_overlay
8
8
  class Item
9
+ include InspectMixin
10
+
9
11
  attr_accessor :content
10
12
  def self.create(parent, attributes = {})
11
13
  Item.new(attributes['id'], attributes['href'], attributes['media-type'], parent,
@@ -46,12 +48,14 @@ module GEPUB
46
48
  media_type
47
49
  end
48
50
 
49
- def [](x)
50
- @attributes[x]
51
+ # get +attribute+
52
+ def [](attribute)
53
+ @attributes[attribute]
51
54
  end
52
55
 
53
- def []=(x,y)
54
- @attributes[x] = y
56
+ # set +attribute+
57
+ def []=(attribute, value)
58
+ @attributes[attribute] = value
55
59
  end
56
60
 
57
61
  # add value to properties attribute.
@@ -3,6 +3,8 @@ require 'nokogiri'
3
3
  module GEPUB
4
4
  class Manifest
5
5
  include XMLUtil
6
+ include InspectMixin
7
+
6
8
  attr_accessor :opf_version
7
9
  def self.parse(manifest_xml, opf_version = '3.0', id_pool = Package::IDPool.new)
8
10
  Manifest.new(opf_version, id_pool) {
data/lib/gepub/meta.rb CHANGED
@@ -16,12 +16,14 @@ module GEPUB
16
16
  @parent.register_meta(self) unless @parent.nil?
17
17
  end
18
18
 
19
- def [](x)
20
- @attributes[x]
19
+ # get +attribute+
20
+ def [](attribute)
21
+ @attributes[attribute]
21
22
  end
22
23
 
23
- def []=(x,y)
24
- @attributes[x] = y
24
+ # set +attribute+
25
+ def []=(attribute, value)
26
+ @attributes[attribute] = value
25
27
  end
26
28
 
27
29
  def refiner_list(name)
@@ -18,6 +18,8 @@ module GEPUB
18
18
  end
19
19
  end
20
20
  include XMLUtil, DSLUtil
21
+ include InspectMixin
22
+
21
23
  attr_accessor :opf_version
22
24
  # parse metadata element. metadata_xml should be Nokogiri::XML::Node object.
23
25
  def self.parse(metadata_xml, opf_version = '3.0', id_pool = Package::IDPool.new)
data/lib/gepub/package.rb CHANGED
@@ -6,6 +6,8 @@ module GEPUB
6
6
  # Holds data in opf file.
7
7
  class Package
8
8
  include XMLUtil, DSLUtil
9
+ include InspectMixin
10
+
9
11
  extend Forwardable
10
12
  attr_accessor :path, :metadata, :manifest, :spine, :bindings, :epub_backward_compat, :contents_prefix, :prefixes
11
13
  def_delegators :@manifest, :item_by_href
@@ -142,15 +144,16 @@ module GEPUB
142
144
  })
143
145
  }
144
146
 
145
- def [](x)
146
- @attributes[x]
147
+ # get +attribute+
148
+ def [](attribute)
149
+ @attributes[attribute]
147
150
  end
148
151
 
149
- def []=(k,v)
150
- @attributes[k] = v
152
+ # set +attribute+
153
+ def []=(attribute, value)
154
+ @attributes[attribute] = value
151
155
  end
152
156
 
153
-
154
157
  def identifier(identifier=UNASSIGNED)
155
158
  if unassigned?(identifier)
156
159
  @metadata.identifier_by_id(unique_identifier)
data/lib/gepub/spine.rb CHANGED
@@ -3,6 +3,8 @@ require 'nokogiri'
3
3
  module GEPUB
4
4
  class Spine
5
5
  include XMLUtil
6
+ include InspectMixin
7
+
6
8
  attr_accessor :opf_version
7
9
  class Itemref
8
10
  def self.create(parent, attributes = {})
@@ -26,14 +28,16 @@ module GEPUB
26
28
  define_method(methodbase) { @attributes[name] }
27
29
  }
28
30
 
29
- def [](x)
30
- @attributes[x]
31
+ # get +attribute+
32
+ def [](attribute)
33
+ @attributes[attribute]
31
34
  end
32
35
 
33
- def []=(x,y)
34
- @attributes[x] = y
36
+ # set +attribute+
37
+ def []=(attribute, value)
38
+ @attributes[attribute] = value
35
39
  end
36
-
40
+
37
41
  def add_property(property)
38
42
  (@attributes['properties'] ||=[]) << property
39
43
  end
data/lib/gepub/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module GEPUB
2
2
  # GEPUB gem version
3
- VERSION = "1.0.14"
3
+ VERSION = "1.0.15"
4
4
  end
data/lib/gepub.rb CHANGED
@@ -4,6 +4,7 @@ end if RUBY_VERSION < "2.7" && !(defined? ruby2_keywords)
4
4
  require 'gepub/version'
5
5
  require 'gepub/dsl_util'
6
6
  require 'gepub/xml_util'
7
+ require 'gepub/inspect_mixin'
7
8
  require 'gepub/meta'
8
9
  require 'gepub/datemeta'
9
10
  require 'gepub/meta_array'
@@ -1,3 +1,4 @@
1
+ require_relative '../lib/gepub/inspect_mixin.rb'
1
2
  require_relative '../lib/gepub/item.rb'
2
3
  attrs = GEPUB::Item::ATTRIBUTES.select do |attr|
3
4
  attr != 'href'
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.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOJIMA Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2021-10-09 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.13'
22
+ version: '2.0'
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.13'
32
+ version: '2.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rubyzip
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +143,7 @@ files:
143
143
  - lib/gepub/builder_mixin.rb
144
144
  - lib/gepub/datemeta.rb
145
145
  - lib/gepub/dsl_util.rb
146
+ - lib/gepub/inspect_mixin.rb
146
147
  - lib/gepub/item.rb
147
148
  - lib/gepub/manifest.rb
148
149
  - lib/gepub/meta.rb