review 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +90 -66
  3. data/.travis.yml +1 -1
  4. data/Gemfile +0 -1
  5. data/NEWS.ja.md +82 -0
  6. data/NEWS.md +83 -0
  7. data/README.md +5 -3
  8. data/Rakefile +8 -8
  9. data/bin/review +1 -5
  10. data/bin/review-catalog-converter +22 -27
  11. data/bin/review-check +36 -43
  12. data/bin/review-checkdep +10 -15
  13. data/bin/review-compile +37 -55
  14. data/bin/review-epubmaker +4 -5
  15. data/bin/review-index +21 -29
  16. data/bin/review-init +26 -37
  17. data/bin/review-pdfmaker +0 -2
  18. data/bin/review-preproc +25 -45
  19. data/bin/review-validate +19 -18
  20. data/bin/review-vol +15 -27
  21. data/doc/config.yml.sample +5 -2
  22. data/doc/format.ja.md +20 -1
  23. data/doc/format.md +21 -5
  24. data/doc/images/review-generate.png +0 -0
  25. data/lib/epubmaker.rb +1 -3
  26. data/lib/epubmaker/content.rb +24 -27
  27. data/lib/epubmaker/epubcommon.rb +135 -148
  28. data/lib/epubmaker/epubv2.rb +39 -46
  29. data/lib/epubmaker/epubv3.rb +93 -103
  30. data/lib/epubmaker/producer.rb +138 -151
  31. data/lib/epubmaker/zip_exporter.rb +21 -26
  32. data/lib/review/book.rb +3 -6
  33. data/lib/review/book/base.rb +78 -103
  34. data/lib/review/book/chapter.rb +36 -40
  35. data/lib/review/book/compilable.rb +28 -31
  36. data/lib/review/book/image_finder.rb +6 -13
  37. data/lib/review/book/index.rb +100 -121
  38. data/lib/review/book/page_metric.rb +2 -7
  39. data/lib/review/book/part.rb +18 -20
  40. data/lib/review/book/volume.rb +9 -13
  41. data/lib/review/builder.rb +81 -116
  42. data/lib/review/catalog.rb +15 -19
  43. data/lib/review/compiler.rb +64 -83
  44. data/lib/review/configure.rb +87 -97
  45. data/lib/review/converter.rb +2 -7
  46. data/lib/review/epubbuilder.rb +1 -3
  47. data/lib/review/epubmaker.rb +213 -205
  48. data/lib/review/exception.rb +2 -4
  49. data/lib/review/extentions.rb +0 -1
  50. data/lib/review/extentions/hash.rb +2 -2
  51. data/lib/review/extentions/string.rb +5 -30
  52. data/lib/review/htmlbuilder.rb +320 -375
  53. data/lib/review/htmltoc.rb +4 -7
  54. data/lib/review/htmlutils.rb +29 -32
  55. data/lib/review/i18n.rb +33 -44
  56. data/lib/review/i18n.yml +3 -3
  57. data/lib/review/idgxmlbuilder.rb +309 -345
  58. data/lib/review/latexbuilder.rb +175 -212
  59. data/lib/review/latexindex.rb +2 -8
  60. data/lib/review/latexutils.rb +33 -43
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/logger.rb +21 -0
  63. data/lib/review/makerhelper.rb +1 -4
  64. data/lib/review/markdownbuilder.rb +44 -53
  65. data/lib/review/md2inaobuilder.rb +6 -12
  66. data/lib/review/pdfmaker.rb +143 -173
  67. data/lib/review/preprocessor.rb +64 -101
  68. data/lib/review/rstbuilder.rb +126 -158
  69. data/lib/review/sec_counter.rb +18 -34
  70. data/lib/review/template.rb +4 -5
  71. data/lib/review/textbuilder.rb +2 -3
  72. data/lib/review/textutils.rb +7 -13
  73. data/lib/review/tocparser.rb +31 -56
  74. data/lib/review/tocprinter.rb +26 -52
  75. data/lib/review/topbuilder.rb +219 -247
  76. data/lib/review/unfold.rb +15 -24
  77. data/lib/review/version.rb +1 -1
  78. data/lib/review/webmaker.rb +75 -99
  79. data/lib/review/webtocprinter.rb +15 -20
  80. data/lib/review/yamlloader.rb +13 -15
  81. data/review.gemspec +20 -22
  82. data/templates/latex/layout.tex.erb +2 -2
  83. data/templates/opf/epubv2.opf.erb +7 -7
  84. data/templates/opf/epubv3.opf.erb +7 -7
  85. data/templates/web/html/layout-html5.html.erb +2 -2
  86. data/test/assets/black.eps +280 -0
  87. data/test/assets/fit.png +0 -0
  88. data/test/assets/large.gif +0 -0
  89. data/test/assets/large.jpg +0 -0
  90. data/test/assets/large.png +0 -0
  91. data/test/assets/large.svg +65 -0
  92. data/test/assets/test_template.tex +1 -1
  93. data/test/book_test_helper.rb +2 -2
  94. data/test/run_test.rb +4 -4
  95. data/test/sample-book/src/Rakefile +21 -22
  96. data/test/syntax-book/Gemfile +4 -0
  97. data/test/syntax-book/Rakefile +72 -0
  98. data/test/syntax-book/appA.re +22 -0
  99. data/test/syntax-book/bib.re +6 -0
  100. data/test/syntax-book/catalog.yml +15 -0
  101. data/test/syntax-book/ch01.re +136 -0
  102. data/test/syntax-book/ch02.re +351 -0
  103. data/test/syntax-book/ch03.re +82 -0
  104. data/test/syntax-book/config.yml +35 -0
  105. data/test/syntax-book/images/ball.png +0 -0
  106. data/test/syntax-book/images/cover.jpg +0 -0
  107. data/test/syntax-book/images/fractal.png +0 -0
  108. data/test/syntax-book/images/img3-1.png +0 -0
  109. data/test/syntax-book/images/inlineicon.jpg +0 -0
  110. data/test/syntax-book/images/logic.png +0 -0
  111. data/test/syntax-book/images/logic2.png +0 -0
  112. data/test/syntax-book/images/puzzle.jpg +0 -0
  113. data/test/syntax-book/images/table.jpg +0 -0
  114. data/test/syntax-book/part2.re +6 -0
  115. data/test/syntax-book/pre01.re +26 -0
  116. data/test/syntax-book/review-ext.rb +14 -0
  117. data/test/syntax-book/sty/jumoline.sty +310 -0
  118. data/test/syntax-book/sty/reviewmacro.sty +39 -0
  119. data/test/syntax-book/style.css +494 -0
  120. data/test/syntax-book/syntax.dic +2 -0
  121. data/test/test_book.rb +106 -111
  122. data/test/test_book_chapter.rb +21 -22
  123. data/test/test_book_part.rb +3 -5
  124. data/test/test_builder.rb +11 -22
  125. data/test/test_catalog.rb +17 -18
  126. data/test/test_catalog_converter_cmd.rb +5 -5
  127. data/test/test_compiler.rb +18 -16
  128. data/test/test_configure.rb +35 -38
  129. data/test/test_converter.rb +3 -4
  130. data/test/test_epub3maker.rb +136 -117
  131. data/test/test_epubmaker.rb +107 -114
  132. data/test/test_epubmaker_cmd.rb +2 -4
  133. data/test/test_extentions_hash.rb +32 -33
  134. data/test/test_helper.rb +9 -11
  135. data/test/test_htmlbuilder.rb +454 -420
  136. data/test/test_htmltoc.rb +8 -12
  137. data/test/test_htmlutils.rb +0 -2
  138. data/test/test_i18n.rb +159 -150
  139. data/test/test_idgxmlbuilder.rb +190 -197
  140. data/test/test_image_finder.rb +21 -22
  141. data/test/test_index.rb +24 -29
  142. data/test/test_latexbuilder.rb +274 -264
  143. data/test/test_lineinput.rb +7 -10
  144. data/test/test_location.rb +7 -7
  145. data/test/test_makerhelper.rb +13 -25
  146. data/test/test_markdownbuilder.rb +23 -26
  147. data/test/test_md2inaobuilder.rb +8 -11
  148. data/test/test_pdfmaker.rb +114 -123
  149. data/test/test_pdfmaker_cmd.rb +1 -3
  150. data/test/test_review_ext.rb +3 -5
  151. data/test/test_rstbuilder.rb +92 -97
  152. data/test/test_template.rb +3 -7
  153. data/test/test_textutils.rb +27 -27
  154. data/test/test_tocparser.rb +2 -2
  155. data/test/test_topbuilder.rb +98 -103
  156. data/test/test_webtocprinter.rb +5 -6
  157. data/test/test_yamlloader.rb +42 -42
  158. data/test/test_zip_exporter.rb +12 -18
  159. metadata +86 -9
  160. data/lib/review/ewbbuilder.rb +0 -382
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  require 'book_test_helper'
3
2
  class ChapterTest < Test::Unit::TestCase
