gepub 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +14 -6
- data/Gemfile +4 -1
- data/gepub.gemspec +2 -1
- data/lib/gepub/book.rb +8 -4
- data/lib/gepub/metadata.rb +10 -9
- data/lib/gepub/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6279f47052dbbe90014ca6653faf663043872dabd364f3cabadc9c2e82ae8262
|
4
|
+
data.tar.gz: 79e0d32c97a46879c7b6597c48bbeb1253e96bd89c3d5f2c04d307d35c544118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdb6373fc9a484abfd0c041fc989313b6c3033d6c192fd0688b80597fefc1f64aa49cecd56539c67aed9669f1b623ad2c500d046d47bda02853ffb3f6d3dd525
|
7
|
+
data.tar.gz: 2cf23f8b402e491e4dff1b3a6b69a6e9ca6130139716a991d447e0b670bd04249dc0d030b247936a070bbaf7cdd8aa58f6ebb64313cd549a2879d5f0c1ccafdd
|
data/.github/workflows/test.yml
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
name: Test
|
2
|
-
on: push
|
2
|
+
on: [push, pull_request]
|
3
3
|
jobs:
|
4
4
|
test:
|
5
|
-
name: test
|
6
|
-
runs-on: ubuntu-latest
|
7
5
|
strategy:
|
8
6
|
matrix:
|
9
|
-
ruby: [2.5
|
7
|
+
ruby: [2.4, 2.5, 2.6, 2.7, jruby]
|
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
|
+
runs-on: ${{ matrix.platform }}
|
10
15
|
env:
|
11
16
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
12
17
|
steps:
|
13
18
|
- uses: actions/checkout@master
|
14
19
|
- name: Set up Ruby
|
15
|
-
uses:
|
20
|
+
uses: eregon/use-ruby-action@master
|
16
21
|
with:
|
17
22
|
ruby-version: ${{ matrix.ruby }}
|
18
23
|
- name: setup gems
|
@@ -20,9 +25,12 @@ jobs:
|
|
20
25
|
gem install bundler
|
21
26
|
bundle install
|
22
27
|
- name: run test and publish code coverage
|
28
|
+
if: runner.os == 'Linux' && matrix.ruby == '2.7' && env.CC_TEST_REPORTER_ID != ''
|
23
29
|
uses: paambaati/codeclimate-action@v2.3.0
|
24
30
|
env:
|
25
31
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
26
32
|
with:
|
27
33
|
coverageCommand: bundle exec rake spec
|
28
|
-
|
34
|
+
- name: run test
|
35
|
+
if: runner.os != 'Linux' || matrix.ruby != '2.7' || env.CC_TEST_REPORTER_ID == ''
|
36
|
+
run: bundle exec rake spec
|
data/Gemfile
CHANGED
@@ -2,4 +2,7 @@ source "http://rubygems.org"
|
|
2
2
|
|
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
|
+
gem 'simplecov', '~> 0.10', '< 0.18', require: false
|
data/gepub.gemspec
CHANGED
@@ -10,13 +10,14 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = %q{http://github.com/skoji/gepub}
|
11
11
|
s.summary = %q{a generic EPUB library for Ruby.}
|
12
12
|
s.description = %q{gepub is a generic EPUB parser/generator. Generates and parse EPUB2 and EPUB3}
|
13
|
+
s.license = "BSD-3-Clause"
|
13
14
|
|
14
15
|
s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^spec/}) }
|
15
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
17
|
s.require_paths = ["lib"]
|
17
18
|
|
18
19
|
s.add_runtime_dependency "nokogiri", ">= 1.8.2", "< 1.11"
|
19
|
-
s.add_runtime_dependency "rubyzip", "> 1.1.1", "< 2.
|
20
|
+
s.add_runtime_dependency "rubyzip", "> 1.1.1", "< 2.3"
|
20
21
|
s.add_development_dependency "rake"
|
21
22
|
s.add_development_dependency "rspec"
|
22
23
|
end
|
data/lib/gepub/book.rb
CHANGED
@@ -68,7 +68,7 @@ module GEPUB
|
|
68
68
|
# returns contributors list by display-seq or defined order.
|
69
69
|
# the contributors without display-seq is appear after contributors with display-seq.
|
70
70
|
# === Book#lastmodified(date) (delegated to Metadata#lastmodified)
|
71
|
-
# set last modified date.
|
71
|
+
# set last modified date. date is a Time, DateTime or string that can be parsed by DateTime#parse.
|
72
72
|
# === Book#modified_now (delegated to Metadata#modified_now)
|
73
73
|
# set last modified date to current time.
|
74
74
|
# === Book#lastmodified (delegated to Metadata#lastmodified)
|
@@ -299,7 +299,6 @@ EOF
|
|
299
299
|
|landmark|
|
300
300
|
id = landmark[:id].nil? ? "" : "##{x[:id]}"
|
301
301
|
landmark_title = landmark[:title]
|
302
|
-
type = landmark[:type]
|
303
302
|
xml_doc.li {
|
304
303
|
xml_doc.a({'href' => landmark[:item].href + id, 'epub:type' => landmark[:type]}, landmark_title)
|
305
304
|
}
|
@@ -390,6 +389,7 @@ EOF
|
|
390
389
|
end
|
391
390
|
return package, package_path
|
392
391
|
end
|
392
|
+
private_class_method :parse_container
|
393
393
|
|
394
394
|
def self.check_consistency_of_package(package, package_path)
|
395
395
|
if package.nil?
|
@@ -397,9 +397,11 @@ EOF
|
|
397
397
|
end
|
398
398
|
|
399
399
|
if package_path != package.path
|
400
|
-
warn
|
400
|
+
warn "inconsistend EPUB file: container says opf is #{package_path}, but actually #{package.path}"
|
401
401
|
end
|
402
402
|
end
|
403
|
+
private_class_method :check_consistency_of_package
|
404
|
+
|
403
405
|
def self.parse_files_into_package(files, package)
|
404
406
|
files.each {
|
405
407
|
|k, content|
|
@@ -410,6 +412,8 @@ EOF
|
|
410
412
|
end
|
411
413
|
}
|
412
414
|
end
|
415
|
+
private_class_method :parse_files_into_package
|
416
|
+
|
413
417
|
def cleanup_for_epub2
|
414
418
|
if version.to_f < 3.0 || @package.epub_backward_compat
|
415
419
|
if @package.manifest.item_list.select {
|
@@ -425,7 +429,7 @@ EOF
|
|
425
429
|
end
|
426
430
|
def cleanup_for_epub3
|
427
431
|
if version.to_f >=3.0
|
428
|
-
@package.metadata.modified_now
|
432
|
+
@package.metadata.modified_now unless @package.metadata.lastmodified_updated?
|
429
433
|
|
430
434
|
if @package.manifest.item_list.select {
|
431
435
|
|_href, item|
|
data/lib/gepub/metadata.rb
CHANGED
@@ -54,6 +54,7 @@ module GEPUB
|
|
54
54
|
|
55
55
|
}
|
56
56
|
}
|
57
|
+
# do not set @lastmodified_updated here
|
57
58
|
}
|
58
59
|
end
|
59
60
|
|
@@ -73,9 +74,14 @@ module GEPUB
|
|
73
74
|
@spread = NilContent
|
74
75
|
@ibooks_version = NilContent
|
75
76
|
@ibooks_scroll_axis = NilContent
|
77
|
+
@lastmodified_updated = false
|
76
78
|
yield self if block_given?
|
77
79
|
end
|
78
80
|
|
81
|
+
def lastmodified_updated?
|
82
|
+
@lastmodified_updated
|
83
|
+
end
|
84
|
+
|
79
85
|
def to_xml(builder)
|
80
86
|
builder.metadata(@namespaces) {
|
81
87
|
@content_nodes.each {
|
@@ -186,14 +192,16 @@ module GEPUB
|
|
186
192
|
}
|
187
193
|
ret.size == 0 ? nil : ret[0]
|
188
194
|
else
|
195
|
+
@lastmodified_updated = true
|
189
196
|
date ||= Time.now
|
197
|
+
date = DateTime.parse(date) if date.is_a? String
|
190
198
|
(@content_nodes['meta'] ||= []).each {
|
191
199
|
|meta|
|
192
200
|
if (meta['property'] == 'dcterms:modified')
|
193
201
|
@content_nodes['meta'].delete meta
|
194
202
|
end
|
195
203
|
}
|
196
|
-
add_metadata('meta', date.utc.strftime('%Y-%m-%dT%H:%M:%SZ'), itemclass: DateMeta)['property'] = 'dcterms:modified'
|
204
|
+
add_metadata('meta', date.to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ'), itemclass: DateMeta)['property'] = 'dcterms:modified'
|
197
205
|
end
|
198
206
|
end
|
199
207
|
|
@@ -207,14 +215,7 @@ module GEPUB
|
|
207
215
|
|
208
216
|
def set_lastmodified(date=nil)
|
209
217
|
warn "obsolete : set_lastmodified. use lastmodified instead."
|
210
|
-
date
|
211
|
-
(@content_nodes['meta'] ||= []).each {
|
212
|
-
|meta|
|
213
|
-
if (meta['property'] == 'dcterms:modified')
|
214
|
-
@content_nodes['meta'].delete meta
|
215
|
-
end
|
216
|
-
}
|
217
|
-
add_metadata('meta', date.utc.strftime('%Y-%m-%dT%H:%M:%SZ'), itemclass: DateMeta)['property'] = 'dcterms:modified'
|
218
|
+
lastmodified(date)
|
218
219
|
end
|
219
220
|
|
220
221
|
def add_oldstyle_meta(content, attributes = {})
|
data/lib/gepub/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOJIMA Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 1.1.1
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '2.
|
42
|
+
version: '2.3'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 1.1.1
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '2.
|
52
|
+
version: '2.3'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rake
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,8 @@ files:
|
|
128
128
|
- lib/gepub/xml_util.rb
|
129
129
|
- tools/generate_function.rb
|
130
130
|
homepage: http://github.com/skoji/gepub
|
131
|
-
licenses:
|
131
|
+
licenses:
|
132
|
+
- BSD-3-Clause
|
132
133
|
metadata: {}
|
133
134
|
post_install_message:
|
134
135
|
rdoc_options: []
|