gepub 1.0.14 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d719e4054e3b1ab330d8af93992edfc35ebaa355878ee0c623709ddff612f3d
4
- data.tar.gz: d20aa19004c3591f7e17a5275fd957b5b1650514a8206ffe301e162fbec2a4af
3
+ metadata.gz: 93cb58ca825f4f30efeb8f1ce191ccf9bbb2e74d32f9cfd77f37dedb85cc7a3e
4
+ data.tar.gz: da3618e21ad20a7f6a12c4d52fe43d1159ecdd378a5eb4bae39d1eb2558fb605
5
5
  SHA512:
6
- metadata.gz: 9070b08171d351372c4a46e0ac489d2a077f3dd106d52346358a895a4ac9036e9162699e7f72124381a7d53903c96dcaa438ef6a31d2b0d1832267cff4ba4b8a
7
- data.tar.gz: c9914d0a1340504905c09b2afc591a6aa99c15e5ba219958dcbcb56fdbdb2caa5702950ef614b97977521088e0e30b068eae1098c048a946e6423eeb2e6dee9b
6
+ metadata.gz: 0ba5fbbd7590739ef20d73af2cc3b50811c0ba330959cc784a6246bb13dbd249d32a0c9fbe3c31adb15ae4e4b9c69a7c7988cc5c62b8b6e65cdf9c105eed85d6
7
+ data.tar.gz: bb66bd6e2f564ed780e0417b91e43993fb0ece0fc938095a31d10fdfff56b9c77d290df812e3ff94feb64256ac1b21e06aa2a36fb29553b6145ee89644c2f684
@@ -11,10 +11,10 @@ jobs:
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@master
14
- - name: Set up Ruby 2.6
14
+ - name: Set up Ruby
15
15
  uses: actions/setup-ruby@v1
16
16
  with:
17
- ruby-version: 2.6.x
17
+ ruby-version: 3.1.x
18
18
 
19
19
  - name: Publish to GPR
20
20
  run: |
@@ -4,13 +4,13 @@ jobs:
4
4
  test:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.5, 2.6, 2.7, 3.0, jruby]
7
+ ruby: [2.7, 3.0, 3.1, 3.2, 3.3, jruby]
8
8
  platform: [ubuntu-latest, macos-latest, windows-latest]
9
9
  runs-on: ${{ matrix.platform }}
10
10
  env:
11
11
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v4
14
14
  - name: Set up Ruby
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
@@ -18,12 +18,12 @@ jobs:
18
18
  - name: setup gems
19
19
  run: bundle install --jobs 4 --retry 3
20
20
  - name: run test and publish code coverage
21
- if: runner.os == 'Linux' && matrix.ruby == '2.7' && env.CC_TEST_REPORTER_ID != ''
22
- uses: paambaati/codeclimate-action@v2.3.0
21
+ if: runner.os == 'Linux' && matrix.ruby == '3.3' && env.CC_TEST_REPORTER_ID != ''
22
+ uses: paambaati/codeclimate-action@v5.0.0
23
23
  env:
24
24
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
25
25
  with:
26
26
  coverageCommand: bundle exec rake spec
27
27
  - name: run test
28
- if: runner.os != 'Linux' || matrix.ruby != '2.7' || env.CC_TEST_REPORTER_ID == ''
28
+ if: runner.os != 'Linux' || matrix.ruby != '3.3' || env.CC_TEST_REPORTER_ID == ''
29
29
  run: bundle exec rake spec
data/.gitignore CHANGED
@@ -19,8 +19,6 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
- testepub*.epub
23
- example_test*.epub
24
22
 
25
23
  ## BUNDLER
26
24
  Gemfile.lock
data/Gemfile CHANGED
@@ -3,6 +3,4 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in gepub.gemspec
4
4
  gemspec
5
5
 
6
- # workarond : simplecov 0.18 with cc-reporter is broken
7
- # https://github.com/codeclimate/test-reporter/issues/418
8
6
  gem 'simplecov', '~> 0.21', require: false
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/main/frames
8
+ * https://rubydoc.info/github/skoji/gepub
9
9
 
10
10
  ## DESCRIPTION:
