gepub 0.6.9.1 → 0.6.9.2
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/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +4 -3
- data/gepub.gemspec +3 -3
- data/lib/gepub/book.rb +8 -7
- data/lib/gepub/version.rb +1 -1
- data/spec/bindings_spec.rb +6 -6
- data/spec/builder_spec.rb +106 -106
- data/spec/example_spec.rb +16 -7
- data/spec/fixtures/{epubcheck-3.0b4 → epubcheck-3.0.1}/COPYING.txt +19 -19
- data/spec/fixtures/{epubcheck-3.0b4 → epubcheck-3.0.1}/README.txt +50 -61
- data/spec/fixtures/epubcheck-3.0.1/THIRD-PARTY.txt +20 -0
- data/spec/fixtures/epubcheck-3.0.1/epubcheck-3.0.1.jar +0 -0
- data/spec/fixtures/epubcheck-3.0.1/lib/Saxon-HE-9.4.0.6.jar +0 -0
- data/spec/fixtures/epubcheck-3.0.1/lib/commons-compress-1.4.1.jar +0 -0
- data/spec/fixtures/epubcheck-3.0.1/lib/guava-13.0.1.jar +0 -0
- data/spec/fixtures/{epubcheck-3.0b4/lib/jing.jar → epubcheck-3.0.1/lib/jing-20120724.0.0.jar} +0 -0
- data/spec/fixtures/epubcheck-3.0.1/lib/sac-1.3.jar +0 -0
- data/spec/fixtures/epubcheck-3.0.1/licenses/Apache-2.0.txt +201 -0
- data/spec/fixtures/epubcheck-3.0.1/licenses/BSD-3-Clause.txt +27 -0
- data/spec/fixtures/epubcheck-3.0.1/licenses/MPL-1.0.txt +360 -0
- data/spec/fixtures/epubcheck-3.0.1/licenses/W3C.txt +16 -0
- data/spec/gepub_spec.rb +60 -47
- data/spec/manifest_spec.rb +9 -9
- data/spec/metadata_spec.rb +50 -50
- data/spec/package_spec.rb +29 -29
- data/spec/spec_helper.rb +19 -0
- data/spec/spine_spec.rb +14 -14
- metadata +46 -38
- data/spec/fixtures/epubcheck-3.0b4/epubcheck-3.0b4.jar +0 -0
- data/spec/fixtures/epubcheck-3.0b4/jing_license.txt +0 -12
- data/spec/fixtures/epubcheck-3.0b4/lib/commons-compress-1.2.jar +0 -0
- data/spec/fixtures/epubcheck-3.0b4/lib/cssparser-0.9.6.jar +0 -0
- data/spec/fixtures/epubcheck-3.0b4/lib/sac-1.3.jar +0 -0
- data/spec/fixtures/epubcheck-3.0b4/lib/saxon9he.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6790c94431137225f634825b8bb31fa4c17bf9fa
|
4
|
+
data.tar.gz: 6b8b2480b8892406e07f33a36563dc7448b20330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f61337779cffc792a6d186fad5df3998437ec4a5f2785db9cce502af72c58d323037b63ccc0e102b9e9fe70514080056f35afe21a797646fd3d2c9a43c0d1b4
|
7
|
+
data.tar.gz: cffa739c71bbb81dddd083b03d5c2dedb4d203bd35d3f511cbdf96c1b288b70e30ab488462f38b9096a17b268d22ddb6af2f19c780cc04fa967f6899f78f960b
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# gepub
|
1
|
+
# gepub
|
2
|
+
[<img src="https://secure.travis-ci.org/skoji/gepub.png" />](http://travis-ci.org/skoji/gepub) [](https://coveralls.io/r/skoji/gepub?branch=master)
|
2
3
|
|
3
4
|
* http://en.skoji.jp/category/gepub/
|
4
5
|
|
@@ -8,9 +9,9 @@ a generic EPUB parser/generator library.
|
|
8
9
|
|
9
10
|
## FEATURES/PROBLEMS:
|
10
11
|
|
11
|
-
* GEPUB::Book provides functionality to create EPUB file, and parsing EPUB
|
12
|
+
* GEPUB::Book provides functionality to create EPUB file, and parsing EPUB files
|
12
13
|
* Handle every metadata in EPUB2/EPUB3.
|
13
|
-
* GEPUB::Builder
|
14
|
+
* GEPUB::Builder provides an easy and powerful way to create EPUB3 files
|
14
15
|
|
15
16
|
* See [issues](https://github.com/skoji/gepub/issues/) for known problems.
|
16
17
|
|
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_development_dependency "rspec", "~> 2.
|
22
|
-
s.add_runtime_dependency "nokogiri", "~> 1.
|
23
|
-
s.add_runtime_dependency "rubyzip", "
|
21
|
+
s.add_development_dependency "rspec", "~> 2.14"
|
22
|
+
s.add_runtime_dependency "nokogiri", "~> 1.6.1"
|
23
|
+
s.add_runtime_dependency "rubyzip", ">= 1.1.1"
|
24
24
|
end
|
data/lib/gepub/book.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'rubygems'
|
3
3
|
require 'nokogiri'
|
4
|
-
require 'zip
|
4
|
+
require 'zip'
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
7
|
# = GEPUB
|
@@ -102,15 +102,16 @@ module GEPUB
|
|
102
102
|
files = {}
|
103
103
|
package = nil
|
104
104
|
package_path = nil
|
105
|
-
|
105
|
+
book = nil
|
106
|
+
Zip::InputStream::open(io) {
|
106
107
|
|zis|
|
107
108
|
package, package_path = parse_container(zis, files)
|
108
109
|
check_consistency_of_package(package, package_path)
|
109
110
|
parse_files_into_package(files, package)
|
110
111
|
book = Book.new(package.path)
|
111
112
|
book.instance_eval { @package = package; @optional_files = files }
|
112
|
-
book
|
113
113
|
}
|
114
|
+
book
|
114
115
|
end
|
115
116
|
|
116
117
|
# creates new empty Book object.
|
@@ -213,7 +214,7 @@ module GEPUB
|
|
213
214
|
|
214
215
|
# write EPUB to stream specified by the argument.
|
215
216
|
def write_to_epub_container(epub)
|
216
|
-
epub.put_next_entry('mimetype', '', '', Zip::
|
217
|
+
epub.put_next_entry('mimetype', '', '', Zip::Entry::STORED)
|
217
218
|
epub << "application/epub+zip"
|
218
219
|
|
219
220
|
entries = {}
|
@@ -241,17 +242,17 @@ module GEPUB
|
|
241
242
|
# generates and returns StringIO contains EPUB.
|
242
243
|
def generate_epub_stream
|
243
244
|
cleanup
|
244
|
-
Zip::
|
245
|
+
Zip::OutputStream::write_buffer(StringIO.new) do
|
245
246
|
|epub|
|
246
247
|
write_to_epub_container(epub)
|
247
|
-
|
248
|
+
end
|
248
249
|
end
|
249
250
|
|
250
251
|
# writes EPUB to file. if file exists, it will be overwritten.
|
251
252
|
def generate_epub(path_to_epub)
|
252
253
|
cleanup
|
253
254
|
File.delete(path_to_epub) if File.exist?(path_to_epub)
|
254
|
-
Zip::
|
255
|
+
Zip::OutputStream::open(path_to_epub) {
|
255
256
|
|epub|
|
256
257
|
write_to_epub_container(epub)
|
257
258
|
}
|
data/lib/gepub/version.rb
CHANGED
data/spec/bindings_spec.rb
CHANGED
@@ -9,11 +9,11 @@ describe GEPUB::Bindings do
|
|
9
9
|
@bindings = GEPUB::Package.parse_opf(File.open(File.dirname(__FILE__) + '/fixtures/testdata/test_with_bindings.opf'), '/package.opf').instance_eval{ @bindings }
|
10
10
|
end
|
11
11
|
it 'should be parsed' do
|
12
|
-
@bindings.media_types.size.
|
13
|
-
@bindings.media_types[0].handler.
|
14
|
-
@bindings.media_types[0].media_type.
|
15
|
-
@bindings.media_types[1].handler.
|
16
|
-
@bindings.media_types[1].media_type.
|
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
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -27,7 +27,7 @@ describe GEPUB::Bindings do
|
|
27
27
|
}
|
28
28
|
}
|
29
29
|
xml = Nokogiri::XML::Document.parse(builder.to_xml)
|
30
|
-
xml.xpath("//xmlns:mediaType[@handler='id1' and @media-type='application/x-some-type']").size.
|
30
|
+
expect(xml.xpath("//xmlns:mediaType[@handler='id1' and @media-type='application/x-some-type']").size).to eq(1)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/spec/builder_spec.rb
CHANGED
@@ -7,41 +7,41 @@ describe GEPUB::Builder do
|
|
7
7
|
builder = GEPUB::Builder.new {
|
8
8
|
language 'ja'
|
9
9
|
}
|
10
|
-
builder.instance_eval { @book.language }.to_s.
|
10
|
+
expect(builder.instance_eval { @book.language }.to_s).to eq('ja')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should generate uid' do
|
14
14
|
builder = GEPUB::Builder.new {
|
15
15
|
unique_identifier 'http://example.jp/as_url', 'BookID', 'url'
|
16
16
|
}
|
17
|
-
builder.instance_eval { @book.identifier }.to_s.
|
18
|
-
builder.instance_eval { @book.identifier_list[0]['id']}.
|
19
|
-
builder.instance_eval { @book.identifier_list[0].identifier_type}.to_s.
|
17
|
+
expect(builder.instance_eval { @book.identifier }.to_s).to eq('http://example.jp/as_url')
|
18
|
+
expect(builder.instance_eval { @book.identifier_list[0]['id']}).to eq('BookID')
|
19
|
+
expect(builder.instance_eval { @book.identifier_list[0].identifier_type}.to_s).to eq('url')
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should generate title' do
|
23
23
|
builder = GEPUB::Builder.new {
|
24
24
|
title 'The Book Title'
|
25
25
|
}
|
26
|
-
builder.instance_eval { @book.title }.to_s.
|
27
|
-
builder.instance_eval { @book.title.title_type }.to_s.
|
26
|
+
expect(builder.instance_eval { @book.title }.to_s).to eq('The Book Title')
|
27
|
+
expect(builder.instance_eval { @book.title.title_type }.to_s).to eq('main')
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should generate title with type ' do
|
31
31
|
builder = GEPUB::Builder.new {
|
32
32
|
subtitle 'the sub-title'
|
33
33
|
}
|
34
|
-
builder.instance_eval { @book.title }.to_s.
|
35
|
-
builder.instance_eval { @book.title.title_type }.to_s.
|
34
|
+
expect(builder.instance_eval { @book.title }.to_s).to eq('the sub-title')
|
35
|
+
expect(builder.instance_eval { @book.title.title_type }.to_s).to eq('subtitle')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should generate collection title ' do
|
39
39
|
builder = GEPUB::Builder.new {
|
40
40
|
collection 'the collection', 3
|
41
41
|
}
|
42
|
-
builder.instance_eval { @book.title }.to_s.
|
43
|
-
builder.instance_eval { @book.title.title_type }.to_s.
|
44
|
-
builder.instance_eval { @book.title.group_position }.to_s.
|
42
|
+
expect(builder.instance_eval { @book.title }.to_s).to eq('the collection')
|
43
|
+
expect(builder.instance_eval { @book.title.title_type }.to_s).to eq('collection')
|
44
|
+
expect(builder.instance_eval { @book.title.group_position }.to_s).to eq('3')
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should refine title: alternates ' do
|
@@ -49,9 +49,9 @@ describe GEPUB::Builder do
|
|
49
49
|
collection 'the collection', 3
|
50
50
|
alt 'ja' => 'シリーズ'
|
51
51
|
}
|
52
|
-
builder.instance_eval { @book.title }.to_s.
|
53
|
-
builder.instance_eval { @book.title.title_type }.to_s.
|
54
|
-
builder.instance_eval { @book.title.list_alternates['ja'] }.to_s.
|
52
|
+
expect(builder.instance_eval { @book.title }.to_s).to eq('the collection')
|
53
|
+
expect(builder.instance_eval { @book.title.title_type }.to_s).to eq('collection')
|
54
|
+
expect(builder.instance_eval { @book.title.list_alternates['ja'] }.to_s).to eq('シリーズ')
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should refine title: file_as ' do
|
@@ -59,9 +59,9 @@ describe GEPUB::Builder do
|
|
59
59
|
title 'メインタイトル'
|
60
60
|
file_as 'main title'
|
61
61
|
}
|
62
|
-
builder.instance_eval { @book.title }.to_s.
|
63
|
-
builder.instance_eval { @book.title.title_type }.to_s.
|
64
|
-
builder.instance_eval { @book.title.file_as }.to_s.
|
62
|
+
expect(builder.instance_eval { @book.title }.to_s).to eq('メインタイトル')
|
63
|
+
expect(builder.instance_eval { @book.title.title_type }.to_s).to eq('main')
|
64
|
+
expect(builder.instance_eval { @book.title.file_as }.to_s).to eq('main title')
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should refine title: alt and file_as ' do
|
@@ -70,44 +70,44 @@ describe GEPUB::Builder do
|
|
70
70
|
file_as 'main title'
|
71
71
|
alt 'en' => 'The Main Title'
|
72
72
|
}
|
73
|
-
builder.instance_eval { @book.title }.to_s.
|
74
|
-
builder.instance_eval { @book.title.title_type }.to_s.
|
75
|
-
builder.instance_eval { @book.title.file_as }.to_s.
|
76
|
-
builder.instance_eval { @book.title.list_alternates['en'] }.to_s.
|
73
|
+
expect(builder.instance_eval { @book.title }.to_s).to eq('メインタイトル')
|
74
|
+
expect(builder.instance_eval { @book.title.title_type }.to_s).to eq('main')
|
75
|
+
expect(builder.instance_eval { @book.title.file_as }.to_s).to eq('main title')
|
76
|
+
expect(builder.instance_eval { @book.title.list_alternates['en'] }.to_s).to eq('The Main Title')
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should generate creator ' do
|
80
80
|
builder = GEPUB::Builder.new {
|
81
81
|
creator 'The Main Author'
|
82
82
|
}
|
83
|
-
builder.instance_eval { @book.creator }.to_s.
|
83
|
+
expect(builder.instance_eval { @book.creator }.to_s).to eq('The Main Author')
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'should generate creator with role' do
|
87
87
|
builder = GEPUB::Builder.new {
|
88
88
|
creator 'The Illustrator', 'ill'
|
89
89
|
}
|
90
|
-
builder.instance_eval { @book.creator }.to_s.
|
91
|
-
builder.instance_eval { @book.creator.role}.to_s.
|
90
|
+
expect(builder.instance_eval { @book.creator }.to_s).to eq('The Illustrator')
|
91
|
+
expect(builder.instance_eval { @book.creator.role}.to_s).to eq('ill')
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'should generate contributor ' do
|
95
95
|
builder = GEPUB::Builder.new {
|
96
96
|
contributor 'contributor', 'edt'
|
97
97
|
}
|
98
|
-
builder.instance_eval { @book.contributor }.to_s.
|
99
|
-
builder.instance_eval { @book.contributor.role}.to_s.
|
98
|
+
expect(builder.instance_eval { @book.contributor }.to_s).to eq('contributor')
|
99
|
+
expect(builder.instance_eval { @book.contributor.role}.to_s).to eq('edt')
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'should generate multiple creators ' do
|
103
103
|
builder = GEPUB::Builder.new {
|
104
104
|
creators 'First Author', 'Second Author', ['Third Person', 'edt']
|
105
105
|
}
|
106
|
-
builder.instance_eval { @book.creator_list }.size.
|
107
|
-
builder.instance_eval { @book.creator_list[0] }.to_s.
|
108
|
-
builder.instance_eval { @book.creator_list[1] }.to_s.
|
109
|
-
builder.instance_eval { @book.creator_list[2] }.to_s.
|
110
|
-
builder.instance_eval { @book.creator_list[2].role }.to_s.
|
106
|
+
expect(builder.instance_eval { @book.creator_list }.size).to eq(3)
|
107
|
+
expect(builder.instance_eval { @book.creator_list[0] }.to_s).to eq('First Author')
|
108
|
+
expect(builder.instance_eval { @book.creator_list[1] }.to_s).to eq('Second Author')
|
109
|
+
expect(builder.instance_eval { @book.creator_list[2] }.to_s).to eq('Third Person')
|
110
|
+
expect(builder.instance_eval { @book.creator_list[2].role }.to_s).to eq('edt')
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should generate multiple creators, and then add file_as at once ' do
|
@@ -115,14 +115,14 @@ describe GEPUB::Builder do
|
|
115
115
|
creators 'First Author', 'Second Author', ['Third Person', 'edt']
|
116
116
|
file_as '1st', '2nd', '3rd'
|
117
117
|
}
|
118
|
-
builder.instance_eval { @book.creator_list }.size.
|
119
|
-
builder.instance_eval { @book.creator_list[0] }.to_s.
|
120
|
-
builder.instance_eval { @book.creator_list[0].file_as }.to_s.
|
121
|
-
builder.instance_eval { @book.creator_list[1] }.to_s.
|
122
|
-
builder.instance_eval { @book.creator_list[1].file_as }.to_s.
|
123
|
-
builder.instance_eval { @book.creator_list[2] }.to_s.
|
124
|
-
builder.instance_eval { @book.creator_list[2].file_as }.to_s.
|
125
|
-
builder.instance_eval { @book.creator_list[2].role }.to_s.
|
118
|
+
expect(builder.instance_eval { @book.creator_list }.size).to eq(3)
|
119
|
+
expect(builder.instance_eval { @book.creator_list[0] }.to_s).to eq('First Author')
|
120
|
+
expect(builder.instance_eval { @book.creator_list[0].file_as }.to_s).to eq('1st')
|
121
|
+
expect(builder.instance_eval { @book.creator_list[1] }.to_s).to eq('Second Author')
|
122
|
+
expect(builder.instance_eval { @book.creator_list[1].file_as }.to_s).to eq('2nd')
|
123
|
+
expect(builder.instance_eval { @book.creator_list[2] }.to_s).to eq('Third Person')
|
124
|
+
expect(builder.instance_eval { @book.creator_list[2].file_as }.to_s).to eq('3rd')
|
125
|
+
expect(builder.instance_eval { @book.creator_list[2].role }.to_s).to eq('edt')
|
126
126
|
end
|
127
127
|
|
128
128
|
|
@@ -134,17 +134,17 @@ describe GEPUB::Builder do
|
|
134
134
|
'en' => ['first','second','third']
|
135
135
|
)
|
136
136
|
}
|
137
|
-
builder.instance_eval { @book.creator_list }.size.
|
138
|
-
builder.instance_eval { @book.creator_list[0] }.to_s.
|
139
|
-
builder.instance_eval { @book.creator_list[0].list_alternates['ja'] }.to_s.
|
140
|
-
builder.instance_eval { @book.creator_list[0].list_alternates['en'] }.to_s.
|
141
|
-
builder.instance_eval { @book.creator_list[1] }.to_s.
|
142
|
-
builder.instance_eval { @book.creator_list[1].list_alternates['ja'] }.to_s.
|
143
|
-
builder.instance_eval { @book.creator_list[1].list_alternates['en'] }.to_s.
|
144
|
-
builder.instance_eval { @book.creator_list[2] }.to_s.
|
145
|
-
builder.instance_eval { @book.creator_list[2].list_alternates['ja'] }.to_s.
|
146
|
-
builder.instance_eval { @book.creator_list[2].list_alternates['en'] }.to_s.
|
147
|
-
builder.instance_eval { @book.creator_list[2].role }.to_s.
|
137
|
+
expect(builder.instance_eval { @book.creator_list }.size).to eq(3)
|
138
|
+
expect(builder.instance_eval { @book.creator_list[0] }.to_s).to eq('First Author')
|
139
|
+
expect(builder.instance_eval { @book.creator_list[0].list_alternates['ja'] }.to_s).to eq('最初')
|
140
|
+
expect(builder.instance_eval { @book.creator_list[0].list_alternates['en'] }.to_s).to eq('first')
|
141
|
+
expect(builder.instance_eval { @book.creator_list[1] }.to_s).to eq('Second Author')
|
142
|
+
expect(builder.instance_eval { @book.creator_list[1].list_alternates['ja'] }.to_s).to eq('二番目')
|
143
|
+
expect(builder.instance_eval { @book.creator_list[1].list_alternates['en'] }.to_s).to eq('second')
|
144
|
+
expect(builder.instance_eval { @book.creator_list[2] }.to_s).to eq('Third Person')
|
145
|
+
expect(builder.instance_eval { @book.creator_list[2].list_alternates['ja'] }.to_s).to eq('三番目')
|
146
|
+
expect(builder.instance_eval { @book.creator_list[2].list_alternates['en'] }.to_s).to eq('third')
|
147
|
+
expect(builder.instance_eval { @book.creator_list[2].role }.to_s).to eq('edt')
|
148
148
|
end
|
149
149
|
end
|
150
150
|
context 'resources' do
|
@@ -155,8 +155,8 @@ describe GEPUB::Builder do
|
|
155
155
|
file('text/memo.txt')
|
156
156
|
}
|
157
157
|
}
|
158
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
159
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.
|
158
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
159
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }).to eq('just a plain text.')
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'should add files to book' do
|
@@ -166,9 +166,9 @@ describe GEPUB::Builder do
|
|
166
166
|
files('text/memo.txt','text/cover.xhtml')
|
167
167
|
}
|
168
168
|
}
|
169
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
170
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.
|
171
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
169
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
170
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }).to eq('just a plain text.')
|
171
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'should add files to book with glob' do
|
@@ -178,9 +178,9 @@ describe GEPUB::Builder do
|
|
178
178
|
glob 'text/*.{txt,xhtml}'
|
179
179
|
}
|
180
180
|
}
|
181
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
182
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.
|
183
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
181
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
182
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }).to eq('just a plain text.')
|
183
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'should add files to book with import with prefix' do
|
@@ -190,9 +190,9 @@ describe GEPUB::Builder do
|
|
190
190
|
import 'text/localresource.conf'
|
191
191
|
}
|
192
192
|
}
|
193
|
-
builder.instance_eval{ @book.item_by_href('memo.txt') }.
|
194
|
-
builder.instance_eval{ @book.item_by_href('memo.txt').content.chomp }.
|
195
|
-
builder.instance_eval{ @book.item_by_href('cover.xhtml') }.
|
193
|
+
expect(builder.instance_eval{ @book.item_by_href('memo.txt') }).not_to be_nil
|
194
|
+
expect(builder.instance_eval{ @book.item_by_href('memo.txt').content.chomp }).to eq('just a plain text.')
|
195
|
+
expect(builder.instance_eval{ @book.item_by_href('cover.xhtml') }).not_to be_nil
|
196
196
|
end
|
197
197
|
|
198
198
|
it 'should add files to book with import with prefix' do
|
@@ -202,9 +202,9 @@ describe GEPUB::Builder do
|
|
202
202
|
import 'text/localresource.conf', :dir_prefix => 'text'
|
203
203
|
}
|
204
204
|
}
|
205
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
206
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.
|
207
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
205
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
206
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }).to eq('just a plain text.')
|
207
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'should add a file with id' do
|
@@ -215,8 +215,8 @@ describe GEPUB::Builder do
|
|
215
215
|
id 'the_id_of_memo.txt'
|
216
216
|
}
|
217
217
|
}
|
218
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
219
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt').id }.
|
218
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
219
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt').id }).to eq('the_id_of_memo.txt')
|
220
220
|
end
|
221
221
|
|
222
222
|
it 'should add files to book from IO object' do
|
@@ -226,8 +226,8 @@ describe GEPUB::Builder do
|
|
226
226
|
file('text/memo.txt' => io)
|
227
227
|
}
|
228
228
|
}
|
229
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
230
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.
|
229
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
230
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }).to eq('just a plain text.')
|
231
231
|
end
|
232
232
|
|
233
233
|
it 'should add image file as cover' do
|
@@ -237,8 +237,8 @@ describe GEPUB::Builder do
|
|
237
237
|
cover_image 'img/cover.jpg'
|
238
238
|
}
|
239
239
|
}
|
240
|
-
builder.instance_eval{ @book.item_by_href('img/cover.jpg') }.
|
241
|
-
builder.instance_eval{ @book.item_by_href('img/cover.jpg').properties.member? 'cover-image' }.
|
240
|
+
expect(builder.instance_eval{ @book.item_by_href('img/cover.jpg') }).not_to be_nil
|
241
|
+
expect(builder.instance_eval{ @book.item_by_href('img/cover.jpg').properties.member? 'cover-image' }).to eq(true)
|
242
242
|
end
|
243
243
|
|
244
244
|
it 'should add file as nav' do
|
@@ -248,8 +248,8 @@ describe GEPUB::Builder do
|
|
248
248
|
nav 'text/nav.xhtml'
|
249
249
|
}
|
250
250
|
}
|
251
|
-
builder.instance_eval{ @book.item_by_href('text/nav.xhtml') }.
|
252
|
-
builder.instance_eval{ @book.item_by_href('text/nav.xhtml').properties.member? 'nav' }.
|
251
|
+
expect(builder.instance_eval{ @book.item_by_href('text/nav.xhtml') }).not_to be_nil
|
252
|
+
expect(builder.instance_eval{ @book.item_by_href('text/nav.xhtml').properties.member? 'nav' }).to eq(true)
|
253
253
|
end
|
254
254
|
|
255
255
|
it 'should specify mediatype' do
|
@@ -260,8 +260,8 @@ describe GEPUB::Builder do
|
|
260
260
|
media_type('audio/mp4')
|
261
261
|
}
|
262
262
|
}
|
263
|
-
builder.instance_eval{ @book.item_by_href('resources/noise.m4') }.
|
264
|
-
builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }.
|
263
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise.m4') }).not_to be_nil
|
264
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }).to eq('audio/mp4')
|
265
265
|
end
|
266
266
|
|
267
267
|
it 'should specify mediatype to files' do
|
@@ -272,11 +272,11 @@ describe GEPUB::Builder do
|
|
272
272
|
media_type('audio/mp4')
|
273
273
|
}
|
274
274
|
}
|
275
|
-
builder.instance_eval{ @book.item_by_href('resources/noise.m4') }.
|
276
|
-
builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }.
|
275
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise.m4') }).not_to be_nil
|
276
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }).to eq('audio/mp4')
|
277
277
|
|
278
|
-
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a') }.
|
279
|
-
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a').media_type }.
|
278
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a') }).not_to be_nil
|
279
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a').media_type }).to eq('audio/mp4')
|
280
280
|
end
|
281
281
|
|
282
282
|
it 'should specify mediatype to files using with_media_type' do
|
@@ -290,14 +290,14 @@ describe GEPUB::Builder do
|
|
290
290
|
file('text/cover.xhtml')
|
291
291
|
}
|
292
292
|
}
|
293
|
-
builder.instance_eval{ @book.item_by_href('resources/noise.m4') }.
|
294
|
-
builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }.
|
293
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise.m4') }).not_to be_nil
|
294
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }).to eq('audio/mp4')
|
295
295
|
|
296
|
-
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a') }.
|
297
|
-
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a').media_type }.
|
296
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a') }).not_to be_nil
|
297
|
+
expect(builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a').media_type }).to eq('audio/mp4')
|
298
298
|
|
299
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
300
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml').media_type }.
|
299
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
300
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml').media_type }).to eq('application/xhtml+xml')
|
301
301
|
end
|
302
302
|
|
303
303
|
it 'should specify bindings handler' do
|
@@ -322,10 +322,10 @@ describe GEPUB::Builder do
|
|
322
322
|
}
|
323
323
|
}
|
324
324
|
}
|
325
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
326
|
-
builder.instance_eval{ @book.spine_items[0].href }.
|
327
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
328
|
-
builder.instance_eval{ @book.spine_items[1].href }.
|
325
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
326
|
+
expect(builder.instance_eval{ @book.spine_items[0].href }).to eq('text/cover.xhtml')
|
327
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
328
|
+
expect(builder.instance_eval{ @book.spine_items[1].href }).to eq('text/memo.txt')
|
329
329
|
end
|
330
330
|
|
331
331
|
it 'should add files and heading' do
|
@@ -340,14 +340,14 @@ describe GEPUB::Builder do
|
|
340
340
|
}
|
341
341
|
}
|
342
342
|
}
|
343
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
344
|
-
builder.instance_eval{ @book.spine_items[0].href }.
|
345
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
346
|
-
builder.instance_eval{ @book.spine_items[1].href }.
|
347
|
-
builder.instance_eval{ @book.instance_eval { @toc[0][:item].href }}.
|
348
|
-
builder.instance_eval{ @book.instance_eval { @toc[0][:text] }}.
|
349
|
-
builder.instance_eval{ @book.instance_eval { @toc[1][:item].href }}.
|
350
|
-
builder.instance_eval{ @book.instance_eval { @toc[1][:text] }}.
|
343
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
344
|
+
expect(builder.instance_eval{ @book.spine_items[0].href }).to eq('text/cover.xhtml')
|
345
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
346
|
+
expect(builder.instance_eval{ @book.spine_items[1].href }).to eq('text/memo.txt')
|
347
|
+
expect(builder.instance_eval{ @book.instance_eval { @toc[0][:item].href }}).to eq('text/cover.xhtml')
|
348
|
+
expect(builder.instance_eval{ @book.instance_eval { @toc[0][:text] }}).to eq('cover page')
|
349
|
+
expect(builder.instance_eval{ @book.instance_eval { @toc[1][:item].href }}).to eq('text/memo.txt')
|
350
|
+
expect(builder.instance_eval{ @book.instance_eval { @toc[1][:text] }}).to eq('memo text')
|
351
351
|
end
|
352
352
|
|
353
353
|
it 'should add files and page-spread-property' do
|
@@ -362,10 +362,10 @@ describe GEPUB::Builder do
|
|
362
362
|
}
|
363
363
|
}
|
364
364
|
}
|
365
|
-
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.
|
366
|
-
builder.instance_eval{ @book.spine.itemref_list[0].properties[0] }.
|
367
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
368
|
-
builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }.
|
365
|
+
expect(builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }).not_to be_nil
|
366
|
+
expect(builder.instance_eval{ @book.spine.itemref_list[0].properties[0] }).to eq('page-spread-left')
|
367
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
368
|
+
expect(builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }).to eq('page-spread-right')
|
369
369
|
end
|
370
370
|
|
371
371
|
it 'should add files and rendition property' do
|
@@ -381,10 +381,10 @@ describe GEPUB::Builder do
|
|
381
381
|
}
|
382
382
|
}
|
383
383
|
}
|
384
|
-
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.
|
385
|
-
builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }.
|
386
|
-
builder.instance_eval{ @book.spine.itemref_list[1].properties[1] }.
|
387
|
-
builder.instance_eval{ @book.spine.itemref_list[1].properties[2] }.
|
384
|
+
expect(builder.instance_eval{ @book.item_by_href('text/memo.txt') }).not_to be_nil
|
385
|
+
expect(builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }).to eq('rendition:layout-pre-paginated')
|
386
|
+
expect(builder.instance_eval{ @book.spine.itemref_list[1].properties[1] }).to eq('rendition:orientation-landscape')
|
387
|
+
expect(builder.instance_eval{ @book.spine.itemref_list[1].properties[2] }).to eq('rendition:spread-both')
|
388
388
|
builder.instance_eval{
|
389
389
|
xml = Nokogiri::XML::Document.parse @book.opf_xml
|
390
390
|
xml.root['prefix'].should == 'rendition: http://www.idpf.org/vocab/rendition/#'
|
@@ -587,9 +587,9 @@ describe GEPUB::Builder do
|
|
587
587
|
builder.instance_eval {
|
588
588
|
@book.optional_files.size.should == 1
|
589
589
|
}
|
590
|
-
builder.instance_eval {
|
590
|
+
expect(builder.instance_eval {
|
591
591
|
@book.optional_files['META-INF/test.xml']
|
592
|
-
}.
|
592
|
+
}).not_to be_nil
|
593
593
|
end
|
594
594
|
end
|
595
595
|
end
|