4
3
  include BookTestHelper
@@ -8,7 +7,7 @@ class ChapterTest < Test::Unit::TestCase
8
7
  assert_equal :book, ch.book
9
8
  assert_equal :number, ch.number
10
9
  assert_equal '/foo/bar', ch.path
11
- assert_equal "#<ReVIEW::Book::Chapter number /foo/bar>", ch.inspect
10
+ assert_equal '#<ReVIEW::Book::Chapter number /foo/bar>', ch.inspect
12
11
  end
13
12
 
14
13
  def test_dirname_and_basename
@@ -39,7 +38,7 @@ class ChapterTest < Test::Unit::TestCase
39
38
  def test_open
40
39
  ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
41
40
  assert_equal :io, ch.open
42
- assert_equal [:io], (ch.open {|io| [io] })
41
+ assert_equal [:io], (ch.open { |io| [io] })
43
42
  end
44
43
 
45
44
  def test_size
@@ -64,22 +63,22 @@ class ChapterTest < Test::Unit::TestCase
64
63
  end
65
64
 
66
65
  def test_lines
67
- lines = ["1\n", "2\n", "3"]
66
+ lines = ["1\n", "2\n", '3']
68
67
  tf = Tempfile.new('chapter_test')
69
- tf.print lines.join('')
68
+ tf.print lines.join
70
69
  tf.close
