tmtms-review 1.0.0
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 +7 -0
- data/.travis.yml +9 -0
- data/COPYING +515 -0
- data/ChangeLog +2083 -0
- data/README.rdoc +50 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/bin/review-check +178 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +205 -0
- data/bin/review-epubmaker +661 -0
- data/bin/review-epubmaker-ng +176 -0
- data/bin/review-index +118 -0
- data/bin/review-pdfmaker +208 -0
- data/bin/review-preproc +142 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +102 -0
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +62 -0
- data/debian/docs +6 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/format.rdoc +582 -0
- data/doc/format_idg.rdoc +180 -0
- data/doc/libepubmaker/sample.yaml +90 -0
- data/doc/quickstart.rdoc +188 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +108 -0
- data/doc/sample.yaml +62 -0
- data/lib/epubmaker.rb +28 -0
- data/lib/epubmaker/content.rb +82 -0
- data/lib/epubmaker/epubv2.rb +418 -0
- data/lib/epubmaker/epubv3.rb +249 -0
- data/lib/epubmaker/producer.rb +204 -0
- data/lib/epubmaker/resource.rb +66 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review.rb +3 -0
- data/lib/review/book.rb +46 -0
- data/lib/review/book/base.rb +235 -0
- data/lib/review/book/chapter.rb +81 -0
- data/lib/review/book/compilable.rb +159 -0
- data/lib/review/book/index.rb +339 -0
- data/lib/review/book/page_metric.rb +38 -0
- data/lib/review/book/parameters.rb +97 -0
- data/lib/review/book/part.rb +44 -0
- data/lib/review/book/volume.rb +65 -0
- data/lib/review/builder.rb +444 -0
- data/lib/review/compiler.rb +550 -0
- data/lib/review/configure.rb +38 -0
- data/lib/review/epubbuilder.rb +18 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/extentions.rb +3 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/extentions/string.rb +33 -0
- data/lib/review/htmlbuilder.rb +1097 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +36 -0
- data/lib/review/i18n.rb +30 -0
- data/lib/review/i18n.yaml +34 -0
- data/lib/review/idgxmlbuilder.rb +1145 -0
- data/lib/review/latexbuilder.rb +815 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +79 -0
- data/lib/review/preprocessor.rb +563 -0
- data/lib/review/review.tex.erb +232 -0
- data/lib/review/textbuilder.rb +17 -0
- data/lib/review/textutils.rb +66 -0
- data/lib/review/tocparser.rb +342 -0
- data/lib/review/tocprinter.rb +221 -0
- data/lib/review/topbuilder.rb +785 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/uuid.rb +312 -0
- data/review.gemspec +141 -0
- data/test/CHAPS +2 -0
- data/test/bib.re +13 -0
- data/test/book_test_helper.rb +35 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +598 -0
- data/test/test_book_chapter.rb +418 -0
- data/test/test_book_parameter.rb +42 -0
- data/test/test_book_part.rb +50 -0
- data/test/test_builder.rb +144 -0
- data/test/test_compiler.rb +44 -0
- data/test/test_epubmaker.rb +507 -0
- data/test/test_helper.rb +27 -0
- data/test/test_htmlbuilder.rb +554 -0
- data/test/test_htmlutils.rb +28 -0
- data/test/test_i18n.rb +64 -0
- data/test/test_idgxmlbuilder.rb +589 -0
- data/test/test_index.rb +31 -0
- data/test/test_latexbuilder.rb +656 -0
- data/test/test_lineinput.rb +198 -0
- data/test/test_preprocessor.rb +23 -0
- data/test/test_textutils.rb +68 -0
- data/test/test_topbuilder.rb +244 -0
- data/test/test_uuid.rb +156 -0
- metadata +161 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'book_test_helper'
|
|
2
|
+
class PartTest < Test::Unit::TestCase
|
|
3
|
+
include BookTestHelper
|
|
4
|
+
|
|
5
|
+
def test_initialize
|
|
6
|
+
part = Book::Part.new(nil, nil, nil)
|
|
7
|
+
assert_equal nil, part.number
|
|
8
|
+
assert_equal nil, part.chapters
|
|
9
|
+
assert_equal '', part.name
|
|
10
|
+
|
|
11
|
+
part = Book::Part.new(nil, 123, [], 'name')
|
|
12
|
+
assert_equal 123, part.number
|
|
13
|
+
assert_equal [], part.chapters
|
|
14
|
+
assert_equal 'name', part.name
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_each_chapter
|
|
18
|
+
part = Book::Part.new(nil, nil, [1, 2, 3])
|
|
19
|
+
|
|
20
|
+
tmp = []
|
|
21
|
+
part.each_chapter do |ch|
|
|
22
|
+
tmp << ch
|
|
23
|
+
end
|
|
24
|
+
assert_equal [1, 2, 3], tmp
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_volume
|
|
28
|
+
part = Book::Part.new(nil, nil, [])
|
|
29
|
+
assert part.volume
|
|
30
|
+
assert_equal 0, part.volume.bytes
|
|
31
|
+
assert_equal 0, part.volume.chars
|
|
32
|
+
assert_equal 0, part.volume.lines
|
|
33
|
+
|
|
34
|
+
chs = []
|
|
35
|
+
Tempfile.open('part_test') do |o|
|
|
36
|
+
o.print "12345"
|
|
37
|
+
chs << Book::Chapter.new(nil, nil, nil, o.path)
|
|
38
|
+
end
|
|
39
|
+
Tempfile.open('part_test') do |o|
|
|
40
|
+
o.print "67890"
|
|
41
|
+
chs << Book::Chapter.new(nil, nil, nil, o.path)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
part = Book::Part.new(nil, nil, chs)
|
|
45
|
+
assert part.volume
|
|
46
|
+
assert part.volume.bytes > 0
|
|
47
|
+
assert part.volume.chars > 0
|
|
48
|
+
assert part.volume.lines > 0
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
require 'review/builder'
|
|
5
|
+
|
|
6
|
+
require 'review/book'
|
|
7
|
+
|
|
8
|
+
class MockCompiler
|
|
9
|
+
def text(s)
|
|
10
|
+
[:text, s]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class BuidlerTest < Test::Unit::TestCase
|
|
15
|
+
include ReVIEW
|
|
16
|
+
|
|
17
|
+
def setup
|
|
18
|
+
@b = Builder.new
|
|
19
|
+
@b.bind(MockCompiler.new, nil, nil)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_initialize
|
|
23
|
+
assert Builder.new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_bind
|
|
27
|
+
b = Builder.new
|
|
28
|
+
assert_nothing_raised do
|
|
29
|
+
b.bind(nil, nil, nil)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_result
|
|
34
|
+
b = Builder.new
|
|
35
|
+
assert_raises(NoMethodError) do # XXX: OK?
|
|
36
|
+
b.result
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
b = Builder.new
|
|
40
|
+
b.bind(nil, nil, nil)
|
|
41
|
+
assert_equal '', b.result
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_print_and_puts
|
|
45
|
+
b = Builder.new
|
|
46
|
+
assert_raises(NoMethodError) do # XXX: OK?
|
|
47
|
+
b.print ""
|
|
48
|
+
end
|
|
49
|
+
assert_raises(NoMethodError) do # XXX: OK?
|
|
50
|
+
b.puts ""
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
if "".respond_to?(:encode)
|
|
54
|
+
utf8_str = "あいうえお"
|
|
55
|
+
eucjp_str = "あいうえお".encode("EUC-JP")
|
|
56
|
+
sjis_str = "あいうえお".encode("Shift_JIS")
|
|
57
|
+
jis_str = "あいうえお".encode("ISO-2022-JP")
|
|
58
|
+
else
|
|
59
|
+
utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお"
|
|
60
|
+
eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"
|
|
61
|
+
sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"
|
|
62
|
+
jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
[
|
|
66
|
+
['EUC', eucjp_str],
|
|
67
|
+
['SJIS', sjis_str],
|
|
68
|
+
# ['JIS', jis_str],
|
|
69
|
+
# ['jis', jis_str],
|
|
70
|
+
# ['jIs', jis_str],
|
|
71
|
+
['XYZ', utf8_str],
|
|
72
|
+
].each do |enc, expect|
|
|
73
|
+
params = {"outencoding" => enc}
|
|
74
|
+
|
|
75
|
+
[
|
|
76
|
+
[:print, utf8_str, expect],
|
|
77
|
+
[:puts, utf8_str, "#{expect}\n"],
|
|
78
|
+
[:print, "#{utf8_str}\n", "#{expect}\n"],
|
|
79
|
+
[:puts, "#{utf8_str}\n", "#{expect}\n"],
|
|
80
|
+
].each do |m, instr, expstr|
|
|
81
|
+
b = Builder.new
|
|
82
|
+
b.bind(nil, nil, nil)
|
|
83
|
+
ReVIEW.book.param = params
|
|
84
|
+
b.__send__(m, instr)
|
|
85
|
+
if "".respond_to?(:encode)
|
|
86
|
+
assert_equal expstr.encode("UTF-8"), b.result
|
|
87
|
+
else
|
|
88
|
+
assert_equal expstr, b.result
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_not_implemented_methods
|
|
95
|
+
ex = NoMethodError # XXX: OK?
|
|
96
|
+
[
|
|
97
|
+
:list_header, :list_body, :listnum_body,
|
|
98
|
+
:source_header, :source_body,
|
|
99
|
+
:image_image, :image_dummy,
|
|
100
|
+
:table_header, :table_begin, :tr, :th, :table_end,
|
|
101
|
+
:compile_ruby, :compile_kw, :compile_href,
|
|
102
|
+
:bibpaper_header, :bibpaper_bibpaper,
|
|
103
|
+
:inline_hd_chap,
|
|
104
|
+
].each do |m|
|
|
105
|
+
b = Builder.new
|
|
106
|
+
assert_raises(ex) { b.__send__(m) }
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_compile_inline
|
|
111
|
+
text = "abc"
|
|
112
|
+
assert_equal [:text, text], @b.compile_inline(text)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_compile_inline_backslash
|
|
116
|
+
text = "abc\\d\\#a"
|
|
117
|
+
assert_equal [:text, text], @b.compile_inline(text)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_convert_outencoding
|
|
121
|
+
ReVIEW.book.param = {'outencoding' => "EUC"}
|
|
122
|
+
b = Builder.new
|
|
123
|
+
ret = b.convert_outencoding("a", ReVIEW.book.param["outencoding"])
|
|
124
|
+
assert_equal "a", ret
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class XBuilder < Builder
|
|
128
|
+
def list_header(id, caption)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def list_body(lines)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def listnum_body(lines)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def source_header(caption)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def source_body(lines)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
require 'review/compiler'
|
|
5
|
+
|
|
6
|
+
class CompilerTest < Test::Unit::TestCase
|
|
7
|
+
include ReVIEW
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
@builder = LATEXBuilder.new()
|
|
11
|
+
@c = Compiler.new(@builder)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_parse_args
|
|
15
|
+
args = @c.__send__(:parse_args, "[foo][bar]")
|
|
16
|
+
assert_equal ["foo","bar"], args
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_parse_args_with_brace1
|
|
20
|
+
args = @c.__send__(:parse_args, "[fo[\\][\\]o][bar]")
|
|
21
|
+
assert_equal ["fo[][]o","bar"], args
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_parse_args_with_brace2
|
|
25
|
+
args = @c.__send__(:parse_args, "[f\\]o\\]o][bar]")
|
|
26
|
+
assert_equal ["f]o]o","bar"], args
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_parse_args_with_backslash
|
|
30
|
+
args = @c.__send__(:parse_args, "[foo][bar\\buz]")
|
|
31
|
+
assert_equal ["foo","bar\\buz"], args
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_parse_args_with_backslash2
|
|
35
|
+
args = @c.__send__(:parse_args, "[foo][bar\\#\\[\\!]")
|
|
36
|
+
assert_equal ["foo","bar\\#\\[\\!"], args
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_parse_args_with_backslash3
|
|
40
|
+
args = @c.__send__(:parse_args, "[foo][bar\\\\buz]")
|
|
41
|
+
assert_equal ["foo","bar\\buz"], args
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
require 'epubmaker'
|
|
5
|
+
|
|
6
|
+
class EPUBMakerTest < Test::Unit::TestCase
|
|
7
|
+
include EPUBMaker
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
@producer = Producer.new
|
|
11
|
+
@producer.mergeparams({
|
|
12
|
+
"bookname" => "sample",
|
|
13
|
+
"title" => "Sample Book",
|
|
14
|
+
"version" => 2,
|
|
15
|
+
"urnid" => "http://example.jp/",
|
|
16
|
+
"date" => "2011-01-01",
|
|
17
|
+
"language" => "en",
|
|
18
|
+
})
|
|
19
|
+
@output = StringIO.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_initialize
|
|
23
|
+
assert Producer.new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_resource_en
|
|
27
|
+
@producer.mergeparams({"language" => "en"})
|
|
28
|
+
assert_equal "Table of Contents", @producer.res.v("toctitle")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_resource_ja
|
|
32
|
+
@producer.mergeparams({"language" => "ja"})
|
|
33
|
+
assert_equal "目次", @producer.res.v("toctitle")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_mimetype
|
|
37
|
+
@producer.mimetype(@output)
|
|
38
|
+
assert_equal %Q[application/epub+zip], @output.string
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_container
|
|
42
|
+
@producer.container(@output)
|
|
43
|
+
expect = <<EOT
|
|
44
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
45
|
+
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
|
|
46
|
+
<rootfiles>
|
|
47
|
+
<rootfile full-path="OEBPS/sample.opf" media-type="application/oebps-package+xml" />
|
|
48
|
+
</rootfiles>
|
|
49
|
+
</container>
|
|
50
|
+
EOT
|
|
51
|
+
assert_equal expect, @output.string
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_stage1_opf
|
|
55
|
+
@producer.opf(@output)
|
|
56
|
+
expect = <<EOT
|
|
57
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
58
|
+
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
|
59
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
|
60
|
+
<dc:title>Sample Book</dc:title>
|
|
61
|
+
<dc:language>en</dc:language>
|
|
62
|
+
<dc:date>2011-01-01</dc:date>
|
|
63
|
+
<dc:identifier id="BookId">http://example.jp/</dc:identifier>
|
|
64
|
+
</metadata>
|
|
65
|
+
<manifest>
|
|
66
|
+
<item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
|
|
67
|
+
<item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
|
|
68
|
+
</manifest>
|
|
69
|
+
<spine toc="ncx">
|
|
70
|
+
<itemref idref="sample" linear="no"/>
|
|
71
|
+
</spine>
|
|
72
|
+
<guide>
|
|
73
|
+
<reference type="cover" title="Cover" href="sample.html"/>
|
|
74
|
+
</guide>
|
|
75
|
+
</package>
|
|
76
|
+
EOT
|
|
77
|
+
assert_equal expect, @output.string
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_stage1_ncx
|
|
81
|
+
@producer.ncx(@output)
|
|
82
|
+
expect = <<EOT
|
|
83
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
84
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
|
85
|
+
<head>
|
|
86
|
+
<meta name="dtb:depth" content="1"/>
|
|
87
|
+
<meta name="dtb:totalPageCount" content="0"/>
|
|
88
|
+
<meta name="dtb:maxPageNumber" content="0"/>
|
|
89
|
+
<meta name="dtb:uid" content="http://example.jp/"/>
|
|
90
|
+
</head>
|
|
91
|
+
<docTitle>
|
|
92
|
+
<text>Sample Book</text>
|
|
93
|
+
</docTitle>
|
|
94
|
+
<docAuthor>
|
|
95
|
+
<text></text>
|
|
96
|
+
</docAuthor>
|
|
97
|
+
<navMap>
|
|
98
|
+
<navPoint id="top" playOrder="1">
|
|
99
|
+
<navLabel>
|
|
100
|
+
<text>Sample Book</text>
|
|
101
|
+
</navLabel>
|
|
102
|
+
<content src="sample.html"/>
|
|
103
|
+
</navPoint>
|
|
104
|
+
</navMap>
|
|
105
|
+
</ncx>
|
|
106
|
+
EOT
|
|
107
|
+
assert_equal expect, @output.string
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def stage2
|
|
111
|
+
# add one item
|
|
112
|
+
@producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_stage2_add_l1item
|
|
116
|
+
stage2
|
|
117
|
+
expect = EPUBMaker::Content.new("ch01.html",
|
|
118
|
+
"ch01-html",
|
|
119
|
+
"application/xhtml+xml",
|
|
120
|
+
"CH01",
|
|
121
|
+
1)
|
|
122
|
+
assert_equal expect, @producer.contents[0]
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_stage2_opf
|
|
126
|
+
stage2
|
|
127
|
+
@producer.opf(@output)
|
|
128
|
+
expect = <<EOT
|
|
129
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
130
|
+
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
|
131
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
|
132
|
+
<dc:title>Sample Book</dc:title>
|
|
133
|
+
<dc:language>en</dc:language>
|
|
134
|
+
<dc:date>2011-01-01</dc:date>
|
|
135
|
+
<dc:identifier id="BookId">http://example.jp/</dc:identifier>
|
|
136
|
+
</metadata>
|
|
137
|
+
<manifest>
|
|
138
|
+
<item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
|
|
139
|
+
<item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
|
|
140
|
+
<item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/>
|
|
141
|
+
</manifest>
|
|
142
|
+
<spine toc="ncx">
|
|
143
|
+
<itemref idref="sample" linear="no"/>
|
|
144
|
+
<itemref idref="ch01-html"/>
|
|
145
|
+
</spine>
|
|
146
|
+
<guide>
|
|
147
|
+
<reference type="cover" title="Cover" href="sample.html"/>
|
|
148
|
+
</guide>
|
|
149
|
+
</package>
|
|
150
|
+
EOT
|
|
151
|
+
assert_equal expect, @output.string
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_stage2_ncx
|
|
155
|
+
stage2
|
|
156
|
+
@producer.ncx(@output)
|
|
157
|
+
expect = <<EOT
|
|
158
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
159
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
|
160
|
+
<head>
|
|
161
|
+
<meta name="dtb:depth" content="1"/>
|
|
162
|
+
<meta name="dtb:totalPageCount" content="0"/>
|
|
163
|
+
<meta name="dtb:maxPageNumber" content="0"/>
|
|
164
|
+
<meta name="dtb:uid" content="http://example.jp/"/>
|
|
165
|
+
</head>
|
|
166
|
+
<docTitle>
|
|
167
|
+
<text>Sample Book</text>
|
|
168
|
+
</docTitle>
|
|
169
|
+
<docAuthor>
|
|
170
|
+
<text></text>
|
|
171
|
+
</docAuthor>
|
|
172
|
+
<navMap>
|
|
173
|
+
<navPoint id="top" playOrder="1">
|
|
174
|
+
<navLabel>
|
|
175
|
+
<text>Sample Book</text>
|
|
176
|
+
</navLabel>
|
|
177
|
+
<content src="sample.html"/>
|
|
178
|
+
</navPoint>
|
|
179
|
+
<navPoint id="nav-2" playOrder="2">
|
|
180
|
+
<navLabel>
|
|
181
|
+
<text>CH01</text>
|
|
182
|
+
</navLabel>
|
|
183
|
+
<content src="ch01.html"/>
|
|
184
|
+
</navPoint>
|
|
185
|
+
</navMap>
|
|
186
|
+
</ncx>
|
|
187
|
+
EOT
|
|
188
|
+
assert_equal expect, @output.string
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def stage3
|
|
192
|
+
# add more items
|
|
193
|
+
@producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
|
|
194
|
+
@producer.contents << Content.new({"file" => "ch02.html", "title" => "CH02", "level" => 1})
|
|
195
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
|
|
196
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1", "title" => "CH02.1.1", "level" => 3})
|
|
197
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1.1", "title" => "CH02.1.1.1", "level" => 4})
|
|
198
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1.1.1", "title" => "CH02.1.1.1.1", "level" => 5})
|
|
199
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1.2", "title" => "CH02.1.1.2", "level" => 4})
|
|
200
|
+
@producer.contents << Content.new({"file" => "ch02.html#S2", "title" => "CH02.2", "level" => 2})
|
|
201
|
+
@producer.contents << Content.new({"file" => "ch02.html#S2.1", "title" => "CH02.2.1", "level" => 3})
|
|
202
|
+
@producer.contents << Content.new({"file" => "ch03.html", "title" => "CH03", "level" => 1})
|
|
203
|
+
@producer.contents << Content.new({"file" => "ch03.html#S1", "title" => "CH03.1", "level" => 2})
|
|
204
|
+
@producer.contents << Content.new({"file" => "ch03.html#S1.1", "title" => "CH03.1.1", "level" => 3})
|
|
205
|
+
@producer.contents << Content.new({"file" => "ch04.html", "title" => "CH04", "level" => 1})
|
|
206
|
+
@producer.contents << Content.new({"file" => "sample.png"})
|
|
207
|
+
@producer.contents << Content.new({"file" => "sample.jpg"})
|
|
208
|
+
@producer.contents << Content.new({"file" => "sample.JPEG"})
|
|
209
|
+
@producer.contents << Content.new({"file" => "sample.SvG"})
|
|
210
|
+
@producer.contents << Content.new({"file" => "sample.GIF"})
|
|
211
|
+
@producer.contents << Content.new({"file" => "sample.css"})
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def test_stage3_add_various_items
|
|
215
|
+
stage3
|
|
216
|
+
expect = [
|
|
217
|
+
Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01", 1),
|
|
218
|
+
Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1),
|
|
219
|
+
Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2),
|
|
220
|
+
Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3),
|
|
221
|
+
Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4),
|
|
222
|
+
Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5),
|
|
223
|
+
Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4),
|
|
224
|
+
Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2),
|
|
225
|
+
Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3),
|
|
226
|
+
Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1),
|
|
227
|
+
Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2),
|
|
228
|
+
Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3),
|
|
229
|
+
Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1),
|
|
230
|
+
Content.new("sample.png", "sample-png", "image/png"),
|
|
231
|
+
Content.new("sample.jpg", "sample-jpg", "image/jpeg"),
|
|
232
|
+
Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"),
|
|
233
|
+
Content.new("sample.SvG", "sample-SvG", "image/svg+xml"),
|
|
234
|
+
Content.new("sample.GIF", "sample-GIF", "image/gif"),
|
|
235
|
+
Content.new("sample.css", "sample-css", "text/css")
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
assert_equal expect, @producer.contents
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def test_stage3_opf
|
|
242
|
+
stage3
|
|
243
|
+
@producer.opf(@output)
|
|
244
|
+
expect = <<EOT
|
|
245
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
246
|
+
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
|
247
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
|
248
|
+
<dc:title>Sample Book</dc:title>
|
|
249
|
+
<dc:language>en</dc:language>
|
|
250
|
+
<dc:date>2011-01-01</dc:date>
|
|
251
|
+
<dc:identifier id="BookId">http://example.jp/</dc:identifier>
|
|
252
|
+
</metadata>
|
|
253
|
+
<manifest>
|
|
254
|
+
<item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
|
|
255
|
+
<item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
|
|
256
|
+
<item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/>
|
|
257
|
+
<item id="ch02-html" href="ch02.html" media-type="application/xhtml+xml"/>
|
|
258
|
+
<item id="ch03-html" href="ch03.html" media-type="application/xhtml+xml"/>
|
|
259
|
+
<item id="ch04-html" href="ch04.html" media-type="application/xhtml+xml"/>
|
|
260
|
+
<item id="sample-png" href="sample.png" media-type="image/png"/>
|
|
261
|
+
<item id="sample-jpg" href="sample.jpg" media-type="image/jpeg"/>
|
|
262
|
+
<item id="sample-JPEG" href="sample.JPEG" media-type="image/jpeg"/>
|
|
263
|
+
<item id="sample-SvG" href="sample.SvG" media-type="image/svg+xml"/>
|
|
264
|
+
<item id="sample-GIF" href="sample.GIF" media-type="image/gif"/>
|
|
265
|
+
<item id="sample-css" href="sample.css" media-type="text/css"/>
|
|
266
|
+
</manifest>
|
|
267
|
+
<spine toc="ncx">
|
|
268
|
+
<itemref idref="sample" linear="no"/>
|
|
269
|
+
<itemref idref="ch01-html"/>
|
|
270
|
+
<itemref idref="ch02-html"/>
|
|
271
|
+
<itemref idref="ch03-html"/>
|
|
272
|
+
<itemref idref="ch04-html"/>
|
|
273
|
+
</spine>
|
|
274
|
+
<guide>
|
|
275
|
+
<reference type="cover" title="Cover" href="sample.html"/>
|
|
276
|
+
</guide>
|
|
277
|
+
</package>
|
|
278
|
+
EOT
|
|
279
|
+
assert_equal expect, @output.string
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def test_stage3_ncx
|
|
283
|
+
stage3
|
|
284
|
+
@producer.ncx(@output)
|
|
285
|
+
expect = <<EOT
|
|
286
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
287
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
|
288
|
+
<head>
|
|
289
|
+
<meta name="dtb:depth" content="1"/>
|
|
290
|
+
<meta name="dtb:totalPageCount" content="0"/>
|
|
291
|
+
<meta name="dtb:maxPageNumber" content="0"/>
|
|
292
|
+
<meta name="dtb:uid" content="http://example.jp/"/>
|
|
293
|
+
</head>
|
|
294
|
+
<docTitle>
|
|
295
|
+
<text>Sample Book</text>
|
|
296
|
+
</docTitle>
|
|
297
|
+
<docAuthor>
|
|
298
|
+
<text></text>
|
|
299
|
+
</docAuthor>
|
|
300
|
+
<navMap>
|
|
301
|
+
<navPoint id="top" playOrder="1">
|
|
302
|
+
<navLabel>
|
|
303
|
+
<text>Sample Book</text>
|
|
304
|
+
</navLabel>
|
|
305
|
+
<content src="sample.html"/>
|
|
306
|
+
</navPoint>
|
|
307
|
+
<navPoint id="nav-2" playOrder="2">
|
|
308
|
+
<navLabel>
|
|
309
|
+
<text>CH01</text>
|
|
310
|
+
</navLabel>
|
|
311
|
+
<content src="ch01.html"/>
|
|
312
|
+
</navPoint>
|
|
313
|
+
<navPoint id="nav-3" playOrder="3">
|
|
314
|
+
<navLabel>
|
|
315
|
+
<text>CH02</text>
|
|
316
|
+
</navLabel>
|
|
317
|
+
<content src="ch02.html"/>
|
|
318
|
+
</navPoint>
|
|
319
|
+
<navPoint id="nav-4" playOrder="4">
|
|
320
|
+
<navLabel>
|
|
321
|
+
<text>CH02.1</text>
|
|
322
|
+
</navLabel>
|
|
323
|
+
<content src="ch02.html#S1"/>
|
|
324
|
+
</navPoint>
|
|
325
|
+
<navPoint id="nav-5" playOrder="5">
|
|
326
|
+
<navLabel>
|
|
327
|
+
<text>CH02.1.1</text>
|
|
328
|
+
</navLabel>
|
|
329
|
+
<content src="ch02.html#S1.1"/>
|
|
330
|
+
</navPoint>
|
|
331
|
+
<navPoint id="nav-6" playOrder="6">
|
|
332
|
+
<navLabel>
|
|
333
|
+
<text>CH02.1.1.1</text>
|
|
334
|
+
</navLabel>
|
|
335
|
+
<content src="ch02.html#S1.1.1"/>
|
|
336
|
+
</navPoint>
|
|
337
|
+
<navPoint id="nav-7" playOrder="7">
|
|
338
|
+
<navLabel>
|
|
339
|
+
<text>CH02.1.1.1.1</text>
|
|
340
|
+
</navLabel>
|
|
341
|
+
<content src="ch02.html#S1.1.1.1"/>
|
|
342
|
+
</navPoint>
|
|
343
|
+
<navPoint id="nav-8" playOrder="8">
|
|
344
|
+
<navLabel>
|
|
345
|
+
<text>CH02.1.1.2</text>
|
|
346
|
+
</navLabel>
|
|
347
|
+
<content src="ch02.html#S1.1.2"/>
|
|
348
|
+
</navPoint>
|
|
349
|
+
<navPoint id="nav-9" playOrder="9">
|
|
350
|
+
<navLabel>
|
|
351
|
+
<text>CH02.2</text>
|
|
352
|
+
</navLabel>
|
|
353
|
+
<content src="ch02.html#S2"/>
|
|
354
|
+
</navPoint>
|
|
355
|
+
<navPoint id="nav-10" playOrder="10">
|
|
356
|
+
<navLabel>
|
|
357
|
+
<text>CH02.2.1</text>
|
|
358
|
+
</navLabel>
|
|
359
|
+
<content src="ch02.html#S2.1"/>
|
|
360
|
+
</navPoint>
|
|
361
|
+
<navPoint id="nav-11" playOrder="11">
|
|
362
|
+
<navLabel>
|
|
363
|
+
<text>CH03</text>
|
|
364
|
+
</navLabel>
|
|
365
|
+
<content src="ch03.html"/>
|
|
366
|
+
</navPoint>
|
|
367
|
+
<navPoint id="nav-12" playOrder="12">
|
|
368
|
+
<navLabel>
|
|
369
|
+
<text>CH03.1</text>
|
|
370
|
+
</navLabel>
|
|
371
|
+
<content src="ch03.html#S1"/>
|
|
372
|
+
</navPoint>
|
|
373
|
+
<navPoint id="nav-13" playOrder="13">
|
|
374
|
+
<navLabel>
|
|
375
|
+
<text>CH03.1.1</text>
|
|
376
|
+
</navLabel>
|
|
377
|
+
<content src="ch03.html#S1.1"/>
|
|
378
|
+
</navPoint>
|
|
379
|
+
<navPoint id="nav-14" playOrder="14">
|
|
380
|
+
<navLabel>
|
|
381
|
+
<text>CH04</text>
|
|
382
|
+
</navLabel>
|
|
383
|
+
<content src="ch04.html"/>
|
|
384
|
+
</navPoint>
|
|
385
|
+
</navMap>
|
|
386
|
+
</ncx>
|
|
387
|
+
EOT
|
|
388
|
+
assert_equal expect, @output.string
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
def test_stage3_mytoc
|
|
392
|
+
stage3
|
|
393
|
+
@producer.mytoc(@output)
|
|
394
|
+
expect = <<EOT
|
|
395
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
396
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
397
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
|
|
398
|
+
<head>
|
|
399
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
|
400
|
+
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
|
401
|
+
<meta name="generator" content="EPUBMaker::Producer"/>
|
|
402
|
+
<title>Table of Contents</title>
|
|
403
|
+
</head>
|
|
404
|
+
<body>
|
|
405
|
+
<h1 class="toc-title">Table of Contents</h1>
|
|
406
|
+
<ul class="toc-h1">
|
|
407
|
+
<li><a href="ch01.html">CH01</a></li>
|
|
408
|
+
<li><a href="ch02.html">CH02</a>
|
|
409
|
+
<ul class="toc-h2">
|
|
410
|
+
<li><a href="ch02.html#S1">CH02.1</a></li>
|
|
411
|
+
<li><a href="ch02.html#S2">CH02.2</a></li>
|
|
412
|
+
</ul>
|
|
413
|
+
</li>
|
|
414
|
+
<li><a href="ch03.html">CH03</a>
|
|
415
|
+
<ul class="toc-h2">
|
|
416
|
+
<li><a href="ch03.html#S1">CH03.1</a></li>
|
|
417
|
+
</ul>
|
|
418
|
+
</li>
|
|
419
|
+
<li><a href="ch04.html">CH04</a></li>
|
|
420
|
+
</ul>
|
|
421
|
+
</body>
|
|
422
|
+
</html>
|
|
423
|
+
EOT
|
|
424
|
+
assert_equal expect, @output.string
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def test_stage3_cover
|
|
428
|
+
stage3
|
|
429
|
+
@producer.cover(@output)
|
|
430
|
+
expect = <<EOT
|
|
431
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
432
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
433
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
|
|
434
|
+
<head>
|
|
435
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
|
436
|
+
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
|
437
|
+
<meta name="generator" content="EPUBMaker::Producer"/>
|
|
438
|
+
<title>Sample Book</title>
|
|
439
|
+
</head>
|
|
440
|
+
<body>
|
|
441
|
+
<h1 class="cover-title">Sample Book</h1>
|
|
442
|
+
</body>
|
|
443
|
+
</html>
|
|
444
|
+
EOT
|
|
445
|
+
assert_equal expect, @output.string
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def test_stage3_cover_with_image
|
|
449
|
+
stage3
|
|
450
|
+
@producer.params["coverimage"] = "sample.png"
|
|
451
|
+
@producer.cover(@output)
|
|
452
|
+
expect = <<EOT
|
|
453
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
454
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
455
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
|
|
456
|
+
<head>
|
|
457
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
|
458
|
+
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
|
459
|
+
<meta name="generator" content="EPUBMaker::Producer"/>
|
|
460
|
+
<title>Sample Book</title>
|
|
461
|
+
</head>
|
|
462
|
+
<body>
|
|
463
|
+
<div id="cover-image" class="cover-image">
|
|
464
|
+
<img src="sample.png" alt="Sample Book" class="max"/>
|
|
465
|
+
</div>
|
|
466
|
+
</body>
|
|
467
|
+
</html>
|
|
468
|
+
EOT
|
|
469
|
+
assert_equal expect, @output.string
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
def test_colophon_default
|
|
473
|
+
@producer.params["aut"] = "Mr.Smith"
|
|
474
|
+
@producer.params["prt"] = "BLUEPRINT"
|
|
475
|
+
@producer.colophon(@output)
|
|
476
|
+
expect = <<EOT
|
|
477
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
478
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
479
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
|
|
480
|
+
<head>
|
|
481
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
|
482
|
+
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
|
483
|
+
<meta name="generator" content="EPUBMaker::Producer"/>
|
|
484
|
+
<title>Colophon</title>
|
|
485
|
+
</head>
|
|
486
|
+
<body>
|
|
487
|
+
<div class="colophon">
|
|
488
|
+
<p class="title">Sample Book</p>
|
|
489
|
+
<table class="colophon">
|
|
490
|
+
<tr><th>Author</th><td>Mr.Smith</td></tr>
|
|
491
|
+
<tr><th>Publisher</th><td>BLUEPRINT</td></tr>
|
|
492
|
+
</table>
|
|
493
|
+
</div>
|
|
494
|
+
</body>
|
|
495
|
+
</html>
|
|
496
|
+
EOT
|
|
497
|
+
assert_equal expect, @output.string
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
# def test_duplicate_id
|
|
501
|
+
# stage3
|
|
502
|
+
# assert_raise(Error) do
|
|
503
|
+
# @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
|
|
504
|
+
# end
|
|
505
|
+
# end
|
|
506
|
+
|
|
507
|
+
end
|