gepub 1.0.0 → 1.0.1

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: 877e717beb44a21df9afc0a5427d5576a162e27dfad1cb562cb5b36bd2adcdc9
4
- data.tar.gz: 2ea4a07ae25bf2a85af439a1b49b429ce70961e958a8deba1882f2f46075ec55
3
+ metadata.gz: 88666fd75b90a68e50f920648d1a459b2beb59bc47aa9a1ca3ef9fb39dc7b746
4
+ data.tar.gz: c455873460659bc89b70f725129bf462ae5478beb68fb8be99de2ba04c49e4dc
5
5
  SHA512:
6
- metadata.gz: 7e58686f88c0d9e80dd4db6c3749a571ba53b2b4d92579fde57af40802438d64e344629d59d2d6667da83eca35bf2202616ac4097e2c5caca7bc833ad188874e
7
- data.tar.gz: 59065a6eea1f705bda13722f677928730e7b23565dbd778a1c9174e3f0919880f9a504c90f0ba86c3d75bdeb914207473f13f6ad64596420d382090d5517f4c1
6
+ metadata.gz: d121c4ea9dbabaa8e61ddebf98c79a63d6358e25c49c46d3692a36a1f97c2e0adeba226ae1e7455dddc1aaa9ef2c674336991d38d8a04d3cca3fa931a0892973
7
+ data.tar.gz: 8a4ffe1aa6c98483f9cd64637145802911326a7ef5d766d9526cbbcfb7a62835eefc2d52fa6ac51421f39b8d4f12a7fdf0f2b221bcc2678c5dac058072aec1cd
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.5
4
- - 2.5.3
3
+ - 2.5.3
4
+ - 2.6.0
5
5
  script: bundle exec rake spec