71
70
 
72
71
  book = Book::Base.new(nil)
73
72
  ch = Book::Chapter.new(book, nil, nil, tf.path)
74
73
  assert_equal lines, ch.lines
75
74
 
76
- lines = ["1\n", "2\n", "3"]
75
+ lines = ["1\n", "2\n", '3']
77
76
  tf1 = Tempfile.new('chapter_test1')
78
- tf1.print lines.join('')
77
+ tf1.print lines.join
79
78
  tf1.close
80
79
  tf2 = Tempfile.new('chapter_test2')
81
- tf2.puts lines.join('')
82
- tf2.puts lines.join('')
80
+ tf2.puts lines.join
81
+ tf2.puts lines.join
83
82
  tf2.close
84
83
 
85
84
  ch = Book::Chapter.new(book, nil, nil, tf1.path, tf2.path)
@@ -107,14 +106,14 @@ class ChapterTest < Test::Unit::TestCase
107
106
  assert_equal content.gsub(/\s/, '').size, ch.volume.bytes # XXX: OK?
108
107
  end
109
108
 
110
- def test_on_CHAPS?
109
+ def test_on_chaps?
111
110
  mktmpbookdir 'CHAPS' => "chapter1.re\nchapter2.re",
112
111
  'chapter1.re' => '12345', 'preface.re' => 'abcde' do |dir, book, files|
113
112
  ch1 = Book::Chapter.new(book, 1, 'chapter1', files['chapter1.re'])
114
113
  pre = Book::Chapter.new(book, nil, 'preface', files['preface.re'])
115
114
 
116
- assert ch1.on_CHAPS?
117
- assert !pre.on_CHAPS?
115
+ assert ch1.on_chaps?
116
+ assert !pre.on_chaps?
118
117
 
119
118
  ch2_path = File.join(dir, 'chapter2.er')
120
119
  File.open(ch2_path, 'w') {}
@@ -124,8 +123,8 @@ class ChapterTest < Test::Unit::TestCase
124
123
  File.open(ch3_path, 'w') {}
125
124
  ch3 = Book::Chapter.new(book, 3, 'chapter3', ch3_path)
