review 3.0.0.preview3 → 3.0.0.preview4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.ja.md +26 -0
  3. data/NEWS.md +26 -0
  4. data/bin/review +2 -0
  5. data/bin/review-update +19 -0
  6. data/doc/format.ja.md +11 -0
  7. data/doc/format.md +11 -1
  8. data/doc/format_idg.ja.md +2 -4
  9. data/lib/review/book/chapter.rb +1 -0
  10. data/lib/review/book/compilable.rb +9 -0
  11. data/lib/review/book/index.rb +7 -1
  12. data/lib/review/builder.rb +29 -3
  13. data/lib/review/compiler.rb +2 -1
  14. data/lib/review/htmlbuilder.rb +40 -28
  15. data/lib/review/i18n.rb +8 -0
  16. data/lib/review/i18n.yml +22 -1
  17. data/lib/review/idgxmlbuilder.rb +42 -36
  18. data/lib/review/init.rb +2 -2
  19. data/lib/review/latexbuilder.rb +27 -1
  20. data/lib/review/makerhelper.rb +2 -1
  21. data/lib/review/plaintextbuilder.rb +27 -41
  22. data/lib/review/rstbuilder.rb +9 -1
  23. data/lib/review/topbuilder.rb +9 -1
  24. data/lib/review/update.rb +527 -0
  25. data/lib/review/version.rb +1 -1
  26. data/review.gemspec +1 -1
  27. data/samples/sample-book/README.md +1 -1
  28. data/samples/sample-book/src/Rakefile +2 -112
  29. data/samples/sample-book/src/config.yml +3 -1
  30. data/samples/sample-book/src/lib/tasks/review.rake +113 -0
  31. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +17 -0
  32. data/samples/sample-book/src/sty/reviewmacro.sty +15 -1
  33. data/samples/syntax-book/Rakefile +2 -87
  34. data/samples/syntax-book/ch02.re +6 -1
  35. data/samples/syntax-book/config.yml +7 -4
  36. data/samples/syntax-book/images/cover-b5.ai +5735 -15
  37. data/samples/syntax-book/lib/tasks/review.rake +113 -0
  38. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +17 -0
  39. data/samples/syntax-book/sty/reviewmacro.sty +11 -35
  40. data/templates/latex/config.erb +1 -0
  41. data/templates/latex/review-jlreq/review-base.sty +4 -0
  42. data/templates/latex/review-jlreq/review-jlreq.cls +56 -2
  43. data/templates/latex/review-jlreq/review-style.sty +0 -6
  44. data/templates/latex/review-jsbook/review-base.sty +5 -0
  45. data/test/assets/test_template.tex +2 -1
  46. data/test/assets/test_template_backmatter.tex +2 -1
  47. data/test/test_htmlbuilder.rb +39 -1
  48. data/test/test_idgxmlbuilder.rb +24 -0
  49. data/test/test_latexbuilder.rb +39 -0
  50. data/test/test_pdfmaker_cmd.rb +1 -1
  51. data/test/test_plaintextbuilder.rb +19 -0
  52. data/test/test_topbuilder.rb +21 -0
  53. data/test/test_update.rb +450 -0
  54. metadata +12 -2
@@ -23,7 +23,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
23
23
  if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
24
24
  config = prepare_samplebook(@tmpdir1)
25
25
  builddir = @tmpdir1 + '/' + config['bookname'] + '-pdf'
26
- assert !File.exist?(builddir)
26
+ # assert !File.exist?(builddir)
27
27
 
28
28
  ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
29
29
  Dir.chdir(@tmpdir1) do
@@ -387,4 +387,23 @@ EOS
387
387
 
388
388
  assert_equal expected, column_helper(review)
389
389
  end
390
+
391
+ def test_texequation_with_caption
392
+ src = <<-EOS
393
+ @<eq>{emc2}
394
+
395
+ //texequation[emc2][The Equivalence of Mass @<i>{and} Energy]{
396
+ e=mc^2
397
+ //}
398
+ EOS
399
+ expected = <<-EOS
400
+ 式1.1
401
+
402
+ 式1.1 The Equivalence of Mass and Energy
403
+ e=mc^2
404
+
405
+ EOS
406
+ actual = compile_block(src)
407
+ assert_equal expected, actual
408
+ end
390
409
  end
