review 5.6.0 → 5.7.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 +4 -4
- data/.github/workflows/rubocop.yml +31 -0
- data/.github/workflows/ruby-tex.yml +1 -1
- data/.github/workflows/ruby-win.yml +1 -1
- data/.github/workflows/ruby.yml +2 -2
- data/.rubocop.yml +13 -2
- data/NEWS.ja.md +22 -0
- data/NEWS.md +21 -0
- data/README.md +1 -1
- data/lib/review/book/base.rb +1 -1
- data/lib/review/builder.rb +4 -8
- data/lib/review/epubmaker/epubcommon.rb +13 -7
- data/lib/review/epubmaker/epubv2.rb +0 -5
- data/lib/review/epubmaker/epubv3.rb +9 -1
- data/lib/review/epubmaker/producer.rb +2 -3
- data/lib/review/epubmaker.rb +2 -4
- data/lib/review/htmlbuilder.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +4 -3
- data/lib/review/img_math.rb +9 -2
- data/lib/review/init.rb +3 -3
- data/lib/review/latexbuilder.rb +1 -1
- data/lib/review/lineinput.rb +2 -2
- data/lib/review/makerhelper.rb +2 -2
- data/lib/review/pdfmaker.rb +3 -5
- data/lib/review/update.rb +3 -7
- data/lib/review/version.rb +1 -1
- data/lib/review/yamlloader.rb +0 -3
- data/review.gemspec +2 -3
- data/samples/syntax-book/Gemfile +1 -1
- data/templates/opf/epubv2.opf.erb +2 -0
- data/templates/opf/epubv3.opf.erb +2 -0
- data/templates/opf/opf_manifest_epubv2.opf.erb +2 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +2 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +2 -0
- metadata +10 -139
- data/test/assets/black.eps +0 -280
- data/test/assets/fit.png +0 -0
- data/test/assets/header_listener.html +0 -35
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +0 -65
- data/test/assets/syntax_book_index_detail.txt +0 -60
- data/test/assets/test.xml.erb +0 -3
- data/test/assets/test_template.tex +0 -189
- data/test/assets/test_template_backmatter.tex +0 -200
- data/test/book_test_helper.rb +0 -44
- data/test/run_test.rb +0 -12
- data/test/test_book.rb +0 -588
- data/test/test_book_chapter.rb +0 -329
- data/test/test_book_part.rb +0 -53
- data/test/test_builder.rb +0 -128
- data/test/test_catalog.rb +0 -174
- data/test/test_catalog_converter_cmd.rb +0 -73
- data/test/test_compiler.rb +0 -52
- data/test/test_configure.rb +0 -91
- data/test/test_converter.rb +0 -21
- data/test/test_epub3maker.rb +0 -733
- data/test/test_epubmaker.rb +0 -931
- data/test/test_epubmaker_cmd.rb +0 -56
- data/test/test_extentions_hash.rb +0 -66
- data/test/test_helper.rb +0 -62
- data/test/test_htmlbuilder.rb +0 -3315
- data/test/test_htmltoc.rb +0 -29
- data/test/test_htmlutils.rb +0 -43
- data/test/test_i18n.rb +0 -300
- data/test/test_idgxmlbuilder.rb +0 -1529
- data/test/test_idgxmlmaker_cmd.rb +0 -50
- data/test/test_image_finder.rb +0 -81
- data/test/test_img_math.rb +0 -120
- data/test/test_index.rb +0 -287
- data/test/test_indexbuilder.rb +0 -52
- data/test/test_latexbuilder.rb +0 -2972
- data/test/test_latexbuilder_v2.rb +0 -1654
- data/test/test_lineinput.rb +0 -104
- data/test/test_location.rb +0 -30
- data/test/test_logger.rb +0 -33
- data/test/test_makerhelper.rb +0 -44
- data/test/test_markdownbuilder.rb +0 -371
- data/test/test_md2inaobuilder.rb +0 -90
- data/test/test_pdfmaker.rb +0 -354
- data/test/test_pdfmaker_cmd.rb +0 -130
- data/test/test_plaintextbuilder.rb +0 -1214
- data/test/test_preprocessor.rb +0 -196
- data/test/test_review_ext.rb +0 -30
- data/test/test_reviewheaderlistener.rb +0 -49
- data/test/test_rstbuilder.rb +0 -619
- data/test/test_sec_counter.rb +0 -156
- data/test/test_template.rb +0 -33
- data/test/test_textmaker_cmd.rb +0 -58
- data/test/test_textutils.rb +0 -187
- data/test/test_tocprinter.rb +0 -46
- data/test/test_topbuilder.rb +0 -1301
- data/test/test_update.rb +0 -473
- data/test/test_webtocprinter.rb +0 -195
- data/test/test_yamlloader.rb +0 -186
- data/test/test_zip_exporter.rb +0 -106
data/test/test_update.rb
DELETED
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'review/update'
|
|
3
|
-
require 'tmpdir'
|
|
4
|
-
require 'fileutils'
|
|
5
|
-
|
|
6
|
-
class UpdateTest < Test::Unit::TestCase
|
|
7
|
-
include ReVIEW
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
@tmpdir = Dir.mktmpdir
|
|
11
|
-
@u = Update.new
|
|
12
|
-
@u.force = true
|
|
13
|
-
I18n.setup('en')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def teardown
|
|
17
|
-
FileUtils.rm_rf(@tmpdir)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_broken_yml
|
|
21
|
-
File.write(File.join(@tmpdir, 'test.yml'), "invalid: [,]\n")
|
|
22
|
-
io = StringIO.new
|
|
23
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
24
|
-
@u.parse_ymls(@tmpdir)
|
|
25
|
-
assert_match(/test\.yml is broken\. Ignored\./, io.string)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_rewrite_yml
|
|
29
|
-
File.write(File.join(@tmpdir, 'test.yml'), "key: foo1\n key: foo2\n\t\t key: foo3\nakey: foo3\nkeya: foo4\n")
|
|
30
|
-
@u.rewrite_yml(File.join(@tmpdir, 'test.yml'), 'key', 'val')
|
|
31
|
-
cont = <<EOT
|
|
32
|
-
key: val
|
|
33
|
-
key: val
|
|
34
|
-
key: val
|
|
35
|
-
akey: foo3
|
|
36
|
-
keya: foo4
|
|
37
|
-
EOT
|
|
38
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'test.yml'))
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_yml_variation
|
|
42
|
-
File.write(File.join(@tmpdir, 'config.yml'), "review_version: 2.0\nlanguage: en\n")
|
|
43
|
-
File.write(File.join(@tmpdir, 'tex1.yml'), %Q(review_version: 2.0\ntexdocumentclass: ["jsbook", "uplatex,twoside"]\n))
|
|
44
|
-
File.write(File.join(@tmpdir, 'epub1.yml'), "htmlversion: 4\nepubversion: 2\n")
|
|
45
|
-
File.write(File.join(@tmpdir, 'locale.yml'), "locale: ja\n")
|
|
46
|
-
File.write(File.join(@tmpdir, 'locale2.yml'), "locale: en\n")
|
|
47
|
-
File.write(File.join(@tmpdir, 'catalog.yml'), "PREDEF:\n - pr01.re\n")
|
|
48
|
-
File.write(File.join(@tmpdir, 'catalog2.yml'), "CHAPS:\n - ch01.re\n")
|
|
49
|
-
File.write(File.join(@tmpdir, 'catalog3.yml'), "APPENDIX:\n - app01.re\n")
|
|
50
|
-
|
|
51
|
-
@u.parse_ymls(@tmpdir)
|
|
52
|
-
|
|
53
|
-
assert_equal 2, @u.config_ymls.size
|
|
54
|
-
assert_equal 2, @u.locale_ymls.size
|
|
55
|
-
assert_equal 3, @u.catalog_ymls.size
|
|
56
|
-
assert_equal 1, @u.tex_ymls.size
|
|
57
|
-
assert_equal 1, @u.epub_ymls.size
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def test_check_old_catalogs
|
|
61
|
-
%w[PREDEF CHAPS POSTDEF PART].each do |fname|
|
|
62
|
-
File.write(File.join(@tmpdir, fname), '')
|
|
63
|
-
|
|
64
|
-
io = StringIO.new
|
|
65
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
66
|
-
assert_raise(ApplicationError) { @u.check_old_catalogs(@tmpdir) }
|
|
67
|
-
assert_match(/review-catalog-converter/, io.string)
|
|
68
|
-
|
|
69
|
-
File.unlink(File.join(@tmpdir, fname))
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def test_check_own_files_layout
|
|
74
|
-
Dir.mkdir(File.join(@tmpdir, 'layouts'))
|
|
75
|
-
File.write(File.join(@tmpdir, 'layouts/layout.tex.erb'), '')
|
|
76
|
-
|
|
77
|
-
io = StringIO.new
|
|
78
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
79
|
-
assert_raise(ApplicationError) { @u.check_own_files(@tmpdir) }
|
|
80
|
-
assert_match(%r{There is custom layouts/layout\.tex\.erb file}, io.string)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def test_check_own_files_reviewext
|
|
84
|
-
File.write(File.join(@tmpdir, 'review-ext.rb'), '')
|
|
85
|
-
|
|
86
|
-
io = StringIO.new
|
|
87
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
88
|
-
@u.check_own_files(@tmpdir)
|
|
89
|
-
assert_match(/There is review-ext\.rb file/, io.string)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def test_update_version_older
|
|
93
|
-
File.write(File.join(@tmpdir, 'config.yml'), "review_version: 2.0\n")
|
|
94
|
-
|
|
95
|
-
io = StringIO.new
|
|
96
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
97
|
-
@u.parse_ymls(@tmpdir)
|
|
98
|
-
@u.update_version
|
|
99
|
-
assert_match(/Update 'review_version' to '5.0'/, io.string)
|
|
100
|
-
assert_equal 'review_version: 5.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
|
|
101
|
-
|
|
102
|
-
File.write(File.join(@tmpdir, 'config.yml'), "review_version: 3.0\n")
|
|
103
|
-
|
|
104
|
-
io = StringIO.new
|
|
105
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
106
|
-
@u.parse_ymls(@tmpdir)
|
|
107
|
-
@u.update_version
|
|
108
|
-
assert_match(/Update 'review_version' to '5.0'/, io.string)
|
|
109
|
-
assert_equal 'review_version: 5.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def test_update_version_current
|
|
113
|
-
File.write(File.join(@tmpdir, 'config.yml'), "review_version: 5.0\n")
|
|
114
|
-
|
|
115
|
-
io = StringIO.new
|
|
116
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
117
|
-
@u.parse_ymls(@tmpdir)
|
|
118
|
-
@u.update_version
|
|
119
|
-
assert_equal '', io.string
|
|
120
|
-
assert_equal 'review_version: 5.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def test_update_version_newer
|
|
124
|
-
File.write(File.join(@tmpdir, 'config.yml'), "review_version: 99.0\n")
|
|
125
|
-
|
|
126
|
-
io = StringIO.new
|
|
127
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
128
|
-
@u.parse_ymls(@tmpdir)
|
|
129
|
-
@u.update_version
|
|
130
|
-
assert_match(/Update 'review_version' to '5.0'/, io.string)
|
|
131
|
-
assert_equal 'review_version: 99.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def test_update_rakefile
|
|
135
|
-
io = StringIO.new
|
|
136
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
137
|
-
@u.update_rakefile(@tmpdir)
|
|
138
|
-
assert_equal '', io.string
|
|
139
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'Rakefile'))
|
|
140
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'lib/tasks/review.rake'))
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
def test_update_rakefile_same
|
|
144
|
-
io = StringIO.new
|
|
145
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
146
|
-
@u.update_rakefile(@tmpdir)
|
|
147
|
-
@u.update_rakefile(@tmpdir)
|
|
148
|
-
assert_equal '', io.string
|
|
149
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'Rakefile'))
|
|
150
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'lib/tasks/review.rake'))
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def test_update_rakefile_different
|
|
154
|
-
File.write(File.join(@tmpdir, 'Rakefile'), '')
|
|
155
|
-
FileUtils.mkdir_p(File.join(@tmpdir, 'lib/tasks'))
|
|
156
|
-
File.write(File.join(@tmpdir, 'lib/tasks/review.rake'), '')
|
|
157
|
-
io = StringIO.new
|
|
158
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
159
|
-
@u.update_rakefile(@tmpdir)
|
|
160
|
-
assert_match(/Rakefile will be overridden with/, io.string)
|
|
161
|
-
assert_match(%r{lib/tasks/review\.rake will be overridden}, io.string)
|
|
162
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'Rakefile'))
|
|
163
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'lib/tasks/review.rake'))
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def test_update_epub_version_older
|
|
167
|
-
File.write(File.join(@tmpdir, 'config.yml'), "epubversion: 2\nhtmlversion: 4\n")
|
|
168
|
-
io = StringIO.new
|
|
169
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
170
|
-
@u.parse_ymls(@tmpdir)
|
|
171
|
-
@u.update_epub_version
|
|
172
|
-
assert_match(/Update 'epubversion'/, io.string)
|
|
173
|
-
assert_match(/Update 'htmlversion'/, io.string)
|
|
174
|
-
cont = <<EOT
|
|
175
|
-
epubversion: 3
|
|
176
|
-
htmlversion: 5
|
|
177
|
-
EOT
|
|
178
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def test_update_epub_version_current
|
|
182
|
-
File.write(File.join(@tmpdir, 'config.yml'), "epubversion: 3\nhtmlversion: 5\n")
|
|
183
|
-
io = StringIO.new
|
|
184
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
185
|
-
@u.parse_ymls(@tmpdir)
|
|
186
|
-
@u.update_epub_version
|
|
187
|
-
assert_equal '', io.string
|
|
188
|
-
cont = <<EOT
|
|
189
|
-
epubversion: 3
|
|
190
|
-
htmlversion: 5
|
|
191
|
-
EOT
|
|
192
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def test_update_epub_version_newer
|
|
196
|
-
File.write(File.join(@tmpdir, 'config.yml'), "epubversion: 99\nhtmlversion: 99\n")
|
|
197
|
-
io = StringIO.new
|
|
198
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
199
|
-
@u.parse_ymls(@tmpdir)
|
|
200
|
-
@u.update_epub_version
|
|
201
|
-
assert_equal '', io.string
|
|
202
|
-
cont = <<EOT
|
|
203
|
-
epubversion: 99
|
|
204
|
-
htmlversion: 99
|
|
205
|
-
EOT
|
|
206
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def test_update_locale_older
|
|
210
|
-
File.write(File.join(@tmpdir, 'locale.yml'), %Q(locale: en\nchapter_quote: "'%s'"\n))
|
|
211
|
-
io = StringIO.new
|
|
212
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
213
|
-
@u.parse_ymls(@tmpdir)
|
|
214
|
-
@u.update_locale
|
|
215
|
-
assert_match(/'chapter_quote' now takes 2 values/, io.string)
|
|
216
|
-
cont = <<EOT
|
|
217
|
-
locale: en
|
|
218
|
-
chapter_quote: '%s %s'
|
|
219
|
-
EOT
|
|
220
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'locale.yml'))
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def test_update_locale_current
|
|
224
|
-
File.write(File.join(@tmpdir, 'locale.yml'), %Q(locale: en\nchapter_quote: "'%s...%s'"\n))
|
|
225
|
-
io = StringIO.new
|
|
226
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
227
|
-
@u.parse_ymls(@tmpdir)
|
|
228
|
-
@u.update_locale
|
|
229
|
-
assert_equal '', io.string
|
|
230
|
-
cont = <<EOT
|
|
231
|
-
locale: en
|
|
232
|
-
chapter_quote: "'%s...%s'"
|
|
233
|
-
EOT
|
|
234
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'locale.yml'))
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
def test_update_tex_parameters_jsbook_to_review_jsbook
|
|
238
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["jsbook", "a5j,11pt,landscape,oneside,twoside,vartwoside,onecolumn,twocolumn,titlepage,notitlepage,openright,openany,leqno,fleqn,disablejfam,draft,final,mingoth,winjis,jis,papersize,english,report,jslogo,nojslogo,uplatex,nomag,usemag,nomag*,tombow,tombo,mentuke,autodetect-engine"]\n))
|
|
239
|
-
io = StringIO.new
|
|
240
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
241
|
-
@u.parse_ymls(@tmpdir)
|
|
242
|
-
@u.update_tex_parameters
|
|
243
|
-
assert_match(/By default it is migrated to/, io.string)
|
|
244
|
-
assert_match(/is safely replaced/, io.string)
|
|
245
|
-
cont = <<EOT
|
|
246
|
-
texdocumentclass: ["review-jsbook", "paper=a5,fontsize=11pt,landscape,oneside,twoside,vartwoside,onecolumn,twocolumn,titlepage,notitlepage,openright,openany,leqno,fleqn,disablejfam,draft,final,mingoth,winjis,jis,papersize,english,report,jslogo,nojslogo,media=print,cover=false"]
|
|
247
|
-
EOT
|
|
248
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
def test_update_tex_parameters_jsbook_to_review_jsbook_invalid
|
|
252
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["jsbook", "a5paper,invalid"]\n))
|
|
253
|
-
io = StringIO.new
|
|
254
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
255
|
-
@u.parse_ymls(@tmpdir)
|
|
256
|
-
@u.update_tex_parameters
|
|
257
|
-
assert_match(/couldn't be converted fully/, io.string)
|
|
258
|
-
assert_match("'paper=a5,media=print,cover=false' is suggested", io.string)
|
|
259
|
-
cont = <<EOT
|
|
260
|
-
texdocumentclass: ["jsbook", "a5paper,invalid"]
|
|
261
|
-
EOT
|
|
262
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
def test_update_tex_parameters_review_jsbook
|
|
266
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jsbook", ""]\n))
|
|
267
|
-
io = StringIO.new
|
|
268
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
269
|
-
@u.parse_ymls(@tmpdir)
|
|
270
|
-
@u.update_tex_parameters
|
|
271
|
-
assert_equal '', io.string
|
|
272
|
-
cont = <<EOT
|
|
273
|
-
texdocumentclass: ["review-jsbook", ""]
|
|
274
|
-
EOT
|
|
275
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
def test_update_tex_parameters_review_jsbook_obsoletekey
|
|
279
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jsbook", "Q=13.5, H=20, W=40, L=34, head=20mm, gutter=20mm"]\n))
|
|
280
|
-
io = StringIO.new
|
|
281
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
282
|
-
@u.parse_ymls(@tmpdir)
|
|
283
|
-
@u.update_tex_parameters
|
|
284
|
-
cont = <<EOT
|
|
285
|
-
texdocumentclass: ["review-jsbook", "fontsize=13.5Q, baselineskip=20H, line_length=40zw, number_of_lines=34, head_space=20mm, gutter=20mm"]
|
|
286
|
-
EOT
|
|
287
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
def test_update_tex_parameters_review_jlreq
|
|
291
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jlreq", ""]\n))
|
|
292
|
-
io = StringIO.new
|
|
293
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
294
|
-
@u.parse_ymls(@tmpdir)
|
|
295
|
-
@u.update_tex_parameters
|
|
296
|
-
assert_equal '', io.string
|
|
297
|
-
cont = <<EOT
|
|
298
|
-
texdocumentclass: ["review-jlreq", ""]
|
|
299
|
-
EOT
|
|
300
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
def test_update_tex_parameters_review_jsbook_review_jlreq
|
|
304
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jsbook", ""]\n))
|
|
305
|
-
io = StringIO.new
|
|
306
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
307
|
-
@u.parse_ymls(@tmpdir)
|
|
308
|
-
@u.specified_template = 'review-jlreq'
|
|
309
|
-
@u.update_tex_parameters
|
|
310
|
-
assert_match(/already, but you specified/, io.string)
|
|
311
|
-
cont = <<EOT
|
|
312
|
-
texdocumentclass: ["review-jsbook", ""]
|
|
313
|
-
EOT
|
|
314
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
def test_update_tex_parameters_unknownclass
|
|
318
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["unknown", ""]\n))
|
|
319
|
-
io = StringIO.new
|
|
320
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
321
|
-
@u.parse_ymls(@tmpdir)
|
|
322
|
-
@u.update_tex_parameters
|
|
323
|
-
assert_match(/unknown class/, io.string)
|
|
324
|
-
cont = <<EOT
|
|
325
|
-
texdocumentclass: ["unknown", ""]
|
|
326
|
-
EOT
|
|
327
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
def test_update_tex_parameters_jsbook_unknownclass
|
|
331
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["jsbook", ""]\n))
|
|
332
|
-
io = StringIO.new
|
|
333
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
334
|
-
@u.parse_ymls(@tmpdir)
|
|
335
|
-
@u.specified_template = 'unknown'
|
|
336
|
-
@u.update_tex_parameters
|
|
337
|
-
assert_match(/unknown class/, io.string)
|
|
338
|
-
cont = <<EOT
|
|
339
|
-
texdocumentclass: ["jsbook", ""]
|
|
340
|
-
EOT
|
|
341
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
def test_update_tex_parameters_jsbook_to_review_jlreq
|
|
345
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["jsbook", "a5j,11pt,landscape,oneside,twoside,onecolumn,twocolumn,titlepage,notitlepage,openright,openany,leqno,fleqn,draft,final,report,uplatex,nomag,usemag,nomag*,tombow,tombo,mentuke,autodetect-engine"]\n))
|
|
346
|
-
io = StringIO.new
|
|
347
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
348
|
-
@u.parse_ymls(@tmpdir)
|
|
349
|
-
@u.specified_template = 'review-jlreq'
|
|
350
|
-
@u.update_tex_parameters
|
|
351
|
-
assert_match(/By default it is migrated to/, io.string)
|
|
352
|
-
assert_match(/is safely replaced/, io.string)
|
|
353
|
-
cont = <<EOT
|
|
354
|
-
texdocumentclass: ["review-jlreq", "paper=a5,fontsize=11pt,landscape,oneside,twoside,onecolumn,twocolumn,titlepage,notitlepage,openright,openany,leqno,fleqn,draft,final,report,media=print,cover=false"]
|
|
355
|
-
EOT
|
|
356
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
def test_update_stys_new
|
|
360
|
-
io = StringIO.new
|
|
361
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
362
|
-
@u.update_tex_stys('review-jsbook', @tmpdir)
|
|
363
|
-
assert_equal '', io.string
|
|
364
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'sty/review-base.sty'))
|
|
365
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'sty/gentombow.sty'))
|
|
366
|
-
assert_equal true, File.exist?(File.join(@tmpdir, 'sty/jsbook.cls'))
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
def test_update_stys_new_custom
|
|
370
|
-
io = StringIO.new
|
|
371
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
372
|
-
@u.update_tex_stys('review-jsbook', @tmpdir)
|
|
373
|
-
assert_equal '', io.string
|
|
374
|
-
File.write(File.join(@tmpdir, 'sty/review-custom.sty'), "% MY CUSTOM\n")
|
|
375
|
-
@u.update_tex_stys('review-jsbook', @tmpdir)
|
|
376
|
-
assert_equal '', io.string
|
|
377
|
-
assert_equal "% MY CUSTOM\n", File.read(File.join(@tmpdir, 'sty/review-custom.sty'))
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
def test_update_stys_modified
|
|
381
|
-
io = StringIO.new
|
|
382
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
383
|
-
@u.update_tex_stys('review-jsbook', @tmpdir)
|
|
384
|
-
cont = File.read(File.join(@tmpdir, 'sty/review-base.sty'))
|
|
385
|
-
|
|
386
|
-
File.write(File.join(@tmpdir, 'sty/review-base.sty'), "% MODIFIED\n")
|
|
387
|
-
@u.update_tex_stys('review-jsbook', @tmpdir)
|
|
388
|
-
assert_match(/review-base\.sty will be overridden/, io.string)
|
|
389
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'sty/review-base.sty'))
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
def test_update_tex_command
|
|
393
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texcommand: "/Program Files/up-latex --shell-escape -v"\n))
|
|
394
|
-
io = StringIO.new
|
|
395
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
396
|
-
@u.parse_ymls(@tmpdir)
|
|
397
|
-
@u.update_tex_command
|
|
398
|
-
assert_match(/has options/, io.string)
|
|
399
|
-
cont = <<EOT
|
|
400
|
-
texcommand: "/Program Files/up-latex"
|
|
401
|
-
texoptions: "-interaction=nonstopmode -file-line-error -halt-on-error --shell-escape -v"
|
|
402
|
-
EOT
|
|
403
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
404
|
-
end
|
|
405
|
-
|
|
406
|
-
def test_update_tex_command_noopt
|
|
407
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texcommand: "/Program Files/up-latex"\n))
|
|
408
|
-
io = StringIO.new
|
|
409
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
410
|
-
@u.parse_ymls(@tmpdir)
|
|
411
|
-
@u.update_tex_command
|
|
412
|
-
assert_equal '', io.string
|
|
413
|
-
cont = <<EOT
|
|
414
|
-
texcommand: "/Program Files/up-latex"
|
|
415
|
-
EOT
|
|
416
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
417
|
-
end
|
|
418
|
-
|
|
419
|
-
def test_update_tex_command_withopt
|
|
420
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(texcommand: "/Program Files/up-latex --shell-escape -v"\ntexoptions: "-myopt"\n))
|
|
421
|
-
io = StringIO.new
|
|
422
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
423
|
-
@u.parse_ymls(@tmpdir)
|
|
424
|
-
@u.update_tex_command
|
|
425
|
-
assert_match(/has options/, io.string)
|
|
426
|
-
cont = <<EOT
|
|
427
|
-
texcommand: "/Program Files/up-latex"
|
|
428
|
-
texoptions: "-myopt --shell-escape -v"
|
|
429
|
-
EOT
|
|
430
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
431
|
-
end
|
|
432
|
-
|
|
433
|
-
def test_update_dvi_command
|
|
434
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(dvicommand: "/Program Files/dvi-pdfmx -q --quiet"\n))
|
|
435
|
-
io = StringIO.new
|
|
436
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
437
|
-
@u.parse_ymls(@tmpdir)
|
|
438
|
-
@u.update_dvi_command
|
|
439
|
-
assert_match(/has options/, io.string)
|
|
440
|
-
cont = <<EOT
|
|
441
|
-
dvicommand: "/Program Files/dvi-pdfmx"
|
|
442
|
-
dvioptions: "-d 5 -z 9 -q --quiet"
|
|
443
|
-
EOT
|
|
444
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
445
|
-
end
|
|
446
|
-
|
|
447
|
-
def test_update_dvi_command_noopt
|
|
448
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(dvicommand: "/Program Files/dvi-pdfmx"\n))
|
|
449
|
-
io = StringIO.new
|
|
450
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
451
|
-
@u.parse_ymls(@tmpdir)
|
|
452
|
-
@u.update_dvi_command
|
|
453
|
-
assert_equal '', io.string
|
|
454
|
-
cont = <<EOT
|
|
455
|
-
dvicommand: "/Program Files/dvi-pdfmx"
|
|
456
|
-
EOT
|
|
457
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
def test_update_dvi_command_withopt
|
|
461
|
-
File.write(File.join(@tmpdir, 'config.yml'), %Q(dvicommand: "/Program Files/dvi-pdfmx -q --quiet"\ndvioptions: "-myopt"\n))
|
|
462
|
-
io = StringIO.new
|
|
463
|
-
@u.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
|
464
|
-
@u.parse_ymls(@tmpdir)
|
|
465
|
-
@u.update_dvi_command
|
|
466
|
-
assert_match(/has options/, io.string)
|
|
467
|
-
cont = <<EOT
|
|
468
|
-
dvicommand: "/Program Files/dvi-pdfmx"
|
|
469
|
-
dvioptions: "-myopt -q --quiet"
|
|
470
|
-
EOT
|
|
471
|
-
assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
|
|
472
|
-
end
|
|
473
|
-
end
|
data/test/test_webtocprinter.rb
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'review/webtocprinter'
|
|
3
|
-
require 'book_test_helper'
|
|
4
|
-
|
|
5
|
-
class WEBTOCPrinterTest < Test::Unit::TestCase
|
|
6
|
-
include ReVIEW
|
|
7
|
-
include BookTestHelper
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
I18n.setup
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_webtocprinter_null
|
|
14
|
-
dummy_book = ReVIEW::Book::Base.new
|
|
15
|
-
# chap = ReVIEW::Book::Chapter.new(dummy_book, 1, '-', nil, StringIO.new)
|
|
16
|
-
str = WEBTOCPrinter.book_to_string(dummy_book)
|
|
17
|
-
expect = <<-EOB
|
|
18
|
-
<ul class="book-toc">
|
|
19
|
-
<li><a href="index.html">TOP</a></li>
|
|
20
|
-
</ul>
|
|
21
|
-
EOB
|
|
22
|
-
assert_equal expect, str
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_webtocprinter_with_chapters
|
|
26
|
-
catalog_yml = <<-EOB
|
|
27
|
-
CHAPS:
|
|
28
|
-
- ch1.re
|
|
29
|
-
- ch2.re
|
|
30
|
-
EOB
|
|
31
|
-
mktmpbookdir('catalog.yml' => catalog_yml,
|
|
32
|
-
'ch1.re' => "= ch. 1\n\n111\n",
|
|
33
|
-
'ch2.re' => "= ch. 2\n\n222\n") do |_dir, book, _files|
|
|
34
|
-
str = WEBTOCPrinter.book_to_string(book)
|
|
35
|
-
expect = <<-EOB
|
|
36
|
-
<ul class="book-toc">
|
|
37
|
-
<li><a href="index.html">TOP</a></li>
|
|
38
|
-
<li><a href="ch1.html">第1章 ch. 1</a></li>
|
|
39
|
-
<li><a href="ch2.html">第2章 ch. 2</a></li>
|
|
40
|
-
</ul>
|
|
41
|
-
EOB
|
|
42
|
-
assert_equal expect, str
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_webtocprinter_with_parts
|
|
47
|
-
catalog_yml = <<-EOB
|
|
48
|
-
CHAPS:
|
|
49
|
-
- part1:
|
|
50
|
-
- ch1.re
|
|
51
|
-
- part2:
|
|
52
|
-
- ch2.re
|
|
53
|
-
EOB
|
|
54
|
-
mktmpbookdir('catalog.yml' => catalog_yml,
|
|
55
|
-
'ch1.re' => "= ch. 1\n\n111\n",
|
|
56
|
-
'ch2.re' => "= ch. 2\n\n222\n") do |_dir, book, _files|
|
|
57
|
-
str = WEBTOCPrinter.book_to_string(book)
|
|
58
|
-
expect = <<-EOB
|
|
59
|
-
<ul class="book-toc">
|
|
60
|
-
<li><a href="index.html">TOP</a></li>
|
|
61
|
-
<li>第I部 part1
|
|
62
|
-
<ul><li><a href="ch1.html">第1章 ch. 1</a></li>
|
|
63
|
-
</ul></li>
|
|
64
|
-
<li>第II部 part2
|
|
65
|
-
<ul><li><a href="ch2.html">第2章 ch. 2</a></li>
|
|
66
|
-
</ul></li>
|
|
67
|
-
</ul>
|
|
68
|
-
EOB
|
|
69
|
-
assert_equal expect, str
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def test_webtocprinter_with_partfiles
|
|
74
|
-
catalog_yml = <<-EOB
|
|
75
|
-
CHAPS:
|
|
76
|
-
- p1.re:
|
|
77
|
-
- ch1.re
|
|
78
|
-
- p2.re:
|
|
79
|
-
- ch2.re
|
|
80
|
-
EOB
|
|
81
|
-
mktmpbookdir('catalog.yml' => catalog_yml,
|
|
82
|
-
'p1.re' => "= This is PART1\n\np111\n",
|
|
83
|
-
'p2.re' => "= This is PART2\n\np111\n",
|
|
84
|
-
'ch1.re' => "= ch. 1\n\n111\n",
|
|
85
|
-
'ch2.re' => "= ch. 2\n\n222\n") do |_dir, book, _files|
|
|
86
|
-
str = WEBTOCPrinter.book_to_string(book)
|
|
87
|
-
expect = <<-EOB
|
|
88
|
-
<ul class="book-toc">
|
|
89
|
-
<li><a href="index.html">TOP</a></li>
|
|
90
|
-
<li><a href="p1.html">第I部 This is PART1</a>
|
|
91
|
-
<ul><li><a href="ch1.html">第1章 ch. 1</a></li>
|
|
92
|
-
</ul></li>
|
|
93
|
-
<li><a href="p2.html">第II部 This is PART2</a>
|
|
94
|
-
<ul><li><a href="ch2.html">第2章 ch. 2</a></li>
|
|
95
|
-
</ul></li>
|
|
96
|
-
</ul>
|
|
97
|
-
EOB
|
|
98
|
-
assert_equal expect, str
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def test_webtocprinter_full
|
|
103
|
-
catalog_yml = <<-EOB
|
|
104
|
-
PREDEF:
|
|
105
|
-
- pre1.re
|
|
106
|
-
- pre2.re
|
|
107
|
-
CHAPS:
|
|
108
|
-
- part1.re:
|
|
109
|
-
- ch1.re
|
|
110
|
-
- part2.re:
|
|
111
|
-
- ch2.re
|
|
112
|
-
APPENDIX:
|
|
113
|
-
- app1.re
|
|
114
|
-
- app2.re
|
|
115
|
-
POSTDEF:
|
|
116
|
-
- post1.re
|
|
117
|
-
- post2.re
|
|
118
|
-
EOB
|
|
119
|
-
mktmpbookdir('catalog.yml' => catalog_yml,
|
|
120
|
-
'pre1.re' => "= PRE1\n\npre111\n",
|
|
121
|
-
'pre2.re' => "= PRE2\n\npre222\n",
|
|
122
|
-
'app1.re' => "= APP1\n\napp111\n",
|
|
123
|
-
'app2.re' => "= APP2\n\napp222\n",
|
|
124
|
-
'part1.re' => "= PART1\n\np111\n",
|
|
125
|
-
'part2.re' => "= PART2\n\np111\n",
|
|
126
|
-
'post1.re' => "= POST1\n\npo111\n",
|
|
127
|
-
'post2.re' => "= POST2\n\npo222\n",
|
|
128
|
-
'ch1.re' => "= ch. 1\n\n111\n",
|
|
129
|
-
'ch2.re' => "= ch. 2\n\n222\n") do |_dir, book, _files|
|
|
130
|
-
str = WEBTOCPrinter.book_to_string(book)
|
|
131
|
-
expect = <<-EOB
|
|
132
|
-
<ul class="book-toc">
|
|
133
|
-
<li><a href="index.html">TOP</a></li>
|
|
134
|
-
<li><a href="pre1.html">PRE1</a></li>
|
|
135
|
-
<li><a href="pre2.html">PRE2</a></li>
|
|
136
|
-
<li><a href="part1.html">第I部 PART1</a>
|
|
137
|
-
<ul><li><a href="ch1.html">第1章 ch. 1</a></li>
|
|
138
|
-
</ul></li>
|
|
139
|
-
<li><a href="part2.html">第II部 PART2</a>
|
|
140
|
-
<ul><li><a href="ch2.html">第2章 ch. 2</a></li>
|
|
141
|
-
</ul></li>
|
|
142
|
-
<li><a href="app1.html">付録A APP1</a></li>
|
|
143
|
-
<li><a href="app2.html">付録B APP2</a></li>
|
|
144
|
-
<li><a href="post1.html">POST1</a></li>
|
|
145
|
-
<li><a href="post2.html">POST2</a></li>
|
|
146
|
-
</ul>
|
|
147
|
-
EOB
|
|
148
|
-
assert_equal expect, str
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def test_webtocprinter_nochapter
|
|
153
|
-
catalog_yml = <<-EOB
|
|
154
|
-
CHAPS:
|
|
155
|
-
EOB
|
|
156
|
-
mktmpbookdir('catalog.yml' => catalog_yml) do |_dir, book, _files|
|
|
157
|
-
str = WEBTOCPrinter.book_to_string(book)
|
|
158
|
-
expect = <<-EOB
|
|
159
|
-
<ul class="book-toc">
|
|
160
|
-
<li><a href="index.html">TOP</a></li>
|
|
161
|
-
</ul>
|
|
162
|
-
EOB
|
|
163
|
-
assert_equal expect, str
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def test_webtocprinter_noheadline
|
|
168
|
-
catalog_yml = <<-EOB
|
|
169
|
-
CHAPS:
|
|
170
|
-
- ch1.re
|
|
171
|
-
- ch2.re
|
|
172
|
-
- ch3.re
|
|
173
|
-
- ch4.re
|
|
174
|
-
EOB
|
|
175
|
-
mktmpbookdir('catalog.yml' => catalog_yml,
|
|
176
|
-
'ch1.re' => "A\n",
|
|
177
|
-
'ch2.re' => "B\n\n= C\n== D\n",
|
|
178
|
-
'ch3.re' => "//emlist{\nLIST\n//}\n",
|
|
179
|
-
'ch4.re' => "==[column] E\n\n= F") do |_dir, book, _files|
|
|
180
|
-
str = WEBTOCPrinter.book_to_string(book)
|
|
181
|
-
expect = <<-EOB
|
|
182
|
-
<ul class="book-toc">
|
|
183
|
-
<li><a href="index.html">TOP</a></li>
|
|
184
|
-
<li><a href="ch1.html">-</a></li>
|
|
185
|
-
<li><a href="ch2.html">-</a></li>
|
|
186
|
-
<li><a href="ch2.html">第2章 C</a></li>
|
|
187
|
-
<li><a href="ch3.html">-</a></li>
|
|
188
|
-
<li><a href="ch4.html">-</a></li>
|
|
189
|
-
<li><a href="ch4.html">第4章 F</a></li>
|
|
190
|
-
</ul>
|
|
191
|
-
EOB
|
|
192
|
-
assert_equal expect, str
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|