126
125
 
127
- assert ch2.on_CHAPS?
128
- assert !ch3.on_CHAPS?
126
+ assert ch2.on_chaps?
127
+ assert !ch3.on_chaps?
129
128
  end
130
129
  end
131
130
 
@@ -166,7 +165,7 @@ E
166
165
  end
167
166
 
168
167
  def test_bibpaper
169
- do_test_index(<<E, Book::BibpaperIndex, :bibpaper_index, :bibpaper, :filename => 'bib.re')
168
+ do_test_index(<<E, Book::BibpaperIndex, :bibpaper_index, :bibpaper, filename: 'bib.re')
170
169
  //bibpaper
171
170
  //bibpaper [abc][text...]
172
171
  //bibpaper [def][text...]
@@ -175,12 +174,12 @@ E
175
174
  //list [others]
176
175
  E
177
176
  assert_raises FileNotFound do
178
- do_test_index('', Book::BibpaperIndex, :bibpaper_index, :bibpaper, :filename => 'bib')
177
+ do_test_index('', Book::BibpaperIndex, :bibpaper_index, :bibpaper, filename: 'bib')
179
178
  end
180
179
  end
181
180
 
182
181
  def test_headline_index
183
- do_test_index(<<E, Book::HeadlineIndex, :headline_index, :headline, :propagate => false)
182
+ do_test_index(<<E, Book::HeadlineIndex, :headline_index, :headline, propagate: false)
184
183
  ==
185
184
  == abc
186
185
  == def
@@ -190,7 +189,7 @@ E
190
189
  end
191
190
 
192
191
  def test_headline_index_nullsection
193
- do_test_index(<<E, Book::HeadlineIndex, :headline_index, :headline, :propagate => false)
192
+ do_test_index(<<E, Book::HeadlineIndex, :headline_index, :headline, propagate: false)
194
193
  == abc
195
194
  ==== dummy
196
195
  == def
@@ -198,7 +197,7 @@ E
198
197
  end
199
198
 
200
199
  def test_column_index
201
- do_test_index(<<E, Book::ColumnIndex, :column_index, :column, :propagate => false)
200
+ do_test_index(<<E, Book::ColumnIndex, :column_index, :column, propagate: false)
202
201
  = dummy1
203
202
  ===[column]{abc} aaaa
204
203
  = dummy2
@@ -216,7 +215,7 @@ E
216
215
  //list [others]
217
216
  E
218
217
 
219
- do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, :propagate => false)
218
+ do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, propagate: false)
220
219
  //numberlessimage
221
220
  //numberlessimage [abc]
222
221
  //numberlessimage [def]
@@ -232,7 +231,7 @@ E
232
231
  //list [others]
233
232
  E
234
233
 
235
- do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, :propagate => false)
234
+ do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, propagate: false)
236
235
  //image
237
236
  //numberlessimage [abc]
238
237
  //image [def]
@@ -241,7 +240,7 @@ E
241
240
  E
242
241
  end
243
242
 
244
- def do_test_index(content, klass, list_method, ref_method, opts = {})
243
+ def do_test_index(content, _klass, _list_method, ref_method, opts = {})
245
244
  Dir.mktmpdir do |dir|
246
245
  path = File.join(dir, opts[:filename] || 'chapter.re')
247
246
 
@@ -18,9 +18,7 @@ class PartTest < Test::Unit::TestCase
18
18
  part = Book::Part.new(nil, nil, [1, 2, 3])
19
19
 
20
20
  tmp = []
21
- part.each_chapter do |ch|
22
- tmp << ch
23
- end
21
+ part.each_chapter { |ch| tmp << ch }
24
22
  assert_equal [1, 2, 3], tmp
25
23
  end
26
24
 
@@ -35,12 +33,12 @@ class PartTest < Test::Unit::TestCase
35
33
  chs = []
36
34
  tfs = [] ## prevent from removing Tempfile
37
35
  Tempfile.open('part_test') do |o|
38
- o.print "12345"
36
+ o.print '12345'
39
37
  chs << Book::Chapter.new(book, nil, nil, o.path)
40
38
  tfs << o
41
39
  end
