gepub 1.0.2 → 1.0.3
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 +4 -4
- data/README.md +3 -3
- data/gepub.gemspec +1 -2
- data/lib/gepub/version.rb +1 -1
- metadata +4 -110
- data/spec/bindings_spec.rb +0 -34
- data/spec/book_spec.rb +0 -307
- data/spec/builder_spec.rb +0 -614
- data/spec/example_spec.rb +0 -192
- data/spec/fixtures/builder/img/cover.jpg +0 -0
- data/spec/fixtures/builder/resources/noise.m4 +0 -0
- data/spec/fixtures/builder/resources/noise_2.m4a +0 -0
- data/spec/fixtures/builder/text/cover.xhtml +0 -11
- data/spec/fixtures/builder/text/localresource.conf +0 -2
- data/spec/fixtures/builder/text/memo.txt +0 -1
- data/spec/fixtures/builder/text/nav.xhtml +0 -12
- data/spec/fixtures/epubcheck-4.1.1/CHANGELOG.txt +0 -92
- data/spec/fixtures/epubcheck-4.1.1/LICENSE.txt +0 -28
- data/spec/fixtures/epubcheck-4.1.1/README.txt +0 -101
- data/spec/fixtures/epubcheck-4.1.1/THIRD-PARTY.txt +0 -60
- data/spec/fixtures/epubcheck-4.1.1/epubcheck.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/Saxon-HE-9.8.0-8.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/animal-sniffer-annotations-1.14.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/checker-compat-qual-2.0.0.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/common-image-3.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/common-io-3.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/common-lang-3.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/commons-compress-1.18.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/error_prone_annotations-2.1.3.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/guava-24.0-android.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/imageio-core-3.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/imageio-jpeg-3.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/imageio-metadata-3.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/j2objc-annotations-1.1.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/jackson-core-asl-1.9.12.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/jackson-mapper-asl-1.9.12.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/jing-20120724.0.0.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/jsr305-1.3.9.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/lib/sac-1.3.jar +0 -0
- data/spec/fixtures/epubcheck-4.1.1/licenses/Apache-2.0.txt +0 -201
- data/spec/fixtures/epubcheck-4.1.1/licenses/BSD-3-Clause.txt +0 -27
- data/spec/fixtures/epubcheck-4.1.1/licenses/MPL-1.0.txt +0 -360
- data/spec/fixtures/epubcheck-4.1.1/licenses/W3C.txt +0 -16
- data/spec/fixtures/testdata/0.html +0 -12
- data/spec/fixtures/testdata/1.html +0 -10
- data/spec/fixtures/testdata/image1.jpg +0 -0
- data/spec/fixtures/testdata/package_2_0.opf +0 -23
- data/spec/fixtures/testdata/test.opf +0 -69
- data/spec/fixtures/testdata/test2.opf +0 -63
- data/spec/fixtures/testdata/test_with_bindings.opf +0 -67
- data/spec/fixtures/testdata/wasteland-20120118.epub +0 -0
- data/spec/gepub_deprectad_api_spec.rb +0 -229
- data/spec/gepub_spec.rb +0 -229
- data/spec/manifest_spec.rb +0 -36
- data/spec/metadata_spec.rb +0 -219
- data/spec/package_spec.rb +0 -150
- data/spec/spec_helper.rb +0 -57
- data/spec/spine_spec.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee59e3e012e4f2c44790db3b96a1e8dffbfcf147071c34060e1775efa3ba8df2
|
4
|
+
data.tar.gz: a0dcdb5d9ecac223b7c78380920f0cf903d41613f2b25588f030c5dc55b1569c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d11d44838afc08f6906a5e6d78982ce9db7ae7618321ff3e3b388875c5e4aaf564bf6a28744cb09d350e6e533486125151ff136d4fe9ed66d709e22c89458762
|
7
|
+
data.tar.gz: a551f8e1330c2d85c0f7b9f41a2ffa03688540ad6ab62c9789f23a6628fff87c7399dee72efc112bd0f32aa154581325e85be726a34a160240e13153dbf19848
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# gepub
|
2
2
|
|
3
3
|
[](https://gitter.im/skoji/gepub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
-
[
|
5
|
-
[](https://travis-ci.org/skoji/gepub)
|
5
|
+
[](https://coveralls.io/r/skoji/gepub?branch=master)
|
6
|
+
[](http://badge.fury.io/rb/gepub)
|
7
7
|
|
8
8
|
* http://rdoc.info/github/skoji/gepub/master/frames
|
9
9
|
|
data/gepub.gemspec
CHANGED
@@ -13,8 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = "gepub"
|
15
15
|
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^spec/}) }
|
18
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOJIMA Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -119,59 +119,6 @@ files:
|
|
119
119
|
- lib/gepub/spine.rb
|
120
120
|
- lib/gepub/version.rb
|
121
121
|
- lib/gepub/xml_util.rb
|
122
|
-
- spec/bindings_spec.rb
|
123
|
-
- spec/book_spec.rb
|
124
|
-
- spec/builder_spec.rb
|
125
|
-
- spec/example_spec.rb
|
126
|
-
- spec/fixtures/builder/img/cover.jpg
|
127
|
-
- spec/fixtures/builder/resources/noise.m4
|
128
|
-
- spec/fixtures/builder/resources/noise_2.m4a
|
129
|
-
- spec/fixtures/builder/text/cover.xhtml
|
130
|
-
- spec/fixtures/builder/text/localresource.conf
|
131
|
-
- spec/fixtures/builder/text/memo.txt
|
132
|
-
- spec/fixtures/builder/text/nav.xhtml
|
133
|
-
- spec/fixtures/epubcheck-4.1.1/CHANGELOG.txt
|
134
|
-
- spec/fixtures/epubcheck-4.1.1/LICENSE.txt
|
135
|
-
- spec/fixtures/epubcheck-4.1.1/README.txt
|
136
|
-
- spec/fixtures/epubcheck-4.1.1/THIRD-PARTY.txt
|
137
|
-
- spec/fixtures/epubcheck-4.1.1/epubcheck.jar
|
138
|
-
- spec/fixtures/epubcheck-4.1.1/lib/Saxon-HE-9.8.0-8.jar
|
139
|
-
- spec/fixtures/epubcheck-4.1.1/lib/animal-sniffer-annotations-1.14.jar
|
140
|
-
- spec/fixtures/epubcheck-4.1.1/lib/checker-compat-qual-2.0.0.jar
|
141
|
-
- spec/fixtures/epubcheck-4.1.1/lib/common-image-3.4.1.jar
|
142
|
-
- spec/fixtures/epubcheck-4.1.1/lib/common-io-3.4.1.jar
|
143
|
-
- spec/fixtures/epubcheck-4.1.1/lib/common-lang-3.4.1.jar
|
144
|
-
- spec/fixtures/epubcheck-4.1.1/lib/commons-compress-1.18.jar
|
145
|
-
- spec/fixtures/epubcheck-4.1.1/lib/error_prone_annotations-2.1.3.jar
|
146
|
-
- spec/fixtures/epubcheck-4.1.1/lib/guava-24.0-android.jar
|
147
|
-
- spec/fixtures/epubcheck-4.1.1/lib/imageio-core-3.4.1.jar
|
148
|
-
- spec/fixtures/epubcheck-4.1.1/lib/imageio-jpeg-3.4.1.jar
|
149
|
-
- spec/fixtures/epubcheck-4.1.1/lib/imageio-metadata-3.4.1.jar
|
150
|
-
- spec/fixtures/epubcheck-4.1.1/lib/j2objc-annotations-1.1.jar
|
151
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jackson-core-asl-1.9.12.jar
|
152
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jackson-mapper-asl-1.9.12.jar
|
153
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jing-20120724.0.0.jar
|
154
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jsr305-1.3.9.jar
|
155
|
-
- spec/fixtures/epubcheck-4.1.1/lib/sac-1.3.jar
|
156
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/Apache-2.0.txt
|
157
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/BSD-3-Clause.txt
|
158
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/MPL-1.0.txt
|
159
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/W3C.txt
|
160
|
-
- spec/fixtures/testdata/0.html
|
161
|
-
- spec/fixtures/testdata/1.html
|
162
|
-
- spec/fixtures/testdata/image1.jpg
|
163
|
-
- spec/fixtures/testdata/package_2_0.opf
|
164
|
-
- spec/fixtures/testdata/test.opf
|
165
|
-
- spec/fixtures/testdata/test2.opf
|
166
|
-
- spec/fixtures/testdata/test_with_bindings.opf
|
167
|
-
- spec/fixtures/testdata/wasteland-20120118.epub
|
168
|
-
- spec/gepub_deprectad_api_spec.rb
|
169
|
-
- spec/gepub_spec.rb
|
170
|
-
- spec/manifest_spec.rb
|
171
|
-
- spec/metadata_spec.rb
|
172
|
-
- spec/package_spec.rb
|
173
|
-
- spec/spec_helper.rb
|
174
|
-
- spec/spine_spec.rb
|
175
122
|
- tools/generate_function.rb
|
176
123
|
homepage: http://github.com/skoji/gepub
|
177
124
|
licenses: []
|
@@ -191,61 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
138
|
- !ruby/object:Gem::Version
|
192
139
|
version: '0'
|
193
140
|
requirements: []
|
194
|
-
rubygems_version: 3.0.
|
141
|
+
rubygems_version: 3.0.3
|
195
142
|
signing_key:
|
196
143
|
specification_version: 4
|
197
144
|
summary: a generic EPUB library for Ruby.
|
198
|
-
test_files:
|
199
|
-
- spec/bindings_spec.rb
|
200
|
-
- spec/book_spec.rb
|
201
|
-
- spec/builder_spec.rb
|
202
|
-
- spec/example_spec.rb
|
203
|
-
- spec/fixtures/builder/img/cover.jpg
|
204
|
-
- spec/fixtures/builder/resources/noise.m4
|
205
|
-
- spec/fixtures/builder/resources/noise_2.m4a
|
206
|
-
- spec/fixtures/builder/text/cover.xhtml
|
207
|
-
- spec/fixtures/builder/text/localresource.conf
|
208
|
-
- spec/fixtures/builder/text/memo.txt
|
209
|
-
- spec/fixtures/builder/text/nav.xhtml
|
210
|
-
- spec/fixtures/epubcheck-4.1.1/CHANGELOG.txt
|
211
|
-
- spec/fixtures/epubcheck-4.1.1/LICENSE.txt
|
212
|
-
- spec/fixtures/epubcheck-4.1.1/README.txt
|
213
|
-
- spec/fixtures/epubcheck-4.1.1/THIRD-PARTY.txt
|
214
|
-
- spec/fixtures/epubcheck-4.1.1/epubcheck.jar
|
215
|
-
- spec/fixtures/epubcheck-4.1.1/lib/Saxon-HE-9.8.0-8.jar
|
216
|
-
- spec/fixtures/epubcheck-4.1.1/lib/animal-sniffer-annotations-1.14.jar
|
217
|
-
- spec/fixtures/epubcheck-4.1.1/lib/checker-compat-qual-2.0.0.jar
|
218
|
-
- spec/fixtures/epubcheck-4.1.1/lib/common-image-3.4.1.jar
|
219
|
-
- spec/fixtures/epubcheck-4.1.1/lib/common-io-3.4.1.jar
|
220
|
-
- spec/fixtures/epubcheck-4.1.1/lib/common-lang-3.4.1.jar
|
221
|
-
- spec/fixtures/epubcheck-4.1.1/lib/commons-compress-1.18.jar
|
222
|
-
- spec/fixtures/epubcheck-4.1.1/lib/error_prone_annotations-2.1.3.jar
|
223
|
-
- spec/fixtures/epubcheck-4.1.1/lib/guava-24.0-android.jar
|
224
|
-
- spec/fixtures/epubcheck-4.1.1/lib/imageio-core-3.4.1.jar
|
225
|
-
- spec/fixtures/epubcheck-4.1.1/lib/imageio-jpeg-3.4.1.jar
|
226
|
-
- spec/fixtures/epubcheck-4.1.1/lib/imageio-metadata-3.4.1.jar
|
227
|
-
- spec/fixtures/epubcheck-4.1.1/lib/j2objc-annotations-1.1.jar
|
228
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jackson-core-asl-1.9.12.jar
|
229
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jackson-mapper-asl-1.9.12.jar
|
230
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jing-20120724.0.0.jar
|
231
|
-
- spec/fixtures/epubcheck-4.1.1/lib/jsr305-1.3.9.jar
|
232
|
-
- spec/fixtures/epubcheck-4.1.1/lib/sac-1.3.jar
|
233
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/Apache-2.0.txt
|
234
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/BSD-3-Clause.txt
|
235
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/MPL-1.0.txt
|
236
|
-
- spec/fixtures/epubcheck-4.1.1/licenses/W3C.txt
|
237
|
-
- spec/fixtures/testdata/0.html
|
238
|
-
- spec/fixtures/testdata/1.html
|
239
|
-
- spec/fixtures/testdata/image1.jpg
|
240
|
-
- spec/fixtures/testdata/package_2_0.opf
|
241
|
-
- spec/fixtures/testdata/test.opf
|
242
|
-
- spec/fixtures/testdata/test2.opf
|
243
|
-
- spec/fixtures/testdata/test_with_bindings.opf
|
244
|
-
- spec/fixtures/testdata/wasteland-20120118.epub
|
245
|
-
- spec/gepub_deprectad_api_spec.rb
|
246
|
-
- spec/gepub_spec.rb
|
247
|
-
- spec/manifest_spec.rb
|
248
|
-
- spec/metadata_spec.rb
|
249
|
-
- spec/package_spec.rb
|
250
|
-
- spec/spec_helper.rb
|
251
|
-
- spec/spine_spec.rb
|
145
|
+
test_files: []
|
data/spec/bindings_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'nokogiri'
|
5
|
-
|
6
|
-
describe GEPUB::Bindings do
|
7
|
-
context 'parse existing opf' do
|
8
|
-
before do
|
9
|
-
@bindings = GEPUB::Package.parse_opf(File.open(File.dirname(__FILE__) + '/fixtures/testdata/test_with_bindings.opf'), '/package.opf').instance_eval{ @bindings }
|
10
|
-
end
|
11
|
-
it 'should be parsed' do
|
12
|
-
expect(@bindings.media_types.size).to eq(2)
|
13
|
-
expect(@bindings.media_types[0].handler).to eq('h')
|
14
|
-
expect(@bindings.media_types[0].media_type).to eq('application/x-foreign-type')
|
15
|
-
expect(@bindings.media_types[1].handler).to eq('v')
|
16
|
-
expect(@bindings.media_types[1].media_type).to eq('application/x-other-foreign-type')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'generate new opf' do
|
21
|
-
it 'should generate xml' do
|
22
|
-
bindings = GEPUB::Bindings.new
|
23
|
-
bindings.add('id1', 'application/x-some-type')
|
24
|
-
builder = Nokogiri::XML::Builder.new { |xml|
|
25
|
-
xml.package('xmlns' => "http://www.idpf.org/2007/opf",'version' => "3.0",'unique-identifier' => "pub-id",'xml:lang' => "ja") {
|
26
|
-
bindings.to_xml(xml)
|
27
|
-
}
|
28
|
-
}
|
29
|
-
xml = Nokogiri::XML::Document.parse(builder.to_xml)
|
30
|
-
expect(xml.xpath("//xmlns:mediaType[@handler='id1' and @media-type='application/x-some-type']").size).to eq(1)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
data/spec/book_spec.rb
DELETED
@@ -1,307 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'nokogiri'
|
4
|
-
|
5
|
-
describe GEPUB::Book do
|
6
|
-
context 'on creating new book' do
|
7
|
-
describe 'initialize' do
|
8
|
-
context 'without parameter' do
|
9
|
-
it 'returns empty book' do
|
10
|
-
book = GEPUB::Book.new()
|
11
|
-
expect(book.path) .to eq('OEBPS/package.opf')
|
12
|
-
expect(book.version).to eq('3.0')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
context 'with path' do
|
16
|
-
it 'returns empty book with path' do
|
17
|
-
book = GEPUB::Book.new('mypath/foo.opf')
|
18
|
-
expect(book.path) .to eq('mypath/foo.opf')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
context 'with path and attributes' do
|
22
|
-
it 'returns empty book with path and attributes' do
|
23
|
-
book = GEPUB::Book.new('mypath/book.opf', {'version' => '2.1'});
|
24
|
-
expect(book.path) .to eq('mypath/book.opf')
|
25
|
-
expect(book.version).to eq('2.1')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
describe 'version=' do
|
30
|
-
context 'overwrite version' do
|
31
|
-
it 'will hold new version' do
|
32
|
-
GEPUB::Book.new do |book|
|
33
|
-
book.version = '2.1'
|
34
|
-
expect(book.version).to eq('2.1')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
describe 'identifer=' do
|
40
|
-
context 'set identifier' do
|
41
|
-
it 'will set unique-identifier and related attributes' do
|
42
|
-
GEPUB::Book.new do |book|
|
43
|
-
book.identifier = 'the-book-identifier'
|
44
|
-
expect(book.identifier).to eq('the-book-identifier')
|
45
|
-
expect(book.identifier_list[0]['id']).to eq(book.unique_identifier)
|
46
|
-
expect(book.identifier_list[0].refiner('identifier-type')).to be_nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
describe 'primary_identifier' do
|
52
|
-
context 'set identifier with id and type' do
|
53
|
-
it 'will set unique-identifier and related attributes' do
|
54
|
-
book = GEPUB::Book.new do
|
55
|
-
primary_identifier 'http//example.com/the-identifier', 'MyBookID', 'URL'
|
56
|
-
end
|
57
|
-
expect(book.identifier).to eq('http//example.com/the-identifier')
|
58
|
-
expect(book.unique_identifier).to eq('MyBookID')
|
59
|
-
expect(book.identifier_list[0]['id']).to eq('MyBookID')
|
60
|
-
expect(book.identifier_list[0].identifier_type.content).to eq('URL')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
describe 'add_identifier' do
|
65
|
-
context 'add new identifier to new book' do
|
66
|
-
it 'will set identifier, and not set unique-identifier' do
|
67
|
-
book = GEPUB::Book.new()
|
68
|
-
book.add_identifier 'newid'
|
69
|
-
expect(book.unique_identifier).to be_nil
|
70
|
-
expect(book.identifier).to be_nil
|
71
|
-
expect(book.identifier_list[0].content).to eq('newid')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
context 'add new identifier to existing book' do
|
75
|
-
it 'will set new identifier' do
|
76
|
-
book = GEPUB::Book.new()
|
77
|
-
book.identifier = 'theIdentifier'
|
78
|
-
book.add_identifier 'http://example.jp/additional_identifier', nil, 'URL'
|
79
|
-
expect(book.identifier).to eq('theIdentifier')
|
80
|
-
expect(book.identifier_list[1].content).to eq('http://example.jp/additional_identifier')
|
81
|
-
expect(book.identifier_list[1].identifier_type.content).to eq('URL')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
describe 'add_title' do
|
86
|
-
context 'add title' do
|
87
|
-
it 'adds new title' do
|
88
|
-
book = GEPUB::Book.new()
|
89
|
-
book.title = 'the title'
|
90
|
-
book.add_title 'new title'
|
91
|
-
expect(book.title.to_s).to eq('the title')
|
92
|
-
expect(book.title_list[1].to_s).to eq('new title')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
describe 'title =' do
|
97
|
-
context 'set first title' do
|
98
|
-
it 'will add new title' do
|
99
|
-
book = GEPUB::Book.new()
|
100
|
-
book.title = 'the title'
|
101
|
-
expect(book.title.to_s).to eq('the title')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
context 'clear and set title' do
|
105
|
-
it 'will clear title and add new title' do
|
106
|
-
book = GEPUB::Book.new()
|
107
|
-
book.add_title 'the title'
|
108
|
-
book.title = 'new title'
|
109
|
-
expect(book.title.to_s).to eq('new title')
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
describe 'title' do
|
114
|
-
context 'main title is specified' do
|
115
|
-
it 'returns main title' do
|
116
|
-
book = GEPUB::Book.new()
|
117
|
-
book.add_title 'sub title'
|
118
|
-
book.add_title('the main title', title_type: GEPUB::TITLE_TYPE::MAIN)
|
119
|
-
expect(book.title.to_s).to eq('the main title')
|
120
|
-
end
|
121
|
-
end
|
122
|
-
context 'display_seq is specified' do
|
123
|
-
it 'returns first title' do
|
124
|
-
book = GEPUB::Book.new()
|
125
|
-
book.add_title 'second title'
|
126
|
-
book.add_title('first title') do
|
127
|
-
|title|
|
128
|
-
title.display_seq = 1
|
129
|
-
end
|
130
|
-
expect(book.title.to_s).to eq('first title')
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
describe 'title_list' do
|
135
|
-
context 'main title is specified' do
|
136
|
-
it 'returns titles in defined order' do
|
137
|
-
book = GEPUB::Book.new()
|
138
|
-
book.add_title 'sub title'
|
139
|
-
book.add_title('the main title', title_type: GEPUB::TITLE_TYPE::MAIN)
|
140
|
-
expect(book.title_list[0].to_s).to eq('sub title')
|
141
|
-
expect(book.title_list[1].to_s).to eq('the main title')
|
142
|
-
end
|
143
|
-
context 'display seq is specified' do
|
144
|
-
it 'returns titles in display-seq order' do
|
145
|
-
book = GEPUB::Book.new()
|
146
|
-
book.add_title 'third title'
|
147
|
-
book.add_title 'fourth title'
|
148
|
-
book.add_title 'second title' do
|
149
|
-
|title|
|
150
|
-
title.display_seq = 2
|
151
|
-
end
|
152
|
-
book.add_title('first title') do
|
153
|
-
|title|
|
154
|
-
title.display_seq = 1
|
155
|
-
end
|
156
|
-
expect(book.title_list[0].to_s).to eq('first title')
|
157
|
-
expect(book.title_list[1].to_s).to eq('second title')
|
158
|
-
expect(book.title_list[2].to_s).to eq('third title')
|
159
|
-
expect(book.title_list[3].to_s).to eq('fourth title')
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
describe 'add_creator' do
|
165
|
-
it 'adds new creator' do
|
166
|
-
book = GEPUB::Book.new()
|
167
|
-
book.creator = 'the creator'
|
168
|
-
book.add_creator 'new creator'
|
169
|
-
expect(book.creator.to_s).to eq('the creator')
|
170
|
-
expect(book.creator_list[1].to_s).to eq('new creator')
|
171
|
-
end
|
172
|
-
end
|
173
|
-
describe 'creator=' do
|
174
|
-
it 'set first creator' do
|
175
|
-
book = GEPUB::Book.new()
|
176
|
-
book.creator = 'the creator'
|
177
|
-
expect(book.creator.to_s).to eq('the creator')
|
178
|
-
end
|
179
|
-
it 'clear and set creator' do
|
180
|
-
book = GEPUB::Book.new()
|
181
|
-
book.creator = 'the creator'
|
182
|
-
book.creator = 'new creator'
|
183
|
-
expect(book.creator.to_s).to eq('new creator')
|
184
|
-
expect(book.creator_list.size).to eq(1)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
describe 'creator' do
|
188
|
-
context 'display seq is specified' do
|
189
|
-
it 'shows creator with smallest display-seq' do
|
190
|
-
book = GEPUB::Book.new()
|
191
|
-
book.add_creator 'a creator'
|
192
|
-
book.add_creator('second creator') do
|
193
|
-
|creator|
|
194
|
-
creator.display_seq = 2
|
195
|
-
end
|
196
|
-
expect(book.creator.to_s).to eq('second creator')
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe 'creator_list' do
|
202
|
-
context 'display seq is specified' do
|
203
|
-
it 'returns creators in display-seq order' do
|
204
|
-
book = GEPUB::Book.new()
|
205
|
-
book.add_creator 'a creator'
|
206
|
-
book.add_creator('second creator') do
|
207
|
-
|creator|
|
208
|
-
creator.display_seq = 2
|
209
|
-
end
|
210
|
-
book.add_creator 'another creator'
|
211
|
-
book.add_creator('first creator') do
|
212
|
-
|creator|
|
213
|
-
creator.display_seq = 1
|
214
|
-
end
|
215
|
-
book.add_creator('third creator') do
|
216
|
-
|creator|
|
217
|
-
creator.display_seq = 3
|
218
|
-
end
|
219
|
-
expect(book.creator_list[0].to_s).to eq('first creator')
|
220
|
-
expect(book.creator_list[1].to_s).to eq('second creator')
|
221
|
-
expect(book.creator_list[2].to_s).to eq('third creator')
|
222
|
-
expect(book.creator_list[3].to_s).to eq('a creator')
|
223
|
-
expect(book.creator_list[4].to_s).to eq('another creator')
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
# omit tests for setter/getter for contributor, publisher, date etc; these methods use same implementation as creator.
|
229
|
-
|
230
|
-
describe 'set_lastmodified' do
|
231
|
-
it 'set current time' do
|
232
|
-
book = GEPUB::Book.new
|
233
|
-
now = Time.now
|
234
|
-
book.modified_now
|
235
|
-
expect((book.lastmodified.content - now).abs).to be < 2
|
236
|
-
end
|
237
|
-
it 'set time in string' do
|
238
|
-
book = GEPUB::Book.new
|
239
|
-
book.lastmodified(Time.parse('2012-9-12 00:00:00Z'))
|
240
|
-
expect(book.lastmodified.content).to eq(Time.parse('2012-9-12 00:00:00 UTC'))
|
241
|
-
end
|
242
|
-
it 'set time in string : using assign method' do
|
243
|
-
book = GEPUB::Book.new
|
244
|
-
book.lastmodified = Time.parse('2012-9-12 00:00:00Z')
|
245
|
-
expect(book.lastmodified.content).to eq(Time.parse('2012-9-12 00:00:00 UTC'))
|
246
|
-
end
|
247
|
-
end
|
248
|
-
describe 'page_progression_direction=' do
|
249
|
-
it 'set page_progression_direction' do
|
250
|
-
book = GEPUB::Book.new
|
251
|
-
book.page_progression_direction= 'rtl'
|
252
|
-
expect(book.page_progression_direction).to eq('rtl')
|
253
|
-
end
|
254
|
-
end
|
255
|
-
describe 'add_optional_file' do
|
256
|
-
context 'add apple specific option file' do
|
257
|
-
it 'is added to book' do
|
258
|
-
content = <<-EOF
|
259
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
260
|
-
<display_options>
|
261
|
-
<platform name="*">
|
262
|
-
<option name="fixed-layout">true</option>
|
263
|
-
</platform>
|
264
|
-
</display_options>
|
265
|
-
EOF
|
266
|
-
book = GEPUB::Book.new
|
267
|
-
book.add_optional_file('META-INF/com.apple.ibooks.display-options.xm', StringIO.new(content))
|
268
|
-
|
269
|
-
expect(book.optional_files.size).to eq(1)
|
270
|
-
expect(book.optional_files['META-INF/com.apple.ibooks.display-options.xm']).to eq(content)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
describe 'add_item' do
|
275
|
-
end
|
276
|
-
describe 'add_ordered_item' do
|
277
|
-
end
|
278
|
-
describe 'ordered' do
|
279
|
-
end
|
280
|
-
describe 'write_to_epub_container' do
|
281
|
-
context 'create typical book' do
|
282
|
-
end
|
283
|
-
context 'create very complex book' do
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
context 'on parsing existing book' do
|
288
|
-
describe '.parse' do
|
289
|
-
context 'IO Object' do
|
290
|
-
it 'loads book and returns GEPUB::Book object' do
|
291
|
-
filehandle = File.new(File.dirname(__FILE__) + '/fixtures/testdata/wasteland-20120118.epub')
|
292
|
-
book = GEPUB::Book.parse(filehandle)
|
293
|
-
expect(book).to be_instance_of GEPUB::Book
|
294
|
-
expect(book.items.size).to eq 6
|
295
|
-
expect(book.items['t1'].href).to eq 'wasteland-content.xhtml'
|
296
|
-
expect(book.items['nav'].href).to eq 'wasteland-nav.xhtml'
|
297
|
-
expect(book.items['cover'].href).to eq 'wasteland-cover.jpg'
|
298
|
-
expect(book.items['css'].href).to eq 'wasteland.css'
|
299
|
-
expect(book.items['css-night'].href).to eq 'wasteland-night.css'
|
300
|
-
expect(book.items['ncx'].href).to eq 'wasteland.ncx'
|
301
|
-
expect(book.spine_items.size).to eq 1
|
302
|
-
expect(book.spine_items[0].href).to eq 'wasteland-content.xhtml'
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|