data/README.md CHANGED
@@ -22,7 +22,7 @@ If you are using GEPUB::Builder and do not like its behaviour(e.g. the block ins
22
22
 
23
23
  ## SYNOPSIS:
24
24
 
25
- ### Builder Example
25
+ ### Example
26
26
 
27
27
  ```ruby
28
28
  require 'rubygems'
data/gepub.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 1.9"
21
+ s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 1.11"
22
22
  s.add_development_dependency "rake"
23
23
  s.add_development_dependency "rspec"
24
24
  s.add_runtime_dependency "rubyzip", ">= 1.1.1"
data/lib/gepub/book.rb CHANGED
@@ -9,7 +9,6 @@ require 'fileutils'
9
9
  # namespace for gepub library.
10
10
  # The core class is GEPUB::Book. It holds metadata and contents of EPUB file. metadata and contents can be accessed
11
11
  # through GEPUB::Meta and GEPUB::Item.
12
- # For generating EPUB file, use GEPUB::Builder.
13
12
  # GEPUB::Item holds information and data of resources like xhtml text, css, scripts, images, videos, etc.
14
13
  # GEPUB::Meta holds metadata(title, creator, publisher, etc.) with its information (alternate script, display sequence, etc.)
15
14
 
@@ -18,10 +17,6 @@ module GEPUB
18
17
  #
19
18
  # It can generate and parse EPUB2/EPUB3 files.
20
19
  #
21
- # If you want to generate a new EPUB file, consider using GEPUB::Builder instead
22
- # of using Book directly.
23
- # Builder is a wrapper class of Book specialized for generating EPUB.
24
- #
25
20
  # Book delegates many methods to objects in other class, so you can't find
26
21
  # them in Book#methods or in ri/rdoc documentation. Their descriptions are below.
27
22
  #
@@ -93,7 +88,7 @@ module GEPUB
93
88
  def self.rootfile_from_container(rootfile)
94
89
  doc = Nokogiri::XML::Document.parse(rootfile)
95
90
  ns = doc.root.namespaces
96
- defaultns = ns.select{ |name, value| value == CONTAINER_NS }.to_a[0][0]
91
+ defaultns = ns.select{ |_name, value| value == CONTAINER_NS }.to_a[0][0]
97
92
  doc.css("#{defaultns}|rootfiles > #{defaultns}|rootfile")[0]['full-path']
98
93
  end
99
94
 
@@ -200,13 +195,13 @@ module GEPUB
200
195
  entries['META-INF/container.xml'] = container_xml
201
196
  entries[@package.path] = opf_xml
202
197
  @package.manifest.item_list.each {
203
- |k, item|
198
+ |_k, item|
204
199
  if item.content != nil
205
200
  entries[@package.contents_prefix + item.href] = item.content
206
201
  end
207
202
  }
208
203
 
209
- entries.sort_by { |k,v| k }.each {
204
+ entries.sort_by { |k,_v| k }.each {
210
205
  |k,v|
211
206
  epub.put_next_entry(k)
212
207
  epub << v.force_encoding('us-ascii')
@@ -411,7 +406,7 @@ EOF
411
406
  def cleanup_for_epub2
412
407
  if version.to_f < 3.0 || @package.epub_backward_compat
413
408
  if @package.manifest.item_list.select {
414
- |x,item|
409
+ |_x,item|
415
410
  item.media_type == 'application/x-dtbncx+xml'
416
411
  }.size == 0
417
412
  if (@toc.size == 0)
@@ -426,14 +421,14 @@ EOF
426
421
  @package.metadata.modified_now
427
422
 
428
423
  if @package.manifest.item_list.select {
429
- |href, item|
424
+ |_href, item|
430
425
  (item.properties||[]).member? 'nav'
431
426
  }.size == 0
432
427
  generate_nav_doc
433
428
  end
434
429
 
435
430
  @package.spine.remove_with_idlist @package.manifest.item_list.map {
436
- |href, item|
431
+ |_href, item|
437
432
  item.fallback
438
433
  }.reject(&:nil?)
439
434
  end
data/lib/gepub/builder.rb CHANGED
@@ -3,6 +3,8 @@ module GEPUB
3
3
  #
4
4
  # Builder is a wrapper class of Book. It provides DSL to create new EPUB file.
5
5
  #
6
+ # * Builder is obsolete on v0.7 and after. We will continue to support GEPUB::Builder works fine on version 1.x, but Builder will not be updated any more. For example, landmarks are not supported with Builder.
7
+ #
6
8
  # = Synopsys
7
9
  # # -*- coding: utf-8 -*-
8
10
  # # GEPUB::Builder example.
@@ -179,7 +181,7 @@ module GEPUB
179
181
  end
180
182
  end
181
183
 
182
- def initialize(attributes = {}, &block)
184
+ def initialize(_attributes = {}, &block)
183
185
  @last_defined_item = nil
184
186
  @book = Book.new
185
187
  instance_eval(&block)
@@ -17,7 +17,7 @@ module GEPUB
17
17
  @content = date
18
18
  end
19
19
 
20
- def to_s(locale = nil)
20
+ def to_s(_locale = nil)
21
21
  # date type don't have alternate scripts.
22
22
  @content.utc.iso8601
23
23
  end
data/lib/gepub/item.rb CHANGED
@@ -9,7 +9,7 @@ module GEPUB
9
9
  attr_accessor :content
10
10
  def self.create(parent, attributes = {})
11
11
  Item.new(attributes['id'], attributes['href'], attributes['media-type'], parent,
12
- attributes.reject { |k,v| ['id','href','media-type'].member?(k) })
12
+ attributes.reject { |k,_v| ['id','href','media-type'].member?(k) })
13
13
  end
14
14
 
15
15
  #
@@ -152,7 +152,7 @@ module GEPUB
152
152
  def to_xml(builder, opf_version = '3.0')
153
153
  attr = @attributes.dup
154
154
  if opf_version.to_f < 3.0
155
- attr.reject!{ |k,v| k == 'properties' }
155
+ attr.reject!{ |k,_v| k == 'properties' }
156
156
  end
157
157
  if !attr['properties'].nil?
158
158
  attr['properties'] = attr['properties'].uniq.join(' ')
@@ -62,7 +62,7 @@ module GEPUB
62
62
  def to_xml(builder)
63
63
  builder.manifest(@attributes) {
64
64
  @items.each {
65
- |itemid, item|
65
+ |_itemid, item|
66
66
  item.to_xml(builder, @opf_version)
67
67
  }
68
68
  }
data/lib/gepub/meta.rb CHANGED
@@ -116,7 +116,7 @@ module GEPUB
116
116
 
117
117
  # using __send__ to parametarize Namespace and content.
118
118
  target = ns.nil? || @name == 'meta' ? builder : builder[ns]
119
- attr = @attributes.reject{|k,v| v.nil?}.merge(additional_attr)
119
+ attr = @attributes.reject{|_k,v| v.nil?}.merge(additional_attr)
120
120
  if @content.nil?
121
121
  target.__send__(@name, attr)
122
122
  else
@@ -126,7 +126,7 @@ module GEPUB
126
126
  if @refiners.size > 0 && opf_version.to_f >= 3.0
127
127
  additional_attr['refines'] = "##{@attributes['id']}"
128
128
  @refiners.each {
129
- |k, ref_list|
129
+ |_k, ref_list|
130
130
  ref_list.each {
131
131
  |ref|
132
132
  ref.to_xml(builder, id_pool, nil, additional_attr)
@@ -79,7 +79,7 @@ module GEPUB
79
79
  def to_xml(builder)
80
80
  builder.metadata(@namespaces) {
81
81
  @content_nodes.each {
82
- |name, list|
82
+ |_name, list|
83
83
  list.each {
84
84
  |meta|
85
85
  meta.to_xml(builder, @id_pool, ns_prefix(DC_NS), nil, @opf_version)
data/lib/gepub/mime.rb CHANGED
@@ -42,7 +42,7 @@ module GEPUB
42
42
  #guess mediatype by mime type mask
43
43
  def self.guess_mediatype(href)
44
44
  ext = File.extname(href)
45
- @@mime_types_compiled.select { |pattern, mime| ext =~ pattern }.values[0]
45
+ @@mime_types_compiled.select { |pattern, _mime| ext =~ pattern }.values[0]
46
46
  end
47
47
 
48
48
  end
data/lib/gepub/package.rb CHANGED
@@ -249,7 +249,7 @@ module GEPUB
249
249
  }.length == 0
250
250
 
251
251
  @manifest.item_list.each {
252
- |k, item|
252
+ |_k, item|
253
253
  if item.properties && item.properties.member?('cover-image')
254
254
  @metadata.add_oldstyle_meta(nil, 'name' => 'cover', 'content' => item.id)
255
255
  end
@@ -45,12 +45,12 @@ module GEPUB
45
45
  raise "can't specify multiple files on file keyword" if Hash === val && val.length > 1
46
46
 
47
47
  @file_preprocess.each {
48
- |k,p|
48
+ |_k,p|
49
49
  p.call
50
50
  }
51
51
  @last_defined_item = ResourceItem.new(create_one_file(val))
52
52
  @file_postprocess.each {
53
- |k,p|
53
+ |_k,p|
54
54
  p.call
55
55
  }
56
56
  end
@@ -58,7 +58,7 @@ module GEPUB
58
58
  def files(*arg)
59
59
  arg = arg[0] if arg.size == 1 && Hash === arg[0]
60
60
  @files_preprocess.each {
61
- |k,p|
61
+ |_k,p|
62
62
  p.call
63
63
  }
64
64
  @last_defined_item = arg.map {
@@ -66,7 +66,7 @@ module GEPUB
66
66
  ResourceItem.new(create_one_file(val))
67
67
  }
68
68
  @files_postprocess.each {
69
- |k,p|
69
+ |_k,p|
70
70
  p.call
71
71
  }
72
72
  end
@@ -5,7 +5,7 @@ class SortedArray < Array
5
5
  self.sort!() &sort_by
6
6
  end
7
7
 
8
- def insert(i, v)
8
+ def insert(_i, v)
9
9
  insert_before = index(find { |x| @sort_by.call(x, v) == 1 })
10
10
  super(insert_before ? insert_before : -1, v)
11
11
  end
data/lib/gepub/spine.rb CHANGED
@@ -6,7 +6,7 @@ module GEPUB
6
6
  attr_accessor :opf_version
7
7
  class Itemref
8
8
  def self.create(parent, attributes = {})
9
- Itemref.new(attributes['idref'], parent, attributes.reject{|k,v| k == 'idref'})
9
+ Itemref.new(attributes['idref'], parent, attributes.reject{|k,_v| k == 'idref'})
10
10
  end
11
11
 
12
12
  def initialize(idref, parent = nil, attributes = {})
@@ -70,7 +70,7 @@ module GEPUB
70
70
  def to_xml(builder, opf_version)
71
71
  attr = @attributes.dup
72
72
  if opf_version.to_f < 3.0
73
- attr.reject!{ |k,v| k == 'properties' }
73
+ attr.reject!{ |k,_v| k == 'properties' }
74
74
  end
75
75
  if !attr['properties'].nil?
76
76
  attr['properties'] = attr['properties'].join(' ')
data/lib/gepub/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module GEPUB
2
- # GEPUB gem version
3
- VERSION = "1.0.0"
2
+ # GEPUB gem version
3
+ VERSION = "1.0.1"
4
4
  end
data/spec/package_spec.rb CHANGED
@@ -43,7 +43,7 @@ describe GEPUB::Package do
43
43
  package['xml:lang'] = 'ja'
44
44
 
45
45
  # metadata add: style 1
46
- package.metadata.add_title('EPUB3 Sample', nil, GEPUB::TITLE_TYPE::MAIN) {
46
+ package.metadata.add_title('EPUB3 Sample', title_type: GEPUB::TITLE_TYPE::MAIN) {
47
47
  |title|
48
48
  title.display_seq = 1
49
49
  title.file_as = 'Sample EPUB3'
@@ -53,7 +53,7 @@ describe GEPUB::Package do
53
53
  'th' => 'EPUB3 ตัวอย่าง (ญี่ปุ่น)')
54
54
  }
55
55
  # metadata add: style2
56
- package.metadata.add_title('これでEPUB3もばっちり', nil, GEPUB::TITLE_TYPE::SUBTITLE).display_seq(2).add_alternates('en' => 'you need nothing but this book!')
56
+ package.metadata.add_title('これでEPUB3もばっちり', title_type: GEPUB::TITLE_TYPE::SUBTITLE).display_seq(2).add_alternates('en' => 'you need nothing but this book!')
57
57
  package.metadata.add_creator('小嶋智').display_seq(1).add_alternates('en' => 'KOJIMA Satoshi')
58
58
  package.metadata.add_contributor('電書部').display_seq(1).add_alternates('en' => 'Denshobu')
59
59
  package.metadata.add_contributor('アサガヤデンショ').display_seq(2).add_alternates('en' => 'Asagaya Densho')
@@ -117,7 +117,7 @@ describe GEPUB::Package do
117
117
  package['xml:lang'] = 'ja'
118
118
 
119
119
  # metadata add: style 1
120
- package.metadata.add_title('EPUB3 Sample', nil, GEPUB::TITLE_TYPE::MAIN) {
120
+ package.metadata.add_title('EPUB3 Sample', title_type: GEPUB::TITLE_TYPE::MAIN) {
121
121
  |title|
122
122
  title.display_seq = 1
123
123
  title.file_as = 'Sample EPUB3'
@@ -127,7 +127,7 @@ describe GEPUB::Package do
127
127
  'th' => 'EPUB3 ตัวอย่าง (ญี่ปุ่น)')
128
128
  }
129
129
  # metadata add: style2
130
- package.metadata.add_title('これでEPUB3もばっちり', nil, GEPUB::TITLE_TYPE::SUBTITLE).display_seq(2).add_alternates('en' => 'you need nothing but this book!')
130
+ package.metadata.add_title('これでEPUB3もばっちり', title_type: GEPUB::TITLE_TYPE::SUBTITLE).display_seq(2).add_alternates('en' => 'you need nothing but this book!')
131
131
  package.metadata.add_creator('小嶋智').display_seq(1).add_alternates('en' => 'KOJIMA Satoshi')
132
132
  package.metadata.add_contributor('電書部').display_seq(1).add_alternates('en' => 'Denshobu')
133
133
  package.metadata.add_contributor('アサガヤデンショ').display_seq(2).add_alternates('en' => 'Asagaya Densho')
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOJIMA Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2019-01-15 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.9'
22
+ version: '1.11'
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.9'
32
+ version: '1.11'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -185,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubyforge_project: gepub
189
- rubygems_version: 2.7.6
188
+ rubygems_version: 3.0.1
190
189
  signing_key:
191
190
  specification_version: 4
192
191
  summary: a generic EPUB library for Ruby.