42
40
  Tempfile.open('part_test') do |o|
43
- o.print "67890"
41
+ o.print '67890'
44
42
  chs << Book::Chapter.new(book, nil, nil, o.path)
45
43
  tfs << o
46
44
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'review/builder'
5
3
 
@@ -47,46 +45,38 @@ class BuidlerTest < Test::Unit::TestCase
47
45
  def test_print_and_puts
48
46
  b = Builder.new
49
47
  assert_raises(NoMethodError) do # XXX: OK?
50
- b.print ""
48
+ b.print ''
51
49
  end
52
50
  assert_raises(NoMethodError) do # XXX: OK?
53
- b.puts ""
51
+ b.puts ''
54
52
  end
55
53
  end
56
54
 
57
55
  def test_not_implemented_methods
58
56
  ex = NoMethodError # XXX: OK?
59
- [
60
- :list_header, :list_body, :listnum_body,
61
- :source_header, :source_body,
62
- :image_image, :image_dummy,
63
- :table_header, :table_begin, :tr, :th, :table_end,
64
- :compile_ruby, :compile_kw, :compile_href,
65
- :bibpaper_header, :bibpaper_bibpaper,
66
- :inline_hd_chap,
67
- ].each do |m|
57
+ %i[list_header list_body listnum_body source_header source_body image_image image_dummy table_header table_begin tr th table_end compile_ruby compile_kw compile_href bibpaper_header bibpaper_bibpaper inline_hd_chap].each do |m|
68
58
  b = Builder.new
69
59
  assert_raises(ex) { b.__send__(m) }
70
60
  end
71
61
  end
72
62
 
73
63
  def test_compile_inline
74
- text = "abc"
64
+ text = 'abc'
75
65
  assert_equal [:text, text], @b.compile_inline(text)
76
66
  end
77
67
 
78
68
  def test_inline_ruby
79
- def @b.compile_ruby(base,ruby)
80
- [base,ruby]
69
+ def @b.compile_ruby(base, ruby)
70
+ [base, ruby]
81
71
  end
82
- str = @b.inline_ruby("foo,bar")
83
- assert_equal str, ["foo","bar"]
84
- str = @b.inline_ruby("foo\\,\\,,\\,bar,buz")
85
- assert_equal str, ["foo,,",",bar,buz"]
72
+ str = @b.inline_ruby('foo,bar')
73
+ assert_equal str, ['foo', 'bar']
74
+ str = @b.inline_ruby('foo\\,\\,,\\,bar,buz')
75
+ assert_equal str, ['foo,,', ',bar,buz']
86
76
  end
87
77
 
88
78
  def test_compile_inline_backslash
89
- text = "abc\\d\\#a"
79
+ text = 'abc\\d\\#a'
90
80
  assert_equal [:text, text], @b.compile_inline(text)
91
81
  end
92
82
 
@@ -107,4 +97,3 @@ class BuidlerTest < Test::Unit::TestCase
107
97
  end
108
98
  end
109
99
  end
110
-
@@ -6,7 +6,7 @@ class CatalogTest < Test::Unit::TestCase
6
6
 
7
7
  def test_predef
8
8
  sut = Catalog.new(yaml)
9
- exp =<<-EOS
9
+ exp = <<-EOS
10
10
  pre01.re
11
11
  pre02.re
12
12
  EOS
@@ -15,7 +15,7 @@ pre02.re
15
15
 
16
16
  def test_chaps
17
17
  sut = Catalog.new(yaml)
18
- exp =<<-EOS
18
+ exp = <<-EOS
19
19
  ch01.re
20
20
  ch02.re
21
21
  EOS
@@ -25,12 +25,12 @@ ch02.re
25
25
  def test_chaps_empty
26
26
  yaml = StringIO.new
27
27
  sut = Catalog.new(yaml)
28
- assert_equal("", sut.chaps)
28
+ assert_equal('', sut.chaps)
29
29
  end
30
30
 
31
31
  def test_appendix
32
32
  sut = Catalog.new(yaml)
33
- exp =<<-EOS
33
+ exp = <<-EOS
34
34
  post01.re
35
35
  post02.re
36
36
  EOS
@@ -39,7 +39,7 @@ post02.re
39
39
 
