review 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.travis.yml +9 -0
  2. data/ChangeLog +326 -0
  3. data/Rakefile +3 -5
  4. data/VERSION +1 -1
  5. data/bin/review-compile +50 -50
  6. data/bin/review-epubmaker +62 -75
  7. data/bin/review-epubmaker-ng +185 -0
  8. data/bin/review-index +2 -1
  9. data/bin/review-pdfmaker +158 -101
  10. data/bin/review-vol +6 -2
  11. data/doc/format.rdoc +111 -46
  12. data/doc/libepubmaker/sample.yaml +90 -0
  13. data/doc/quickstart.rdoc +188 -0
  14. data/doc/sample.yaml +8 -0
  15. data/lib/epubmaker.rb +28 -0
  16. data/lib/epubmaker/content.rb +82 -0
  17. data/lib/epubmaker/epubv2.rb +419 -0
  18. data/lib/epubmaker/epubv3.rb +249 -0
  19. data/lib/epubmaker/producer.rb +204 -0
  20. data/lib/epubmaker/resource.rb +66 -0
  21. data/lib/review.rb +1 -1
  22. data/lib/review/book.rb +27 -4
  23. data/lib/review/builder.rb +153 -20
  24. data/lib/review/compiler.rb +61 -10
  25. data/lib/review/ewbbuilder.rb +3 -2
  26. data/lib/review/htmlbuilder.rb +174 -67
  27. data/lib/review/i18n.rb +30 -0
  28. data/lib/review/i18n.yaml +23 -0
  29. data/lib/review/idgxmlbuilder.rb +110 -63
  30. data/lib/review/index.rb +34 -12
  31. data/lib/review/latexbuilder.rb +128 -33
  32. data/lib/review/latexutils.rb +18 -1
  33. data/lib/review/textbuilder.rb +17 -0
  34. data/lib/review/tocparser.rb +3 -1
  35. data/lib/review/tocprinter.rb +1 -0
  36. data/lib/review/topbuilder.rb +397 -198
  37. data/review.gemspec +101 -100
  38. data/test/test_book.rb +27 -0
  39. data/test/test_epubmaker.rb +507 -0
  40. data/test/test_helper.rb +8 -0
  41. data/test/test_htmlbuilder.rb +295 -10
  42. data/test/test_i18n.rb +64 -0
  43. data/test/test_idgxmlbuilder.rb +268 -10
  44. data/test/test_latexbuilder.rb +316 -20
  45. data/test/test_preprocessor.rb +23 -0
  46. data/test/test_topbuilder.rb +246 -0
  47. metadata +46 -53
  48. data/doc/format.re +0 -505
  49. data/test/test_index.rb +0 -15
data/review.gemspec CHANGED
@@ -1,122 +1,123 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{review}
8
- s.version = "0.9.0"
7
+ s.name = "review"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kmuto", "takahashim"]
12
- s.date = %q{2010-12-01}
13
- s.description = %q{ReVIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX.}
14
- s.email = %q{kmuto@debian.org}
15
- s.executables = ["review-check", "review-checkdep", "review-compile", "review-epubmaker", "review-index", "review-pdfmaker", "review-preproc", "review-validate", "review-vol"]
12
+ s.date = "2012-01-30"
13
+ s.description = "ReVIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX."
14
+ s.email = "kmuto@debian.org"
15
+ s.executables = ["review-check", "review-checkdep", "review-compile", "review-epubmaker", "review-epubmaker-ng", "review-index", "review-pdfmaker", "review-preproc", "review-validate", "review-vol"]
16
16
  s.extra_rdoc_files = [
17
17
  "ChangeLog",
18
- "README.rdoc"
18
+ "README.rdoc"
19
19
  ]