11
11
 
@@ -13,12 +13,12 @@ a generic EPUB parser/generator library.
13
13
 
14
14
  ## FEATURES/PROBLEMS:
15
15
 
16
- * GEPUB::Book provides functionality to create EPUB file, and parsing EPUB files
16
+ * GEPUB::Book provides functionality to create EPUB files and parse EPUB files
17
17
  * Handle every metadata in EPUB2/EPUB3.
18
18
 
19
19
  * See [issues](https://github.com/skoji/gepub/issues/) for known problems.
20
20
 
21
- If you are using GEPUB::Builder and do not like its behaviour(e.g. the block inside is evaluated as inside the Builder instance), please consider using GEPUB::Book directly.
21
+ If you are using GEPUB::Builder and do not like its behavior (e.g., GEPUB::Builder evaluates the block as inside the Builder instance), consider using GEPUB::Book directly.
22
22
 
23
23
  ## SYNOPSIS:
24
24
 
@@ -98,9 +98,9 @@ book.ordered {
98
98
  }
99
99
  epubname = File.join(File.dirname(__FILE__), 'example_test.epub')
100
100
 
101
- # if you do not specify your own nav document with add_item,
102
- # simple navigation text will be generated in generate_epub.
103
- # auto-generated nav file will not appear on spine.
101
+ # if you do not specify a nav document with add_item,
102
+ # generate_epub will generate simple navigation text.
103
+ # auto-generated nav file will not appear on the spine.
104
104
  book.generate_epub(epubname)
105
105
  ```
106
106
  * [examples in this repository](https://github.com/skoji/gepub/tree/main/examples/)
@@ -112,4 +112,3 @@ book.generate_epub(epubname)
112
112
  ## DONATE:
113
113
 
114
114
  * Bitcoin Address: `1M69AwoxpgPZsp5KStLUEjP7so5dHVfDTH`
115
-
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'
@@ -100,14 +102,14 @@ module GEPUB
100
102
  package = nil
101
103
  package_path = nil
102
104
  book = nil
103
- Zip::InputStream::open(io) {
104
- |zis|
105
- package, package_path = parse_container(zis, files)
105
+ Zip::File.open_buffer(io) do
106
+ |zip_file|
107
+ package, package_path = parse_container(zip_file, files)
106
108
  check_consistency_of_package(package, package_path)
107
109
  parse_files_into_package(files, package)
108
110
  book = Book.new(package.path)
109
111
  book.instance_eval { @package = package; @optional_files = files }
110
- }
112
+ end
111
113
  book
112
114
  end
113
115
 
@@ -377,12 +379,12 @@ EOF
377
379
  end
378
380
 
379
381
  private
380
- def self.parse_container(zis, files)
382
+ def self.parse_container(zip_file, files)
381
383
  package_path = nil
382
384
  package = nil
383
- while entry = zis.get_next_entry
385
+ zip_file.each do |entry|
384
386
  if !entry.directory?
385
- files[entry.name] = zis.read
387
+ files[entry.name] = zip_file.read(entry)
386
388
  case entry.name
387
389
  when MIMETYPE then
388
390
  if files[MIMETYPE] != MIMETYPE_CONTENTS
@@ -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)
@@ -138,7 +138,7 @@ module GEPUB
138
138
  meta.add_alternates alternates
139
139
  end
140
140
  yield meta if block_given?
141
- meta
142
- end
141
+ meta
143
142
  end
143
+ end
144
144
  end
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.16"
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'
@@ -188,9 +189,9 @@ module GEPUB
188
189
  meta.add_alternates alternates
189
190
  end
190
191
  yield meta if block_given?
191
- meta
192
- end
192
+ meta
193
193
  end
194
+ end
194
195
  end
195
196
  EOF
196
197
 
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.16
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: 2024-04-27 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
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  - !ruby/object:Gem::Version
178
179
  version: '0'
179
180
  requirements: []
180
- rubygems_version: 3.0.3.1
181
+ rubygems_version: 3.3.26
181
182
  signing_key:
182
183
  specification_version: 4
183
184
  summary: a generic EPUB library for Ruby.