review 2.3.0 → 2.4.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/.rubocop.yml +90 -66
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/NEWS.ja.md +82 -0
- data/NEWS.md +83 -0
- data/README.md +5 -3
- data/Rakefile +8 -8
- data/bin/review +1 -5
- data/bin/review-catalog-converter +22 -27
- data/bin/review-check +36 -43
- data/bin/review-checkdep +10 -15
- data/bin/review-compile +37 -55
- data/bin/review-epubmaker +4 -5
- data/bin/review-index +21 -29
- data/bin/review-init +26 -37
- data/bin/review-pdfmaker +0 -2
- data/bin/review-preproc +25 -45
- data/bin/review-validate +19 -18
- data/bin/review-vol +15 -27
- data/doc/config.yml.sample +5 -2
- data/doc/format.ja.md +20 -1
- data/doc/format.md +21 -5
- data/doc/images/review-generate.png +0 -0
- data/lib/epubmaker.rb +1 -3
- data/lib/epubmaker/content.rb +24 -27
- data/lib/epubmaker/epubcommon.rb +135 -148
- data/lib/epubmaker/epubv2.rb +39 -46
- data/lib/epubmaker/epubv3.rb +93 -103
- data/lib/epubmaker/producer.rb +138 -151
- data/lib/epubmaker/zip_exporter.rb +21 -26
- data/lib/review/book.rb +3 -6
- data/lib/review/book/base.rb +78 -103
- data/lib/review/book/chapter.rb +36 -40
- data/lib/review/book/compilable.rb +28 -31
- data/lib/review/book/image_finder.rb +6 -13
- data/lib/review/book/index.rb +100 -121
- data/lib/review/book/page_metric.rb +2 -7
- data/lib/review/book/part.rb +18 -20
- data/lib/review/book/volume.rb +9 -13
- data/lib/review/builder.rb +81 -116
- data/lib/review/catalog.rb +15 -19
- data/lib/review/compiler.rb +64 -83
- data/lib/review/configure.rb +87 -97
- data/lib/review/converter.rb +2 -7
- data/lib/review/epubbuilder.rb +1 -3
- data/lib/review/epubmaker.rb +213 -205
- data/lib/review/exception.rb +2 -4
- data/lib/review/extentions.rb +0 -1
- data/lib/review/extentions/hash.rb +2 -2
- data/lib/review/extentions/string.rb +5 -30
- data/lib/review/htmlbuilder.rb +320 -375
- data/lib/review/htmltoc.rb +4 -7
- data/lib/review/htmlutils.rb +29 -32
- data/lib/review/i18n.rb +33 -44
- data/lib/review/i18n.yml +3 -3
- data/lib/review/idgxmlbuilder.rb +309 -345
- data/lib/review/latexbuilder.rb +175 -212
- data/lib/review/latexindex.rb +2 -8
- data/lib/review/latexutils.rb +33 -43
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +21 -0
- data/lib/review/makerhelper.rb +1 -4
- data/lib/review/markdownbuilder.rb +44 -53
- data/lib/review/md2inaobuilder.rb +6 -12
- data/lib/review/pdfmaker.rb +143 -173
- data/lib/review/preprocessor.rb +64 -101
- data/lib/review/rstbuilder.rb +126 -158
- data/lib/review/sec_counter.rb +18 -34
- data/lib/review/template.rb +4 -5
- data/lib/review/textbuilder.rb +2 -3
- data/lib/review/textutils.rb +7 -13
- data/lib/review/tocparser.rb +31 -56
- data/lib/review/tocprinter.rb +26 -52
- data/lib/review/topbuilder.rb +219 -247
- data/lib/review/unfold.rb +15 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +75 -99
- data/lib/review/webtocprinter.rb +15 -20
- data/lib/review/yamlloader.rb +13 -15
- data/review.gemspec +20 -22
- data/templates/latex/layout.tex.erb +2 -2
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/black.eps +280 -0
- data/test/assets/fit.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 +65 -0
- data/test/assets/test_template.tex +1 -1
- data/test/book_test_helper.rb +2 -2
- data/test/run_test.rb +4 -4
- data/test/sample-book/src/Rakefile +21 -22
- data/test/syntax-book/Gemfile +4 -0
- data/test/syntax-book/Rakefile +72 -0
- data/test/syntax-book/appA.re +22 -0
- data/test/syntax-book/bib.re +6 -0
- data/test/syntax-book/catalog.yml +15 -0
- data/test/syntax-book/ch01.re +136 -0
- data/test/syntax-book/ch02.re +351 -0
- data/test/syntax-book/ch03.re +82 -0
- data/test/syntax-book/config.yml +35 -0
- data/test/syntax-book/images/ball.png +0 -0
- data/test/syntax-book/images/cover.jpg +0 -0
- data/test/syntax-book/images/fractal.png +0 -0
- data/test/syntax-book/images/img3-1.png +0 -0
- data/test/syntax-book/images/inlineicon.jpg +0 -0
- data/test/syntax-book/images/logic.png +0 -0
- data/test/syntax-book/images/logic2.png +0 -0
- data/test/syntax-book/images/puzzle.jpg +0 -0
- data/test/syntax-book/images/table.jpg +0 -0
- data/test/syntax-book/part2.re +6 -0
- data/test/syntax-book/pre01.re +26 -0
- data/test/syntax-book/review-ext.rb +14 -0
- data/test/syntax-book/sty/jumoline.sty +310 -0
- data/test/syntax-book/sty/reviewmacro.sty +39 -0
- data/test/syntax-book/style.css +494 -0
- data/test/syntax-book/syntax.dic +2 -0
- data/test/test_book.rb +106 -111
- data/test/test_book_chapter.rb +21 -22
- data/test/test_book_part.rb +3 -5
- data/test/test_builder.rb +11 -22
- data/test/test_catalog.rb +17 -18
- data/test/test_catalog_converter_cmd.rb +5 -5
- data/test/test_compiler.rb +18 -16
- data/test/test_configure.rb +35 -38
- data/test/test_converter.rb +3 -4
- data/test/test_epub3maker.rb +136 -117
- data/test/test_epubmaker.rb +107 -114
- data/test/test_epubmaker_cmd.rb +2 -4
- data/test/test_extentions_hash.rb +32 -33
- data/test/test_helper.rb +9 -11
- data/test/test_htmlbuilder.rb +454 -420
- data/test/test_htmltoc.rb +8 -12
- data/test/test_htmlutils.rb +0 -2
- data/test/test_i18n.rb +159 -150
- data/test/test_idgxmlbuilder.rb +190 -197
- data/test/test_image_finder.rb +21 -22
- data/test/test_index.rb +24 -29
- data/test/test_latexbuilder.rb +274 -264
- data/test/test_lineinput.rb +7 -10
- data/test/test_location.rb +7 -7
- data/test/test_makerhelper.rb +13 -25
- data/test/test_markdownbuilder.rb +23 -26
- data/test/test_md2inaobuilder.rb +8 -11
- data/test/test_pdfmaker.rb +114 -123
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +3 -5
- data/test/test_rstbuilder.rb +92 -97
- data/test/test_template.rb +3 -7
- data/test/test_textutils.rb +27 -27
- data/test/test_tocparser.rb +2 -2
- data/test/test_topbuilder.rb +98 -103
- data/test/test_webtocprinter.rb +5 -6
- data/test/test_yamlloader.rb +42 -42
- data/test/test_zip_exporter.rb +12 -18
- metadata +86 -9
- data/lib/review/ewbbuilder.rb +0 -382
data/test/test_book.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
1
|
require 'book_test_helper'
|
|
4
2
|
|
|
5
3
|
class BookTest < Test::Unit::TestCase
|
|
@@ -31,9 +29,7 @@ class BookTest < Test::Unit::TestCase
|
|
|
31
29
|
test_const = "ReVIEW__BOOK__TEST__#{num}"
|
|
32
30
|
begin
|
|
33
31
|
Dir.mktmpdir do |dir|
|
|
34
|
-
File.open(File.join(dir, 'review-ext.rb'), 'w')
|
|
35
|
-
o.puts "#{test_const} = #{num}"
|
|
36
|
-
end
|
|
32
|
+
File.open(File.join(dir, 'review-ext.rb'), 'w') { |o| o.puts "#{test_const} = #{num}" }
|
|
37
33
|
Book.update_rubyenv(dir)
|
|
38
34
|
assert_equal num, (Object.class_eval { const_get(test_const) })
|
|
39
35
|
end
|
|
@@ -47,95 +43,95 @@ class BookTest < Test::Unit::TestCase
|
|
|
47
43
|
assert_equal '.re', book.ext
|
|
48
44
|
end
|
|
49
45
|
|
|
50
|
-
def
|
|
46
|
+
def test_read_chaps
|
|
51
47
|
Dir.mktmpdir do |dir|
|
|
52
48
|
book = Book::Base.new(dir)
|
|
53
|
-
assert_equal
|
|
49
|
+
assert_equal '', book.read_chaps
|
|
54
50
|
|
|
55
51
|
chaps_path = File.join(dir, 'CHAPS')
|
|
56
52
|
re1_path = File.join(dir, "123#{book.ext}")
|
|
57
53
|
re2_path = File.join(dir, "456#{book.ext}")
|
|
58
54
|
|
|
59
|
-
File.open(chaps_path, 'w') {|o| o.print "abc\n" }
|
|
60
|
-
File.open(re1_path, 'w') {|o| o.print "123\n" }
|
|
61
|
-
File.open(re2_path, 'w') {|o| o.print "456\n" }
|
|
55
|
+
File.open(chaps_path, 'w') { |o| o.print "abc\n" }
|
|
56
|
+
File.open(re1_path, 'w') { |o| o.print "123\n" }
|
|
57
|
+
File.open(re2_path, 'w') { |o| o.print "456\n" }
|
|
62
58
|
|
|
63
|
-
assert_equal "abc\n", book.
|
|
59
|
+
assert_equal "abc\n", book.read_chaps
|
|
64
60
|
|
|
65
61
|
File.unlink(chaps_path)
|
|
66
|
-
assert_equal "#{re1_path}\n#{re2_path}", book.
|
|
62
|
+
assert_equal "#{re1_path}\n#{re2_path}", book.read_chaps
|
|
67
63
|
|
|
68
64
|
File.unlink(re1_path)
|
|
69
|
-
assert_equal
|
|
65
|
+
assert_equal re2_path, book.read_chaps
|
|
70
66
|
|
|
71
67
|
File.unlink(re2_path)
|
|
72
|
-
assert_equal
|
|
68
|
+
assert_equal '', book.read_chaps
|
|
73
69
|
end
|
|
74
70
|
end
|
|
75
71
|
|
|
76
|
-
def
|
|
72
|
+
def test_read_part
|
|
77
73
|
Dir.mktmpdir do |dir|
|
|
78
74
|
book = Book::Base.new(dir)
|
|
79
75
|
assert !book.part_exist?
|
|
80
76
|
assert_raises Errno::ENOENT do # XXX: OK?
|
|
81
|
-
book.
|
|
77
|
+
book.read_part
|
|
82
78
|
end
|
|
83
79
|
|
|
84
80
|
chaps_path = File.join(dir, 'PART')
|
|
85
81
|
chaps_content = "abc\n"
|
|
86
|
-
File.open(chaps_path, 'w') {|o| o.print chaps_content }
|
|
82
|
+
File.open(chaps_path, 'w') { |o| o.print chaps_content }
|
|
87
83
|
|
|
88
84
|
assert book.part_exist?
|
|
89
|
-
assert_equal chaps_content, book.
|
|
85
|
+
assert_equal chaps_content, book.read_part
|
|
90
86
|
|
|
91
|
-
File.open(chaps_path, 'w') {|o| o.print "XYZ\n" }
|
|
92
|
-
assert_equal chaps_content, book.
|
|
87
|
+
File.open(chaps_path, 'w') { |o| o.print "XYZ\n" }
|
|
88
|
+
assert_equal chaps_content, book.read_part
|
|
93
89
|
end
|
|
94
90
|
end
|
|
95
91
|
|
|
96
|
-
def
|
|
92
|
+
def test_read_appendix
|
|
97
93
|
Dir.mktmpdir do |dir|
|
|
98
94
|
book = Book::Base.new(dir)
|
|
99
|
-
assert_equal
|
|
95
|
+
assert_equal '', book.read_appendix
|
|
100
96
|
|
|
101
97
|
post_path = File.join(dir, 'POSTDEF')
|
|
102
98
|
re1_path = File.join(dir, "123#{book.ext}")
|
|
103
99
|
re2_path = File.join(dir, "456#{book.ext}")
|
|
104
100
|
|
|
105
|
-
File.open(post_path, 'w') {|o| o.print "abc\n" }
|
|
106
|
-
File.open(re1_path, 'w') {|o| o.print "123\n" }
|
|
107
|
-
File.open(re2_path, 'w') {|o| o.print "456\n" }
|
|
101
|
+
File.open(post_path, 'w') { |o| o.print "abc\n" }
|
|
102
|
+
File.open(re1_path, 'w') { |o| o.print "123\n" }
|
|
103
|
+
File.open(re2_path, 'w') { |o| o.print "456\n" }
|
|
108
104
|
|
|
109
|
-
assert_equal "abc\n", book.
|
|
105
|
+
assert_equal "abc\n", book.read_appendix
|
|
110
106
|
|
|
111
107
|
File.unlink(post_path)
|
|
112
|
-
assert_equal "#{re1_path}\n#{re2_path}", book.
|
|
108
|
+
assert_equal "#{re1_path}\n#{re2_path}", book.read_appendix
|
|
113
109
|
|
|
114
110
|
File.unlink(re1_path)
|
|
115
|
-
assert_equal
|
|
111
|
+
assert_equal re2_path, book.read_appendix
|
|
116
112
|
|
|
117
113
|
File.unlink(re2_path)
|
|
118
|
-
assert_equal
|
|
114
|
+
assert_equal '', book.read_appendix
|
|
119
115
|
end
|
|
120
116
|
end
|
|
121
117
|
|
|
122
|
-
def
|
|
118
|
+
def test_read_postdef
|
|
123
119
|
Dir.mktmpdir do |dir|
|
|
124
120
|
book = Book::Base.new(dir)
|
|
125
|
-
assert_equal
|
|
121
|
+
assert_equal '', book.read_postdef
|
|
126
122
|
|
|
127
123
|
post_path = File.join(dir, 'POSTDEF')
|
|
128
124
|
re1_path = File.join(dir, "123#{book.ext}")
|
|
129
125
|
re2_path = File.join(dir, "456#{book.ext}")
|
|
130
126
|
|
|
131
|
-
File.open(post_path, 'w') {|o| o.print "abc\n" }
|
|
132
|
-
File.open(re1_path, 'w') {|o| o.print "123\n" }
|
|
133
|
-
File.open(re2_path, 'w') {|o| o.print "456\n" }
|
|
127
|
+
File.open(post_path, 'w') { |o| o.print "abc\n" }
|
|
128
|
+
File.open(re1_path, 'w') { |o| o.print "123\n" }
|
|
129
|
+
File.open(re2_path, 'w') { |o| o.print "456\n" }
|
|
134
130
|
|
|
135
|
-
assert_equal
|
|
131
|
+
assert_equal '', book.read_postdef
|
|
136
132
|
|
|
137
133
|
File.unlink(post_path)
|
|
138
|
-
assert_equal
|
|
134
|
+
assert_equal '', book.read_postdef
|
|
139
135
|
end
|
|
140
136
|
end
|
|
141
137
|
|
|
@@ -146,9 +142,8 @@ class BookTest < Test::Unit::TestCase
|
|
|
146
142
|
assert_raises Errno::ENOENT do # XXX: OK?
|
|
147
143
|
book.read_bib
|
|
148
144
|
end
|
|
149
|
-
|
|
150
145
|
bib_path = File.join(dir, "bib#{book.ext}")
|
|
151
|
-
File.open(bib_path, 'w') {|o| o.print "abc\n" }
|
|
146
|
+
File.open(bib_path, 'w') { |o| o.print "abc\n" }
|
|
152
147
|
|
|
153
148
|
assert book.bib_exist?
|
|
154
149
|
assert_equal "abc\n", book.read_bib
|
|
@@ -156,39 +151,39 @@ class BookTest < Test::Unit::TestCase
|
|
|
156
151
|
end
|
|
157
152
|
|
|
158
153
|
# backward compatible
|
|
159
|
-
def
|
|
154
|
+
def test_set_parameter
|
|
160
155
|
book = Book::Base.new(File.dirname(__FILE__))
|
|
161
156
|
book.config = :test
|
|
162
157
|
assert_equal :test, book.config
|
|
163
158
|
end
|
|
164
159
|
|
|
165
|
-
def
|
|
160
|
+
def test_set_config
|
|
166
161
|
book = Book::Base.new(File.dirname(__FILE__))
|
|
167
162
|
book.config = :test
|
|
168
163
|
assert_equal :test, book.config
|
|
169
164
|
end
|
|
170
165
|
|
|
171
166
|
def test_parse_chapters
|
|
172
|
-
mktmpbookdir 'CHAPS' => '' do |
|
|
167
|
+
mktmpbookdir 'CHAPS' => '' do |_dir, book, _files|
|
|
173
168
|
parts = book.instance_eval { parse_chapters }
|
|
174
169
|
assert_equal 0, parts.size
|
|
175
170
|
end
|
|
176
171
|
|
|
177
|
-
mktmpbookdir 'CHAPS' => "chapter1.re\nchapter2\n" do |dir, book,
|
|
172
|
+
mktmpbookdir 'CHAPS' => "chapter1.re\nchapter2\n" do |dir, book, _files|
|
|
178
173
|
parts = book.instance_eval { parse_chapters }
|
|
179
174
|
assert_equal 1, parts.size
|
|
180
175
|
|
|
181
176
|
assert_equal nil, parts[0].number
|
|
182
177
|
assert_equal 2, parts[0].chapters.size
|
|
183
|
-
chaps = parts[0].chapters.map {|ch| [ch.number, ch.name, ch.path] }
|
|
178
|
+
chaps = parts[0].chapters.map { |ch| [ch.number, ch.name, ch.path] }
|
|
184
179
|
expect = [
|
|
185
180
|
[1, 'chapter1', File.join(dir, 'chapter1.re')],
|
|
186
|
-
[2, 'chapter2', File.join(dir, 'chapter2')]
|
|
181
|
+
[2, 'chapter2', File.join(dir, 'chapter2')]
|
|
187
182
|
]
|
|
188
183
|
assert_equal expect, chaps
|
|
189
184
|
end
|
|
190
185
|
|
|
191
|
-
mktmpbookdir 'CHAPS' => <<EOC do |dir, book,
|
|
186
|
+
mktmpbookdir 'CHAPS' => <<EOC do |dir, book, _files|
|
|
192
187
|
part1_chapter1.re
|
|
193
188
|
part1_chapter2.re
|
|
194
189
|
|
|
@@ -204,28 +199,28 @@ EOC
|
|
|
204
199
|
|
|
205
200
|
assert_equal nil, parts[0].number
|
|
206
201
|
assert_equal 2, parts[0].chapters.size
|
|
207
|
-
chaps = parts[0].chapters.map {|ch| [ch.number, ch.name, ch.path] }
|
|
202
|
+
chaps = parts[0].chapters.map { |ch| [ch.number, ch.name, ch.path] }
|
|
208
203
|
expect = [
|
|
209
204
|
[1, 'part1_chapter1', File.join(dir, 'part1_chapter1.re')],
|
|
210
|
-
[2, 'part1_chapter2', File.join(dir, 'part1_chapter2.re')]
|
|
205
|
+
[2, 'part1_chapter2', File.join(dir, 'part1_chapter2.re')]
|
|
211
206
|
]
|
|
212
207
|
assert_equal expect, chaps
|
|
213
208
|
|
|
214
209
|
assert_equal nil, parts[1].number
|
|
215
210
|
assert_equal 3, parts[1].chapters.size
|
|
216
|
-
chaps = parts[1].chapters.map {|ch| [ch.number, ch.name, ch.path] }
|
|
211
|
+
chaps = parts[1].chapters.map { |ch| [ch.number, ch.name, ch.path] }
|
|
217
212
|
expect = [
|
|
218
213
|
[3, 'part2_chapter1', File.join(dir, 'part2_chapter1.re')],
|
|
219
214
|
[4, 'part2_chapter2', File.join(dir, 'part2_chapter2.re')],
|
|
220
|
-
[5, 'part2_chapter3', File.join(dir, 'part2_chapter3.re')]
|
|
215
|
+
[5, 'part2_chapter3', File.join(dir, 'part2_chapter3.re')]
|
|
221
216
|
]
|
|
222
217
|
assert_equal expect, chaps
|
|
223
218
|
|
|
224
219
|
assert_equal nil, parts[2].number
|
|
225
220
|
assert_equal 1, parts[2].chapters.size
|
|
226
|
-
chaps = parts[2].chapters.map {|ch| [ch.number, ch.name, ch.path] }
|
|
221
|
+
chaps = parts[2].chapters.map { |ch| [ch.number, ch.name, ch.path] }
|
|
227
222
|
expect = [
|
|
228
|
-
[6, 'part3_chapter1', File.join(dir, 'part3_chapter1.re')]
|
|
223
|
+
[6, 'part3_chapter1', File.join(dir, 'part3_chapter1.re')]
|
|
229
224
|
]
|
|
230
225
|
assert_equal expect, chaps
|
|
231
226
|
end
|
|
@@ -239,103 +234,103 @@ EOC
|
|
|
239
234
|
2,
|
|
240
235
|
"part1_chapter1.re\n\npart2_chpater1.re\n",
|
|
241
236
|
"part1\npart2\npart3\n",
|
|
242
|
-
%w
|
|
237
|
+
%w[part1 part2]
|
|
243
238
|
],
|
|
244
239
|
[
|
|
245
240
|
3,
|
|
246
241
|
"part1_chapter1.re\n\npart2_chapter1.re\n\npart3_chapter1.re",
|
|
247
242
|
"part1\n",
|
|
248
243
|
[
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
]
|
|
244
|
+
'part1',
|
|
245
|
+
'', # XXX: OK?
|
|
246
|
+
''
|
|
247
|
+
]
|
|
253
248
|
],
|
|
254
249
|
[
|
|
255
250
|
1,
|
|
256
251
|
"part1_chapter1.re\n",
|
|
257
|
-
|
|
252
|
+
'',
|
|
258
253
|
[
|
|
259
|
-
|
|
260
|
-
]
|
|
254
|
+
'', # XXX: OK?
|
|
255
|
+
]
|
|
261
256
|
],
|
|
262
257
|
[
|
|
263
258
|
1,
|
|
264
259
|
"part1_chapter1.re\n",
|
|
265
260
|
nil,
|
|
266
261
|
[
|
|
267
|
-
|
|
268
|
-
]
|
|
269
|
-
]
|
|
262
|
+
''
|
|
263
|
+
]
|
|
264
|
+
]
|
|
270
265
|
].each do |n_parts, chaps_text, parts_text, part_names|
|
|
271
266
|
n_test += 1
|
|
272
267
|
Dir.mktmpdir do |dir|
|
|
273
268
|
book = Book::Base.new(dir)
|
|
274
269
|
chaps_path = File.join(dir, 'CHAPS')
|
|
275
|
-
File.open(chaps_path, 'w') {|o| o.print chaps_text }
|
|
276
|
-
|
|
270
|
+
File.open(chaps_path, 'w') { |o| o.print chaps_text }
|
|
271
|
+
if parts_text
|
|
277
272
|
parts_path = File.join(dir, 'PART')
|
|
278
|
-
File.open(parts_path, 'w') {|o| o.print parts_text }
|
|
273
|
+
File.open(parts_path, 'w') { |o| o.print parts_text }
|
|
279
274
|
end
|
|
280
275
|
|
|
281
276
|
parts = book.instance_eval { parse_chapters }
|
|
282
|
-
assert_equal n_parts, parts.size, "
|
|
283
|
-
assert_equal part_names, parts.map
|
|
277
|
+
assert_equal n_parts, parts.size, "##{n_test}"
|
|
278
|
+
assert_equal part_names, parts.map(&:name), "##{n_test}"
|
|
284
279
|
end
|
|
285
280
|
end
|
|
286
281
|
end
|
|
287
282
|
|
|
288
283
|
def test_prefaces
|
|
289
|
-
mktmpbookdir do |
|
|
284
|
+
mktmpbookdir do |_dir, book, _files|
|
|
290
285
|
assert_equal nil, book.prefaces
|
|
291
286
|
end
|
|
292
287
|
|
|
293
|
-
mktmpbookdir 'PREDEF' => '' do |
|
|
288
|
+
mktmpbookdir 'PREDEF' => '' do |_dir, book, _files|
|
|
294
289
|
assert_equal nil, book.prefaces # XXX: OK?
|
|
295
290
|
end
|
|
296
291
|
|
|
297
292
|
mktmpbookdir 'PREDEF' => 'chapter1',
|
|
298
|
-
'chapter1.re' => '' do |
|
|
293
|
+
'chapter1.re' => '' do |_dir, book, files|
|
|
299
294
|
assert_kind_of Book::Part, book.prefaces
|
|
300
295
|
assert_equal '', book.prefaces.name
|
|
301
296
|
assert_equal 1, book.prefaces.chapters.size
|
|
302
|
-
assert_equal
|
|
297
|
+
assert_equal 'chapter1', book.prefaces.chapters.first.name
|
|
303
298
|
assert_equal files['chapter1.re'], book.prefaces.chapters.first.path
|
|
304
299
|
end
|
|
305
300
|
|
|
306
301
|
mktmpbookdir 'PREDEF' => "chapter1\n\nchapter2",
|
|
307
|
-
'chapter1.re' => '', 'chapter2.re' => '' do |
|
|
302
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |_dir, book, files|
|
|
308
303
|
assert_kind_of Book::Part, book.prefaces
|
|
309
304
|
assert_equal '', book.prefaces.name
|
|
310
305
|
assert_equal 2, book.prefaces.chapters.size
|
|
311
|
-
assert_equal
|
|
306
|
+
assert_equal 'chapter1', book.prefaces.chapters.first.name
|
|
312
307
|
assert_equal files['chapter1.re'], book.prefaces.chapters.first.path
|
|
313
|
-
assert_equal
|
|
308
|
+
assert_equal 'chapter2', book.prefaces.chapters.last.name
|
|
314
309
|
assert_equal files['chapter2.re'], book.prefaces.chapters.last.path
|
|
315
310
|
end
|
|
316
311
|
|
|
317
|
-
mktmpbookdir 'PREDEF' =>
|
|
318
|
-
'chapter1.re' => '', 'chapter2.re' => '' do |
|
|
312
|
+
mktmpbookdir 'PREDEF' => 'chapter1 chapter2',
|
|
313
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |_dir, book, _files|
|
|
319
314
|
assert_kind_of Book::Part, book.prefaces
|
|
320
315
|
assert_equal '', book.prefaces.name
|
|
321
316
|
assert_equal 2, book.prefaces.chapters.size # XXX: OK?
|
|
322
317
|
end
|
|
323
318
|
|
|
324
|
-
mktmpbookdir 'PREDEF' => 'not_exist' do |
|
|
319
|
+
mktmpbookdir 'PREDEF' => 'not_exist' do |_dir, book, _files|
|
|
325
320
|
assert_raises FileNotFound do
|
|
326
321
|
assert_equal nil, book.prefaces
|
|
327
322
|
end
|
|
328
323
|
end
|
|
329
324
|
|
|
330
325
|
mktmpbookdir 'PREDEF' => 'chapter1.re',
|
|
331
|
-
'chapter1.re' => '' do |
|
|
326
|
+
'chapter1.re' => '' do |_dir, book, _files|
|
|
332
327
|
assert_kind_of Book::Part, book.prefaces
|
|
333
328
|
assert_equal '', book.prefaces.name
|
|
334
329
|
assert_equal 1, book.prefaces.chapters.size
|
|
335
330
|
end
|
|
336
331
|
|
|
337
332
|
mktmpbookdir 'PREDEF' => 'chapter1.txt',
|
|
338
|
-
'chapter1.txt' => '' do |
|
|
333
|
+
'chapter1.txt' => '' do |_dir, book, _files|
|
|
339
334
|
assert_kind_of Book::Part, book.prefaces
|
|
340
335
|
assert_equal '', book.prefaces.name
|
|
341
336
|
assert_equal 1, book.prefaces.chapters.size
|
|
@@ -343,39 +338,39 @@ EOC
|
|
|
343
338
|
end
|
|
344
339
|
|
|
345
340
|
def test_appendix
|
|
346
|
-
mktmpbookdir do |
|
|
341
|
+
mktmpbookdir do |_dir, book, _files|
|
|
347
342
|
assert_equal nil, book.appendix
|
|
348
343
|
end
|
|
349
344
|
|
|
350
|
-
mktmpbookdir 'POSTDEF' => '' do |
|
|
345
|
+
mktmpbookdir 'POSTDEF' => '' do |_dir, book, _files|
|
|
351
346
|
assert_equal nil, book.appendix
|
|
352
347
|
end
|
|
353
348
|
|
|
354
349
|
mktmpbookdir 'POSTDEF' => 'chapter1',
|
|
355
|
-
'chapter1.re' => '' do |
|
|
350
|
+
'chapter1.re' => '' do |_dir, book, files|
|
|
356
351
|
assert_kind_of Book::Part, book.appendix
|
|
357
352
|
assert_equal '', book.appendix.name
|
|
358
353
|
assert_equal 1, book.appendix.chapters.size
|
|
359
|
-
assert_equal
|
|
354
|
+
assert_equal 'chapter1', book.appendix.chapters.first.name
|
|
360
355
|
assert_equal files['chapter1.re'], book.appendix.chapters.first.path
|
|
361
356
|
assert_equal 1, book.appendix.chapters.first.number
|
|
362
357
|
end
|
|
363
358
|
|
|
364
359
|
mktmpbookdir 'POSTDEF' => "chapter1\n\nchapter2",
|
|
365
|
-
'chapter1.re' => '', 'chapter2.re' => '' do |
|
|
360
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |_dir, book, files|
|
|
366
361
|
assert_kind_of Book::Part, book.appendix
|
|
367
362
|
assert_equal '', book.appendix.name
|
|
368
363
|
assert_equal 2, book.appendix.chapters.size
|
|
369
|
-
assert_equal
|
|
364
|
+
assert_equal 'chapter1', book.appendix.chapters.first.name
|
|
370
365
|
assert_equal files['chapter1.re'], book.appendix.chapters.first.path
|
|
371
|
-
assert_equal
|
|
366
|
+
assert_equal 'chapter2', book.appendix.chapters.last.name
|
|
372
367
|
assert_equal files['chapter2.re'], book.appendix.chapters.last.path
|
|
373
368
|
assert_equal 1, book.appendix.chapters.first.number
|
|
374
369
|
assert_equal 2, book.appendix.chapters.last.number
|
|
375
370
|
end
|
|
376
371
|
|
|
377
|
-
mktmpbookdir 'POSTDEF' =>
|
|
378
|
-
'chapter1.re' => '', 'chapter2.re' => '' do |
|
|
372
|
+
mktmpbookdir 'POSTDEF' => 'chapter1 chapter2',
|
|
373
|
+
'chapter1.re' => '', 'chapter2.re' => '' do |_dir, book, _files|
|
|
379
374
|
assert_kind_of Book::Part, book.appendix
|
|
380
375
|
assert_equal '', book.appendix.name
|
|
381
376
|
assert_equal 2, book.appendix.chapters.size # XXX: OK?
|
|
@@ -383,14 +378,14 @@ EOC
|
|
|
383
378
|
assert_equal 2, book.appendix.chapters.last.number
|
|
384
379
|
end
|
|
385
380
|
|
|
386
|
-
mktmpbookdir 'POSTDEF' => 'not_exist' do |
|
|
381
|
+
mktmpbookdir 'POSTDEF' => 'not_exist' do |_dir, book, _files|
|
|
387
382
|
assert_raises FileNotFound do
|
|
388
383
|
assert_equal nil, book.appendix
|
|
389
384
|
end
|
|
390
385
|
end
|
|
391
386
|
|
|
392
387
|
mktmpbookdir 'catalog.yml' => "APPENDIX:\n - p01.re",
|
|
393
|
-
'p01.re' => '= appendix' do |
|
|
388
|
+
'p01.re' => '= appendix' do |_dir, book, _files|
|
|
394
389
|
assert_equal 'appendix', book.appendix.chapters.first.title
|
|
395
390
|
assert_equal 1, book.appendix.chapters.first.number
|
|
396
391
|
end
|
|
@@ -398,7 +393,7 @@ EOC
|
|
|
398
393
|
|
|
399
394
|
def test_postscripts
|
|
400
395
|
mktmpbookdir 'catalog.yml' => "POSTDEF:\n - b01.re",
|
|
401
|
-
'b01.re' => '= back' do |
|
|
396
|
+
'b01.re' => '= back' do |_dir, book, _files|
|
|
402
397
|
assert_kind_of Book::Part, book.postscripts
|
|
403
398
|
assert_equal 1, book.postscripts.chapters.size
|
|
404
399
|
assert_equal 'back', book.postscripts.chapters.first.title
|
|
@@ -407,7 +402,7 @@ EOC
|
|
|
407
402
|
end
|
|
408
403
|
|
|
409
404
|
def test_parts
|
|
410
|
-
mktmpbookdir do |
|
|
405
|
+
mktmpbookdir do |_dir, book, _files|
|
|
411
406
|
assert book.parts.empty?
|
|
412
407
|
assert !book.part(0)
|
|
413
408
|
assert !book.part(1)
|
|
@@ -417,28 +412,28 @@ EOC
|
|
|
417
412
|
assert tmp.empty?
|
|
418
413
|
end
|
|
419
414
|
|
|
420
|
-
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3", 'PART' => "foo\nbar\n" do |
|
|
415
|
+
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3", 'PART' => "foo\nbar\n" do |_dir, book, _files|
|
|
421
416
|
parts = book.parts
|
|
422
417
|
assert_equal 2, parts.size
|
|
423
418
|
assert !book.part(0)
|
|
424
|
-
assert_equal
|
|
425
|
-
assert_equal
|
|
419
|
+
assert_equal 'foo', book.part(1).name
|
|
420
|
+
assert_equal 'bar', book.part(2).name
|
|
426
421
|
assert !book.part(3)
|
|
427
422
|
|
|
428
423
|
tmp = []
|
|
429
|
-
book.each_part {|p| tmp << p.number }
|
|
424
|
+
book.each_part { |p| tmp << p.number }
|
|
430
425
|
assert_equal [1, 2], tmp
|
|
431
426
|
end
|
|
432
427
|
end
|
|
433
428
|
|
|
434
429
|
def test_chapters
|
|
435
|
-
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3" do |
|
|
430
|
+
mktmpbookdir 'CHAPS' => "ch1\nch2\n\nch3" do |_dir, book, _files|
|
|
436
431
|
chapters = book.chapters
|
|
437
432
|
assert_equal 3, chapters.size
|
|
438
433
|
|
|
439
|
-
ch_names = %w
|
|
434
|
+
ch_names = %w[ch1 ch2 ch3]
|
|
440
435
|
tmp = []
|
|
441
|
-
book.each_chapter {|ch| tmp << ch.name }
|
|
436
|
+
book.each_chapter { |ch| tmp << ch.name }
|
|
442
437
|
assert_equal ch_names, tmp
|
|
443
438
|
|
|
444
439
|
ch_names.each do |name|
|
|
@@ -451,13 +446,13 @@ EOC
|
|
|
451
446
|
end
|
|
452
447
|
end
|
|
453
448
|
|
|
454
|
-
mktmpbookdir 'CHAPS' => "ch1.txt\nch2.txt\n\nch3.txt" do |
|
|
449
|
+
mktmpbookdir 'CHAPS' => "ch1.txt\nch2.txt\n\nch3.txt" do |_dir, book, _files|
|
|
455
450
|
chapters = book.chapters
|
|
456
451
|
assert_equal 3, chapters.size
|
|
457
452
|
|
|
458
|
-
ch_names = %w
|
|
453
|
+
ch_names = %w[ch1 ch2 ch3]
|
|
459
454
|
tmp = []
|
|
460
|
-
book.each_chapter {|ch| tmp << ch.name }
|
|
455
|
+
book.each_chapter { |ch| tmp << ch.name }
|
|
461
456
|
assert_equal ch_names, tmp
|
|
462
457
|
|
|
463
458
|
ch_names.each do |name|
|
|
@@ -472,7 +467,7 @@ EOC
|
|
|
472
467
|
end
|
|
473
468
|
|
|
474
469
|
def test_next_chapter
|
|
475
|
-
mktmpbookdir 'CHAPS' => "ch1\nch2" do |
|
|
470
|
+
mktmpbookdir 'CHAPS' => "ch1\nch2" do |_dir, book, _files|
|
|
476
471
|
chapter = book.chapter('ch1')
|
|
477
472
|
assert_equal book.chapter('ch2'), book.next_chapter(chapter)
|
|
478
473
|
|
|
@@ -482,7 +477,7 @@ EOC
|
|
|
482
477
|
end
|
|
483
478
|
|
|
484
479
|
def test_prev_chapter
|
|
485
|
-
mktmpbookdir 'CHAPS' => "ch1\nch2" do |
|
|
480
|
+
mktmpbookdir 'CHAPS' => "ch1\nch2" do |_dir, book, _files|
|
|
486
481
|
chapter = book.chapter('ch2')
|
|
487
482
|
assert_equal book.chapter('ch1'), book.prev_chapter(chapter)
|
|
488
483
|
|
|
@@ -492,21 +487,21 @@ EOC
|
|
|
492
487
|
end
|
|
493
488
|
|
|
494
489
|
def test_volume
|
|
495
|
-
mktmpbookdir do |
|
|
490
|
+
mktmpbookdir do |_dir, book, _files|
|
|
496
491
|
assert book.volume
|
|
497
492
|
assert_equal 0, book.volume.bytes
|
|
498
493
|
assert_equal 0, book.volume.chars
|
|
499
494
|
assert_equal 0, book.volume.lines
|
|
500
495
|
end
|
|
501
496
|
|
|
502
|
-
mktmpbookdir 'CHAPS' => 'chapter1.re', 'chapter1.re' => '12345' do |
|
|
497
|
+
mktmpbookdir 'CHAPS' => 'chapter1.re', 'chapter1.re' => '12345' do |_dir, book, _files|
|
|
503
498
|
assert book.volume
|
|
504
499
|
assert book.volume.bytes > 0
|
|
505
500
|
assert book.volume.chars > 0
|
|
506
501
|
assert book.volume.lines > 0
|
|
507
502
|
end
|
|
508
503
|
|
|
509
|
-
mktmpbookdir 'preface.re' => '12345' do |dir,
|
|
504
|
+
mktmpbookdir 'preface.re' => '12345' do |dir, _book, _files|
|
|
510
505
|
Dir.chdir(dir) do
|
|
511
506
|
book2 = Book::Base.new('.')
|
|
512
507
|
assert book2.volume
|
|
@@ -532,18 +527,18 @@ EOC
|
|
|
532
527
|
end
|
|
533
528
|
|
|
534
529
|
def test_page_metric_config
|
|
535
|
-
mktmpbookdir('config.yml'=>"bookname: book\npage_metric: B5\n") do |dir,
|
|
530
|
+
mktmpbookdir('config.yml' => "bookname: book\npage_metric: B5\n") do |dir, _book, _files|
|
|
536
531
|
book = Book::Base.new(dir)
|
|
537
|
-
config_file = File.join(dir,
|
|
532
|
+
config_file = File.join(dir, 'config.yml')
|
|
538
533
|
book.load_config(config_file)
|
|
539
534
|
assert_equal ReVIEW::Book::PageMetric::B5, book.page_metric
|
|
540
535
|
end
|
|
541
536
|
end
|
|
542
537
|
|
|
543
538
|
def test_page_metric_config_array
|
|
544
|
-
mktmpbookdir('config.yml'=>"bookname: book\npage_metric: [46, 80, 30, 74, 2]\n") do |dir,
|
|
539
|
+
mktmpbookdir('config.yml' => "bookname: book\npage_metric: [46, 80, 30, 74, 2]\n") do |dir, _book, _files|
|
|
545
540
|
book = Book::Base.new(dir)
|
|
546
|
-
config_file = File.join(dir,
|
|
541
|
+
config_file = File.join(dir, 'config.yml')
|
|
547
542
|
book.load_config(config_file)
|
|
548
543
|
assert_equal ReVIEW::Book::PageMetric::B5, book.page_metric
|
|
549
544
|
end
|