@@ -411,4 +411,25 @@ EOS
411
411
 
412
412
  assert_equal expected, column_helper(review)
413
413
  end
414
+
415
+ def test_texequation_with_caption
416
+ src = <<-EOS
417
+ @<eq>{emc2}
418
+
419
+ //texequation[emc2][The Equivalence of Mass @<i>{and} Energy]{
420
+ e=mc^2
421
+ //}
422
+ EOS
423
+ expected = <<-EOS
424
+ 式1.1
425
+
426
+ ◆→開始:TeX式←◆
427
+ 式1.1 The Equivalence of Mass ▲and☆ Energy
428
+ e=mc^2
429
+ ◆→終了:TeX式←◆
430
+
431
+ EOS
432
+ actual = compile_block(src)
433
+ assert_equal expected, actual
434
+ end
414
435
  end
@@ -0,0 +1,450 @@
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 '3.0'/, io.string)
100
+ assert_equal 'review_version: 3.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
101
+ end
102
+
103
+ def test_update_version_current
104
+ File.write(File.join(@tmpdir, 'config.yml'), "review_version: 3.0\n")
105
+
106
+ io = StringIO.new
107
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
108
+ @u.parse_ymls(@tmpdir)
109
+ @u.update_version
110
+ assert_equal '', io.string
111
+ assert_equal 'review_version: 3.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
112
+ end
113
+
114
+ def test_update_version_newer
115
+ File.write(File.join(@tmpdir, 'config.yml'), "review_version: 99.0\n")
116
+
117
+ io = StringIO.new
118
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
119
+ @u.parse_ymls(@tmpdir)
120
+ @u.update_version
121
+ assert_match(/Update 'review_version' to '3.0'/, io.string)
122
+ assert_equal 'review_version: 99.0', File.read(File.join(@tmpdir, 'config.yml')).match(/review_version:.*$/).to_s
123
+ end
124
+
125
+ def test_update_rakefile
126
+ io = StringIO.new
127
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
128
+ @u.update_rakefile(@tmpdir)
129
+ assert_equal '', io.string
130
+ assert_equal true, File.exist?(File.join(@tmpdir, 'Rakefile'))
131
+ assert_equal true, File.exist?(File.join(@tmpdir, 'lib/tasks/review.rake'))
132
+ end
133
+
134
+ def test_update_rakefile_same
135
+ io = StringIO.new
136
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
137
+ @u.update_rakefile(@tmpdir)
138
+ @u.update_rakefile(@tmpdir)
139
+ assert_equal '', io.string
140
+ assert_equal true, File.exist?(File.join(@tmpdir, 'Rakefile'))
141
+ assert_equal true, File.exist?(File.join(@tmpdir, 'lib/tasks/review.rake'))
142
+ end
143
+
144
+ def test_update_rakefile_different
145
+ File.write(File.join(@tmpdir, 'Rakefile'), '')
146
+ FileUtils.mkdir_p File.join(@tmpdir, 'lib/tasks')
147
+ File.write(File.join(@tmpdir, 'lib/tasks/review.rake'), '')
148
+ io = StringIO.new
149
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
150
+ @u.update_rakefile(@tmpdir)
151
+ assert_match(/Rakefile will be overridden with/, io.string)
152
+ assert_match(%r{lib/tasks/review\.rake will be overridden}, io.string)
153
+ assert_equal true, File.exist?(File.join(@tmpdir, 'Rakefile'))
154
+ assert_equal true, File.exist?(File.join(@tmpdir, 'lib/tasks/review.rake'))
155
+ end
156
+
157
+ def test_update_epub_version_older
158
+ File.write(File.join(@tmpdir, 'config.yml'), "epubversion: 2\nhtmlversion: 4\n")
159
+ io = StringIO.new
160
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
161
+ @u.parse_ymls(@tmpdir)
162
+ @u.update_epub_version
163
+ assert_match(/Update 'epubversion'/, io.string)
164
+ assert_match(/Update 'htmlversion'/, io.string)
165
+ cont = <<EOT
166
+ epubversion: 3
167
+ htmlversion: 5
168
+ EOT
169
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
170
+ end
171
+
172
+ def test_update_epub_version_current
173
+ File.write(File.join(@tmpdir, 'config.yml'), "epubversion: 3\nhtmlversion: 5\n")
174
+ io = StringIO.new
175
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
176
+ @u.parse_ymls(@tmpdir)
177
+ @u.update_epub_version
178
+ assert_equal '', io.string
179
+ cont = <<EOT
180
+ epubversion: 3
181
+ htmlversion: 5
182
+ EOT
183
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
184
+ end
185
+
186
+ def test_update_epub_version_newer
187
+ File.write(File.join(@tmpdir, 'config.yml'), "epubversion: 99\nhtmlversion: 99\n")
188
+ io = StringIO.new
189
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
190
+ @u.parse_ymls(@tmpdir)
191
+ @u.update_epub_version
192
+ assert_equal '', io.string
193
+ cont = <<EOT
194
+ epubversion: 99
195
+ htmlversion: 99
196
+ EOT
197
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
198
+ end
199
+
200
+ def test_update_locale_older
201
+ File.write(File.join(@tmpdir, 'locale.yml'), %Q(locale: en\nchapter_quote: "'%s'"\n))
202
+ io = StringIO.new
203
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
204
+ @u.parse_ymls(@tmpdir)
205
+ @u.update_locale
206
+ assert_match(/'chapter_quote' now takes 2 values/, io.string)
207
+ cont = <<EOT
208
+ locale: en
209
+ chapter_quote: '%s %s'
210
+ EOT
211
+ assert_equal cont, File.read(File.join(@tmpdir, 'locale.yml'))
212
+ end
213
+
214
+ def test_update_locale_current
215
+ File.write(File.join(@tmpdir, 'locale.yml'), %Q(locale: en\nchapter_quote: "'%s...%s'"\n))
216
+ io = StringIO.new
217
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
218
+ @u.parse_ymls(@tmpdir)
219
+ @u.update_locale
220
+ assert_equal '', io.string
221
+ cont = <<EOT
222
+ locale: en
223
+ chapter_quote: "'%s...%s'"
224
+ EOT
225
+ assert_equal cont, File.read(File.join(@tmpdir, 'locale.yml'))
226
+ end
227
+
228
+ def test_update_tex_parameters_jsbook_to_review_jsbook
229
+ 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))
230
+ io = StringIO.new
231
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
232
+ @u.parse_ymls(@tmpdir)
233
+ @u.update_tex_parameters
234
+ assert_match(/By default it is migrated to/, io.string)
235
+ assert_match(/is safely replaced/, io.string)
236
+ cont = <<EOT
237
+ texdocumentclass: ["review-jsbook", "paper=a5,Q=15.46,landscape,oneside,twoside,vartwoside,onecolumn,twocolumn,titlepage,notitlepage,openright,openany,leqno,fleqn,disablejfam,draft,final,mingoth,winjis,jis,papersize,english,report,jslogo,nojslogo,cameraready=print,cover=false"]
238
+ EOT
239
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
240
+ end
241
+
242
+ def test_update_tex_parameters_jsbook_to_review_jsbook_invalid
243
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["jsbook", "a5paper,invalid"]\n))
244
+ io = StringIO.new
245
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
246
+ @u.parse_ymls(@tmpdir)
247
+ @u.update_tex_parameters
248
+ assert_match(/couldn't be converted fully/, io.string)
249
+ assert_match("'paper=a5,cameraready=print,cover=false' is suggested", io.string)
250
+ cont = <<EOT
251
+ texdocumentclass: ["jsbook", "a5paper,invalid"]
252
+ EOT
253
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
254
+ end
255
+
256
+ def test_update_tex_parameters_review_jsbook
257
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jsbook", ""]\n))
258
+ io = StringIO.new
259
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
260
+ @u.parse_ymls(@tmpdir)
261
+ @u.update_tex_parameters
262
+ assert_equal '', io.string
263
+ cont = <<EOT
264
+ texdocumentclass: ["review-jsbook", ""]
265
+ EOT
266
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
267
+ end
268
+
269
+ def test_update_tex_parameters_review_jlreq
270
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jlreq", ""]\n))
271
+ io = StringIO.new
272
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
273
+ @u.parse_ymls(@tmpdir)
274
+ @u.update_tex_parameters
275
+ assert_equal '', io.string
276
+ cont = <<EOT
277
+ texdocumentclass: ["review-jlreq", ""]
278
+ EOT
279
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
280
+ end
281
+
282
+ def test_update_tex_parameters_review_jsbook_review_jlreq
283
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["review-jsbook", ""]\n))
284
+ io = StringIO.new
285
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
286
+ @u.parse_ymls(@tmpdir)
287
+ @u.specified_template = 'review-jlreq'
288
+ @u.update_tex_parameters
289
+ assert_match(/already, but you specified/, io.string)
290
+ cont = <<EOT
291
+ texdocumentclass: ["review-jsbook", ""]
292
+ EOT
293
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
294
+ end
295
+
296
+ def test_update_tex_parameters_unknownclass
297
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["unknown", ""]\n))
298
+ io = StringIO.new
299
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
300
+ @u.parse_ymls(@tmpdir)
301
+ @u.update_tex_parameters
302
+ assert_match(/unknown class/, io.string)
303
+ cont = <<EOT
304
+ texdocumentclass: ["unknown", ""]
305
+ EOT
306
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
307
+ end
308
+
309
+ def test_update_tex_parameters_jsbook_unknownclass
310
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texdocumentclass: ["jsbook", ""]\n))
311
+ io = StringIO.new
312
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
313
+ @u.parse_ymls(@tmpdir)
314
+ @u.specified_template = 'unknown'
315
+ @u.update_tex_parameters
316
+ assert_match(/unknown class/, io.string)
317
+ cont = <<EOT
318
+ texdocumentclass: ["jsbook", ""]
319
+ EOT
320
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
321
+ end
322
+
323
+ def test_update_tex_parameters_jsbook_to_review_jlreq
324
+ 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))
325
+ io = StringIO.new
326
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
327
+ @u.parse_ymls(@tmpdir)
328
+ @u.specified_template = 'review-jlreq'
329
+ @u.update_tex_parameters
330
+ assert_match(/By default it is migrated to/, io.string)
331
+ assert_match(/is safely replaced/, io.string)
332
+ cont = <<EOT
333
+ texdocumentclass: ["review-jlreq", "paper=a5,fontsize=11pt,landscape,oneside,twoside,onecolumn,twocolumn,titlepage,notitlepage,openright,openany,leqno,fleqn,draft,final,report,cameraready=print,cover=false"]
334
+ EOT
335
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
336
+ end
337
+
338
+ def test_update_stys_new
339
+ io = StringIO.new
340
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
341
+ @u.update_tex_stys('review-jsbook', @tmpdir)
342
+ assert_equal '', io.string
343
+ assert_equal true, File.exist?(File.join(@tmpdir, 'sty/review-base.sty'))
344
+ assert_equal true, File.exist?(File.join(@tmpdir, 'sty/gentombow09j.sty'))
345
+ end
346
+
347
+ def test_update_stys_new_custom
348
+ io = StringIO.new
349
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
350
+ @u.update_tex_stys('review-jsbook', @tmpdir)
351
+ File.write(File.join(@tmpdir, 'sty/review-custom.sty'), "% MY CUSTOM\n")
352
+ @u.update_tex_stys('review-jsbook', @tmpdir)
353
+ assert_equal '', io.string
354
+ assert_equal "% MY CUSTOM\n", File.read(File.join(@tmpdir, 'sty/review-custom.sty'))
355
+ end
356
+
357
+ def test_update_stys_modified
358
+ io = StringIO.new
359
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
360
+ @u.update_tex_stys('review-jsbook', @tmpdir)
361
+ cont = File.read(File.join(@tmpdir, 'sty/review-base.sty'))
362
+
363
+ File.write(File.join(@tmpdir, 'sty/review-base.sty'), "% MODIFIED\n")
364
+ @u.update_tex_stys('review-jsbook', @tmpdir)
365
+ assert_match(/review\-base\.sty will be overridden/, io.string)
366
+ assert_equal cont, File.read(File.join(@tmpdir, 'sty/review-base.sty'))
367
+ end
368
+
369
+ def test_update_tex_command
370
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texcommand: "/Program Files/up-latex --shell-escape -v"\n))
371
+ io = StringIO.new
372
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
373
+ @u.parse_ymls(@tmpdir)
374
+ @u.update_tex_command
375
+ assert_match(/has options/, io.string)
376
+ cont = <<EOT
377
+ texcommand: "/Program Files/up-latex"
378
+ texoptions: "-interaction=nonstopmode -file-line-error --shell-escape -v"
379
+ EOT
380
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
381
+ end
382
+
383
+ def test_update_tex_command_noopt
384
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texcommand: "/Program Files/up-latex"\n))
385
+ io = StringIO.new
386
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
387
+ @u.parse_ymls(@tmpdir)
388
+ @u.update_tex_command
389
+ assert_equal '', io.string
390
+ cont = <<EOT
391
+ texcommand: "/Program Files/up-latex"
392
+ EOT
393
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
394
+ end
395
+
396
+ def test_update_tex_command_withopt
397
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(texcommand: "/Program Files/up-latex --shell-escape -v"\ntexoptions: "-myopt"\n))
398
+ io = StringIO.new
399
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
400
+ @u.parse_ymls(@tmpdir)
401
+ @u.update_tex_command
402
+ assert_match(/has options/, io.string)
403
+ cont = <<EOT
404
+ texcommand: "/Program Files/up-latex"
405
+ texoptions: "-myopt --shell-escape -v"
406
+ EOT
407
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
408
+ end
409
+
410
+ def test_update_dvi_command
411
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(dvicommand: "/Program Files/dvi-pdfmx -q --quiet"\n))
412
+ io = StringIO.new
413
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
414
+ @u.parse_ymls(@tmpdir)
415
+ @u.update_dvi_command
416
+ assert_match(/has options/, io.string)
417
+ cont = <<EOT
418
+ dvicommand: "/Program Files/dvi-pdfmx"
419
+ dvioptions: "-d 5 -z 9 -q --quiet"
420
+ EOT
421
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
422
+ end
423
+
424
+ def test_update_dvi_command_noopt
425
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(dvicommand: "/Program Files/dvi-pdfmx"\n))
426
+ io = StringIO.new
427
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
428
+ @u.parse_ymls(@tmpdir)
429
+ @u.update_dvi_command
430
+ assert_equal '', io.string
431
+ cont = <<EOT
432
+ dvicommand: "/Program Files/dvi-pdfmx"
433
+ EOT
434
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
435
+ end
436
+
437
+ def test_update_dvi_command_withopt
438
+ File.write(File.join(@tmpdir, 'config.yml'), %Q(dvicommand: "/Program Files/dvi-pdfmx -q --quiet"\ndvioptions: "-myopt"\n))
439
+ io = StringIO.new
440
+ @u.instance_eval{ @logger = ReVIEW::Logger.new(io) }
441
+ @u.parse_ymls(@tmpdir)
442
+ @u.update_dvi_command
443
+ assert_match(/has options/, io.string)
444
+ cont = <<EOT
445
+ dvicommand: "/Program Files/dvi-pdfmx"
446
+ dvioptions: "-myopt -q --quiet"
447
+ EOT
448
+ assert_equal cont, File.read(File.join(@tmpdir, 'config.yml'))
449
+ end
450
+ end