40
40
  def test_chaps_with_parts
41
41
  sut = Catalog.new(yaml_with_parts)
42
- exp =<<-EOS
42
+ exp = <<-EOS
43
43
  ch01.re
44
44
  ch02.re
45
45
  ch03.re
@@ -51,7 +51,7 @@ ch05.re
51
51
 
52
52
  def test_parts
53
53
  sut = Catalog.new(yaml_with_parts)
54
- exp =<<-EOS
54
+ exp = <<-EOS
55
55
  part1.re
56
56
  part2.re
57
57
  EOS
@@ -60,21 +60,21 @@ part2.re
60
60
 
61
61
  def test_parts_with_empty
62
62
  sut = Catalog.new(yaml)
63
- assert_equal("", sut.parts)
63
+ assert_equal('', sut.parts)
64
64
  end
65
65
 
66
66
  def test_parts2
67
67
  sut = Catalog.new(yaml_with_parts)
68
- assert_equal(["ch01.re",
69
- {"part1.re" => ["ch02.re"]},
70
- "ch03.re",
71
- {"part2.re" => ["ch04.re", "ch05.re"]}],
68
+ assert_equal(['ch01.re',
69
+ { 'part1.re' => ['ch02.re'] },
70
+ 'ch03.re',
71
+ { 'part2.re' => ['ch04.re', 'ch05.re'] }],
72
72
  sut.parts_with_chaps)
73
73
  end
74
74
 
75
75
  def test_postdef
76
76
  sut = Catalog.new(yaml)
77
- exp =<<-EOS
77
+ exp = <<-EOS
78
78
  back01.re
79
79
  back02.re
80
80
  EOS
@@ -83,14 +83,13 @@ back02.re
83
83
 
84
84
  def test_from_object
85
85
  sut = Catalog.new(yaml_hash)
86
- exp =<<-EOS
86
+ exp = <<-EOS
87
87
  ch01.re
88
88
  ch02.re
89
89
  EOS
90
90
  assert_equal(exp.chomp, sut.chaps)
91
91
  end
92
92
 
93
-
94
93
  private
95
94
 
96
95
  def yaml
@@ -115,10 +114,10 @@ POSTDEF:
115
114
  end
116
115
 
117
116
  def yaml_hash
118
- {"PREDEF" => %w(pre01.re pre02.re),
119
- "CHAPS" => %w(ch01.re ch02.re),
120
- "APPENDIX" => %w(post01.re post02.re),
121
- "POSTDEF" => %w(back01.re back02.re)}
117
+ { 'PREDEF' => %w[pre01.re pre02.re],
118
+ 'CHAPS' => %w[ch01.re ch02.re],
119
+ 'APPENDIX' => %w[post01.re post02.re],
120
+ 'POSTDEF' => %w[back01.re back02.re] }
122
121
  end
123
122
 
124
123
  def yaml_with_parts
@@ -25,7 +25,7 @@ CHAPS:
25
25
  end
26
26
 
27
27
  def test_parse_chaps_empty
28
- assert_equal "CHAPS:\n\n", parse_chaps("")
28
+ assert_equal "CHAPS:\n\n", parse_chaps('')
29
29
  assert_equal "CHAPS:\n\n", parse_chaps(nil)
30
30
  end
31
31
 
@@ -61,13 +61,13 @@ CHAPS:
61
61
  end
62
62
 
63
63
  def test_parse_parts_chaps_empty
64
- assert_equal "CHAPS:\n\n", parse_parts("", "")
64
+ assert_equal "CHAPS:\n\n", parse_parts('', '')
65
65
  assert_equal "CHAPS:\n\n", parse_parts(nil, nil)
66
66
  end
67
67
 
68
68
  def test_parse_postdef
69
- assert_equal "APPENDIX:\n\n", parse_postdef("", true)
70
- assert_equal "POSTDEF:\n\n", parse_postdef("")
71
- assert_equal "POSTDEF:\n\n", parse_postdef("", false)
69
+ assert_equal "APPENDIX:\n\n", parse_postdef('', true)
70
+ assert_equal "POSTDEF:\n\n", parse_postdef('')
71
+ assert_equal "POSTDEF:\n\n", parse_postdef('', false)
72
72
  end
73
73
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'review/compiler'
5
3
  require 'review/book'
@@ -9,38 +7,42 @@ class CompilerTest < Test::Unit::TestCase
9
7
  include ReVIEW
10
8
 
11
9
  def setup
12
- @builder = LATEXBuilder.new()
10
+ @builder = LATEXBuilder.new
13
11
  @c = Compiler.new(@builder)
14
12
  end
15
13
 
16
14
  def test_parse_args
17
- args = @c.__send__(:parse_args, "[foo][bar]")
18
- assert_equal ["foo","bar"], args
15
+ args = @c.__send__(:parse_args, '[foo][bar]')
16
+ assert_equal ['foo', 'bar'], args
19
17
  end
20
18
 
21
19
  def test_parse_args_with_brace1
22
- args = @c.__send__(:parse_args, "[fo[\\][\\]o][bar]")
23
- assert_equal ["fo[][]o","bar"], args
20
+ args = @c.__send__(:parse_args, '[fo[\\][\\]o][bar]')
21
+ assert_equal ['fo[][]o', 'bar'], args
24
22
  end
25
23
 
26
24
  def test_parse_args_with_brace2
27
- args = @c.__send__(:parse_args, "[f\\]o\\]o][bar]")
28
- assert_equal ["f]o]o","bar"], args
25
+ args = @c.__send__(:parse_args, '[f\\]o\\]o][bar]')
26
+ assert_equal ['f]o]o', 'bar'], args
29
27
  end
30
28
 
31
29
  def test_parse_args_with_backslash
32
- args = @c.__send__(:parse_args, "[foo][bar\\buz]")
33
- assert_equal ["foo","bar\\buz"], args
30
+ args = @c.__send__(:parse_args, '[foo][bar\\buz]')
31
+ assert_equal ['foo', 'bar\\buz'], args
34
32
  end
35
33
 
36
34
  def test_parse_args_with_backslash2
37
- args = @c.__send__(:parse_args, "[foo][bar\\#\\[\\!]")
38
- assert_equal ["foo","bar\\#\\[\\!"], args
35
+ args = @c.__send__(:parse_args, '[foo][bar\\#\\[\\!]')
36
+ assert_equal ['foo', 'bar\\#\\[\\!'], args
39
37
  end
40
38
 
41
39
  def test_parse_args_with_backslash3
42
- args = @c.__send__(:parse_args, "[foo][bar\\\\buz]")
43
- assert_equal ["foo","bar\\buz"], args
40
+ args = @c.__send__(:parse_args, '[foo][bar\\\\buz]')
41
+ assert_equal ['foo', 'bar\\buz'], args
44
42
  end
45
- end
46
43
 
44
+ def test_replace_fence
45
+ actual = @c.__send__(:replace_fence, '@<m>${}\\}|$, @<m>|{}\\}\\$|, @<m>|\\{\\a\\}|, @<tt>|}|, @<tt>|\\|, @<tt>|\\\\|, @<tt>|\\\\\\|')
46
+ assert_equal '@<m>{{\\}\\\\\\}|}, @<m>{{\\}\\\\\\}\\$}, @<m>{\\{\\a\\\\\\}}, @<tt>{\\}}, @<tt>{\\\\}, @<tt>{\\\\\\\\}, @<tt>{\\\\\\\\\\\\}', actual
47
+ end
48
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'review/epubmaker'
5
3
 
@@ -9,18 +7,18 @@ class ConfigureTest < Test::Unit::TestCase
9
7
  def setup
10
8
  @maker = ReVIEW::EPUBMaker.new
11
9
  @config = ReVIEW::Configure.values
12
- @config.merge!({
13
- "bookname" => "sample",
14
- "title" => "Sample Book",
15
- "version" => 2,
16
- "urnid" => "http://example.jp/",
17
- "date" => "2011-01-01",
18
- "language" => "ja",
19
- "epubmaker" => {"flattocindent" => true,
20
- "title" => "Sample Book(EPUB)"},
21
- })
10
+ @config.merge!(
11
+ 'bookname' => 'sample',
12
+ 'title' => 'Sample Book',
13
+ 'version' => 2,
14
+ 'urnid' => 'http://example.jp/',
15
+ 'date' => '2011-01-01',
16
+ 'language' => 'ja',
17
+ 'epubmaker' => { 'flattocindent' => true,
18
+ 'title' => 'Sample Book(EPUB)' }
19
+ )
22
20
  @output = StringIO.new
23
- I18n.setup(@config["language"])
21
+ I18n.setup(@config['language'])
24
22
  end
25
23
 
26
24
  def test_configure_class
@@ -28,67 +26,66 @@ class ConfigureTest < Test::Unit::TestCase
28
26
  end
29
27
 
30
28
  def test_configure_get
31
- bookname = @config["bookname"]
32
- assert_equal "sample", bookname
29
+ bookname = @config['bookname']
30
+ assert_equal 'sample', bookname
33
31
  end
34
32
 
35
33
  def test_configure_get2
36
- assert_equal true, @config["epubmaker"]["flattocindent"]
34
+ assert_equal true, @config['epubmaker']['flattocindent']
37
35
  end
38
36
 
39
37
  def test_configure_with_maker
40
- @config.maker = "epubmaker"
41
- assert_equal true, @config["flattocindent"]
42
- assert_equal true, @config["epubmaker"]["flattocindent"]
38
+ @config.maker = 'epubmaker'
39
+ assert_equal true, @config['flattocindent']
40
+ assert_equal true, @config['epubmaker']['flattocindent']
43
41
  end
44
42
 
45
43
  def test_configure_with_maker_override
46
- @config.maker = "epubmaker"
47
- assert_equal "Sample Book(EPUB)", @config["title"]
48
- @config.maker = "pdfmaker"
49
- assert_equal "Sample Book", @config["title"]
44
+ @config.maker = 'epubmaker'
45
+ assert_equal 'Sample Book(EPUB)', @config['title']
46
+ @config.maker = 'pdfmaker'
47
+ assert_equal 'Sample Book', @config['title']
50
48
  end
51
49
 
52
50
  def test_configure_with_invalidmaker
53
- @config.maker = "pdfmaker"
54
- assert_equal nil, @config["flattocindent"]
55
- assert_equal true, @config["epubmaker"]["flattocindent"]
51
+ @config.maker = 'pdfmaker'
52
+ assert_equal nil, @config['flattocindent']
53
+ assert_equal true, @config['epubmaker']['flattocindent']
56
54
  end
57
55
 
58
56
  def test_check_version_nosetting
59
- @config.delete("review_version")
57
+ @config.delete('review_version')
60
58
  assert_raise ReVIEW::ConfigError do
61
- @config.check_version("2.0.0")
59
+ @config.check_version('2.0.0')
62
60
  end
63
61
  end
64
62
 
65
63
  def test_check_version_noversion
66
- @config["review_version"] = nil
64
+ @config['review_version'] = nil
67
65
  assert_nothing_raised ReVIEW::ConfigError do
68
- @config.check_version("2.0.0")
66
+ @config.check_version('2.0.0')
69
67
  end
70
68
  end
71
69
 
72
70
  def test_check_version
73
- @config["review_version"] = "2.1"
71
+ @config['review_version'] = '2.1'
74
72
  assert_nothing_raised do
75
- @config.check_version("2.1.0")
73
+ @config.check_version('2.1.0')
76
74
  end
77
75
  assert_nothing_raised do
78
- @config.check_version("2.2.0")
76
+ @config.check_version('2.2.0')
79
77
  end
80
78
  assert_nothing_raised do
81
- @config.check_version("2.2.5")
79
+ @config.check_version('2.2.5')
82
80
  end
83
81
  assert_raise ReVIEW::ConfigError do
84
- @config.check_version("2.0.0")
82
+ @config.check_version('2.0.0')
85
83
  end
86
84
  assert_raise ReVIEW::ConfigError do
87
- @config.check_version("3.0.0")
85
+ @config.check_version('3.0.0')
88
86
  end
89
87
  assert_raise ReVIEW::ConfigError do
90
- @config.check_version("1.8.0")
88
+ @config.check_version('1.8.0')
91
89
  end
92
90
  end
93
-
94
91
  end