20
20
  s.files = [
21
+ ".travis.yml",
21
22
  "COPYING",
22
- "ChangeLog",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "bin/review-check",
27
- "bin/review-checkdep",
28
- "bin/review-compile",
29
- "bin/review-epubmaker",
30
- "bin/review-index",
31
- "bin/review-pdfmaker",
32
- "bin/review-preproc",
33
- "bin/review-validate",
34
- "bin/review-vol",
35
- "debian/README.Debian",
36
- "debian/README.source",
37
- "debian/changelog",
38
- "debian/compat",
39
- "debian/control",
40
- "debian/copyright",
41
- "debian/docs",
42
- "debian/manpage.1.ex",
43
- "debian/patches/path.diff",
44
- "debian/patches/series",
45
- "debian/review.install",
46
- "debian/review.links",
47
- "debian/rules",
48
- "debian/source/format",
49
- "doc/format.rdoc",
50
- "doc/format.re",
51
- "doc/format_idg.rdoc",
52
- "doc/ruby-uuid/README",
53
- "doc/ruby-uuid/README.ja",
54
- "doc/sample.css",
55
- "doc/sample.yaml",
56
- "lib/lineinput.rb",
57
- "lib/review.rb",
58
- "lib/review/book.rb",
59
- "lib/review/builder.rb",
60
- "lib/review/compat.rb",
61
- "lib/review/compiler.rb",
62
- "lib/review/epubbuilder.rb",
63
- "lib/review/ewbbuilder.rb",
64
- "lib/review/exception.rb",
65
- "lib/review/htmlbuilder.rb",
66
- "lib/review/htmllayout.rb",
67
- "lib/review/htmlutils.rb",
68
- "lib/review/idgxmlbuilder.rb",
69
- "lib/review/index.rb",
70
- "lib/review/latexbuilder.rb",
71
- "lib/review/latexindex.rb",
72
- "lib/review/latexutils.rb",
73
- "lib/review/preprocessor.rb",
74
- "lib/review/textutils.rb",
75
- "lib/review/tocparser.rb",
76
- "lib/review/tocprinter.rb",
77
- "lib/review/topbuilder.rb",
78
- "lib/review/unfold.rb",
79
- "lib/review/volume.rb",
80
- "lib/uuid.rb",
81
- "review.gemspec",
82
- "test/CHAPS",
83
- "test/bib.re",
84
- "test/test.re",
85
- "test/test_book.rb",
86
- "test/test_builder.rb",
87
- "test/test_helper.rb",
88
- "test/test_htmlbuilder.rb",
89
- "test/test_htmlutils.rb",
90
- "test/test_idgxmlbuilder.rb",
91
- "test/test_latexbuilder.rb",
92
- "test/test_lineinput.rb",
93
- "test/test_textutils.rb",
94
- "test/test_uuid.rb"
95
- ]
96
- s.homepage = %q{http://github.com/kmuto/review}
97
- s.rdoc_options = ["--charset=UTF-8"]
98
- s.require_paths = ["lib"]
99
- s.rubygems_version = %q{1.3.6}
100
- s.summary = %q{ReVIEW: a easy-to-use digital publishing system}
101
- s.test_files = [
23
+ "ChangeLog",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/review-check",
28
+ "bin/review-checkdep",
29
+ "bin/review-compile",
30
+ "bin/review-epubmaker",
31
+ "bin/review-epubmaker-ng",
32
+ "bin/review-index",
33
+ "bin/review-pdfmaker",
34
+ "bin/review-preproc",
35
+ "bin/review-validate",
36
+ "bin/review-vol",
37
+ "debian/README.Debian",
38
+ "debian/README.source",
39
+ "debian/changelog",
40
+ "debian/compat",
41
+ "debian/control",
42
+ "debian/copyright",
43
+ "debian/docs",
44
+ "debian/manpage.1.ex",
45
+ "debian/patches/path.diff",
46
+ "debian/patches/series",
47
+ "debian/review.install",
48
+ "debian/review.links",
49
+ "debian/rules",
50
+ "debian/source/format",
51
+ "doc/format.rdoc",
52
+ "doc/format_idg.rdoc",
53
+ "doc/libepubmaker/sample.yaml",
54
+ "doc/quickstart.rdoc",
55
+ "doc/ruby-uuid/README",
56
+ "doc/ruby-uuid/README.ja",
57
+ "doc/sample.css",
58
+ "doc/sample.yaml",
59
+ "lib/epubmaker.rb",
60
+ "lib/epubmaker/content.rb",
61
+ "lib/epubmaker/epubv2.rb",
62
+ "lib/epubmaker/epubv3.rb",
63
+ "lib/epubmaker/producer.rb",
64
+ "lib/epubmaker/resource.rb",
65
+ "lib/lineinput.rb",
66
+ "lib/review.rb",
67
+ "lib/review/book.rb",
68
+ "lib/review/builder.rb",
69
+ "lib/review/compat.rb",
70
+ "lib/review/compiler.rb",
71
+ "lib/review/epubbuilder.rb",
72
+ "lib/review/ewbbuilder.rb",
73
+ "lib/review/exception.rb",
74
+ "lib/review/htmlbuilder.rb",
75
+ "lib/review/htmllayout.rb",
76
+ "lib/review/htmlutils.rb",
77
+ "lib/review/i18n.rb",
78
+ "lib/review/i18n.yaml",
79
+ "lib/review/idgxmlbuilder.rb",
80
+ "lib/review/index.rb",
81
+ "lib/review/latexbuilder.rb",
82
+ "lib/review/latexindex.rb",
83
+ "lib/review/latexutils.rb",
84
+ "lib/review/preprocessor.rb",
85
+ "lib/review/textbuilder.rb",
86
+ "lib/review/textutils.rb",
87
+ "lib/review/tocparser.rb",
88
+ "lib/review/tocprinter.rb",
89
+ "lib/review/topbuilder.rb",
90
+ "lib/review/unfold.rb",
91
+ "lib/review/volume.rb",
92
+ "lib/uuid.rb",
93
+ "review.gemspec",
94
+ "test/CHAPS",
95
+ "test/bib.re",
96
+ "test/test.re",
102
97
  "test/test_book.rb",
103
- "test/test_builder.rb",
104
- "test/test_helper.rb",
105
- "test/test_htmlbuilder.rb",
106
- "test/test_htmlutils.rb",
107
- "test/test_idgxmlbuilder.rb",
108
- "test/test_index.rb",
109
- "test/test_latexbuilder.rb",
110
- "test/test_lineinput.rb",
111
- "test/test_textutils.rb",
112
- "test/test_uuid.rb"
98
+ "test/test_builder.rb",
99
+ "test/test_epubmaker.rb",
100
+ "test/test_helper.rb",
101
+ "test/test_htmlbuilder.rb",
102
+ "test/test_htmlutils.rb",
103
+ "test/test_i18n.rb",
104
+ "test/test_idgxmlbuilder.rb",
105
+ "test/test_latexbuilder.rb",
106
+ "test/test_lineinput.rb",
107
+ "test/test_preprocessor.rb",
108
+ "test/test_textutils.rb",
109
+ "test/test_topbuilder.rb",
110
+ "test/test_uuid.rb"
113
111
  ]
112
+ s.homepage = "http://github.com/kmuto/review"
113
+ s.require_paths = ["lib"]
114
+ s.rubygems_version = "1.8.10"
115
+ s.summary = "ReVIEW: a easy-to-use digital publishing system"
114
116
 
115
117
  if s.respond_to? :specification_version then
116
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
117
118
  s.specification_version = 3
118
119
 
119
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
120
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
120
121
  else
121
122
  end
122
123
  else
data/test/test_book.rb CHANGED
@@ -396,6 +396,13 @@ EOC
396
396
  assert_equal '', book.prefaces.name
397
397
  assert_equal 1, book.prefaces.chapters.size
398
398
  end
399
+
400
+ mktmpbookdir 'PREDEF' => 'chapter1.txt',
401
+ 'chapter1.txt' => '' do |dir, book, files|
402
+ assert_kind_of Part, book.prefaces
403
+ assert_equal '', book.prefaces.name
404
+ assert_equal 1, book.prefaces.chapters.size
405
+ end
399
406
  end
400
407
 
401
408
  def test_postscripts
@@ -571,6 +578,26 @@ EOC
571
578
  book.chapter('not exist')
572
579
  end
573
580
  end
581
+
582
+ mktmpbookdir 'CHAPS' => "ch1.txt\nch2.txt\n\nch3.txt",
583
+ 'preface.re' => '', 'postscript.re' => '' do |dir, book, files|
584
+ chapters = book.chapters
585
+ assert_equal 5, chapters.size
586
+
587
+ ch_names = %w(preface ch1 ch2 ch3 postscript)
588
+ tmp = []
589
+ book.each_chapter {|ch| tmp << ch.name }
590
+ assert_equal ch_names, tmp
591
+
592
+ ch_names.each do |name|
593
+ assert book.chapter(name)
594
+ assert_equal name, book.chapter(name).name
595
+ end
596
+
597
+ assert_raises IndexError,KeyError do
598
+ book.chapter('not exist')
599
+ end
600
+ end
574
601
  end
575
602
 
576
603
  def test_volume
@@ -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\n], @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