review 0.6.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +441 -0
- data/README.rdoc +25 -0
- data/Rakefile +13 -1
- data/VERSION +1 -1
- data/bin/review-check +1 -1
- data/bin/review-compile +19 -10
- data/bin/review-epubmaker +114 -17
- data/bin/review-index +8 -1
- data/bin/review-pdfmaker +378 -0
- data/bin/review-preproc +2 -3
- data/bin/review-vol +1 -2
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +60 -0
- data/debian/docs +5 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/format.rdoc +477 -0
- data/doc/format.re +19 -0
- data/doc/format_idg.rdoc +180 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +17 -0
- data/doc/sample.yaml +8 -4
- data/lib/lineinput.rb +1 -1
- data/lib/review/book.rb +43 -36
- data/lib/review/builder.rb +78 -33
- data/lib/review/compiler.rb +45 -48
- data/lib/review/epubbuilder.rb +1 -675
- data/lib/review/exception.rb +1 -1
- data/lib/review/htmlbuilder.rb +627 -49
- data/lib/review/htmlutils.rb +5 -0
- data/lib/review/idgxmlbuilder.rb +239 -250
- data/lib/review/index.rb +84 -7
- data/lib/review/latexbuilder.rb +261 -42
- data/lib/review/latexutils.rb +15 -6
- data/lib/review/preprocessor.rb +40 -6
- data/lib/review/textutils.rb +22 -0
- data/lib/review/topbuilder.rb +4 -1
- data/lib/uuid.rb +312 -0
- data/review.gemspec +44 -12
- data/test/CHAPS +2 -0
- data/test/bib.re +13 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +1191 -0
- data/test/test_builder.rb +147 -0
- data/test/test_htmlbuilder.rb +191 -10
- data/test/test_htmlutils.rb +24 -0
- data/test/test_idgxmlbuilder.rb +310 -0
- data/test/test_index.rb +15 -0
- data/test/test_latexbuilder.rb +217 -6
- data/test/test_lineinput.rb +198 -0
- data/test/test_textutils.rb +68 -0
- data/test/test_uuid.rb +156 -0
- metadata +43 -10
- data/doc/format.txt +0 -434
- data/doc/format_idg.txt +0 -194
- data/doc/format_sjis.txt +0 -313
- data/setup.rb +0 -1587
- data/test/test_epubbuilder.rb +0 -73
data/test/test_index.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/index'
|
5
|
+
|
6
|
+
class ListIndexTest < Test::Unit::TestCase
|
7
|
+
include ReVIEW
|
8
|
+
|
9
|
+
def setup
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_index
|
13
|
+
# ReVIEW::ChapterIndex.parse("=Foo\nfoo\n=Foo2\nfoo2\n".split(/\n/))
|
14
|
+
end
|
15
|
+
end
|
data/test/test_latexbuilder.rb
CHANGED
@@ -15,12 +15,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
15
15
|
"subdirmode" => nil,
|
16
16
|
"stylesheet" => nil, # for EPUBBuilder
|
17
17
|
}
|
18
|
-
|
19
|
-
compiler.
|
20
|
-
chapter = Chapter.new(nil, 1, '
|
21
|
-
chapter.setParameter(@param)
|
18
|
+
ReVIEW.book.param = @param
|
19
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
20
|
+
@chapter = Chapter.new(nil, 1, 'chap1', nil, StringIO.new)
|
22
21
|
location = Location.new(nil, nil)
|
23
|
-
@builder.bind(compiler, chapter, location)
|
22
|
+
@builder.bind(@compiler, @chapter, location)
|
24
23
|
end
|
25
24
|
|
26
25
|
def test_headline_level1
|
@@ -34,6 +33,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
34
33
|
assert_equal %Q|\\chapter*{this is test.}\n|, @builder.result
|
35
34
|
end
|
36
35
|
|
36
|
+
def test_headline_level1_with_inlinetag
|
37
|
+
@builder.headline(1,"test","this @<b>{is} test.<&\"_>")
|
38
|
+
assert_equal %Q|\\chapter{this \\textbf{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}\n|, @builder.result
|
39
|
+
end
|
40
|
+
|
37
41
|
def test_headline_level2
|
38
42
|
@builder.headline(2,"test","this is test.")
|
39
43
|
assert_equal %Q|\\section{this is test.}\n|, @builder.result
|
@@ -68,7 +72,214 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
68
72
|
|
69
73
|
def test_href_with_underscore
|
70
74
|
ret = @builder.compile_href("http://example.com/aaa/bbb", "AAA_BBB")
|
71
|
-
assert_equal %Q|\\href{http://example.com/aaa/bbb}{AAA\\
|
75
|
+
assert_equal %Q|\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}|, ret
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_inline_br
|
79
|
+
ret = @builder.inline_br("")
|
80
|
+
assert_equal %Q|\\\\\n|, ret
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_inline_br_with_other_strings
|
84
|
+
ret = @builder.compile_inline("abc@<br>{}def")
|
85
|
+
assert_equal %Q|abc\\\\\ndef|, ret
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_inline_u
|
89
|
+
ret = @builder.compile_inline("abc@<u>{def}ghi")
|
90
|
+
assert_equal %Q|abc\\Underline{def}ghi|, ret
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_inline_i
|
94
|
+
ret = @builder.compile_inline("abc@<i>{def}ghi")
|
95
|
+
assert_equal %Q|abc\\textit{def}ghi|, ret
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_inline_i_and_escape
|
99
|
+
ret = @builder.compile_inline("test @<i>{inline<&;\\ test} test2")
|
100
|
+
assert_equal %Q|test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, ret
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_inline_dtp
|
104
|
+
ret = @builder.compile_inline("abc@<dtp>{def}ghi")
|
105
|
+
assert_equal %Q|abcghi|, ret
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_inline_code
|
109
|
+
ret = @builder.compile_inline("abc@<code>{def}ghi")
|
110
|
+
assert_equal %Q|abc\\texttt{def}ghi|, ret
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_inline_raw
|
114
|
+
ret = @builder.compile_inline("@<raw>{@<tt>{inline!$%\\}}")
|
115
|
+
assert_equal %Q|@\\textless{}tt\\textgreater{}\\{inline!\\textdollar{}\\%\\}|, ret
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_inline_sup
|
119
|
+
ret = @builder.compile_inline("abc@<sup>{def}")
|
120
|
+
assert_equal %Q|abc\\textsuperscript{def}|, ret
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_inline_sub
|
124
|
+
ret = @builder.compile_inline("abc@<sub>{def}")
|
125
|
+
assert_equal %Q|abc\\textsubscript{def}|, ret
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_inline_b
|
129
|
+
ret = @builder.compile_inline("abc@<b>{def}")
|
130
|
+
assert_equal %Q|abc\\textbf{def}|, ret
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_inline_b_and_escape
|
134
|
+
ret = @builder.compile_inline("test @<b>{inline<&;\\ test} test2")
|
135
|
+
assert_equal %Q|test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, ret
|
136
|
+
end
|
137
|
+
def test_inline_em
|
138
|
+
ret = @builder.compile_inline("abc@<em>{def}")
|
139
|
+
assert_equal %Q|abc\\textbf{def}|, ret
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_inline_strong
|
143
|
+
ret = @builder.compile_inline("abc@<strong>{def}")
|
144
|
+
assert_equal %Q|abc\\textbf{def}|, ret
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_inline_u
|
148
|
+
ret = @builder.compile_inline("abc@<u>{def}ghi")
|
149
|
+
assert_equal %Q|abc\\Underline{def}ghi|, ret
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_inline_m
|
153
|
+
ret = @builder.compile_inline("abc@<m>{\\alpha^n = \inf < 2}ghi")
|
154
|
+
assert_equal "abc $\\alpha^n = inf < 2$ ghi", ret
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_inline_tt
|
158
|
+
ret = @builder.compile_inline("test @<tt>{inline test} test2")
|
159
|
+
assert_equal %Q|test \\texttt{inline test} test2|, ret
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_inline_tt_endash
|
163
|
+
ret = @builder.compile_inline("test @<tt>{in-line --test ---foo ----bar -----buz} --test2")
|
164
|
+
assert_equal %Q|test \\texttt{in-line {-}{-}test {-}{-}-foo {-}{-}{-}{-}bar {-}{-}{-}{-}-buz} --test2|, ret
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_inline_tti
|
168
|
+
ret = @builder.compile_inline("test @<tti>{inline test} test2")
|
169
|
+
assert_equal %Q|test \\texttt{\\textit{inline test}} test2|, ret
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_inline_ttb
|
173
|
+
ret = @builder.compile_inline("test @<ttb>{inline test} test2")
|
174
|
+
assert_equal %Q|test \\texttt{\\textbf{inline test}} test2|, ret
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_inline_uchar
|
178
|
+
ret = @builder.compile_inline("test @<uchar>{2460} test2")
|
179
|
+
assert_equal %Q|test \\UTF{2460} test2|, ret
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_headline_level1
|
183
|
+
@builder.headline(1,"test","this is test.")
|
184
|
+
assert_equal %Q|\\chapter{this is test.}\n|, @builder.result
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_quote
|
188
|
+
lines = ["foo", "bar", "","buz"]
|
189
|
+
@builder.quote(lines)
|
190
|
+
assert_equal %Q|\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n|, @builder.result
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_memo
|
194
|
+
@builder.memo(["test1", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
|
195
|
+
assert_equal %Q|\\begin{reviewminicolumn}\n\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}\ntest1\n\ntest<i>2</i>\n\\end{reviewminicolumn}\n|, @builder.result
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_flushright
|
199
|
+
@builder.flushright(["foo", "bar", "","buz"])
|
200
|
+
assert_equal %Q|\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n|, @builder.raw_result
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_noindent
|
204
|
+
@builder.noindent
|
205
|
+
@builder.paragraph(["foo", "bar"])
|
206
|
+
@builder.paragraph(["foo2", "bar2"])
|
207
|
+
assert_equal %Q|\\noindent\n\nfoo\nbar\n\nfoo2\nbar2\n|, @builder.raw_result
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_raw
|
211
|
+
@builder.raw("<&>\\n")
|
212
|
+
assert_equal %Q|<&>\n|, @builder.result
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_image
|
216
|
+
def @chapter.image(id)
|
217
|
+
item = ImageIndex::Item.new("sampleimg",1)
|
218
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
219
|
+
item
|
220
|
+
end
|
221
|
+
|
222
|
+
@builder.image_image("sampleimg","sample photo",nil)
|
223
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics{./images/chap1-sampleimg.png}\n\\label{image:chap1:sampleimg}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_image_with_metric
|
227
|
+
def @chapter.image(id)
|
228
|
+
item = ImageIndex::Item.new("sampleimg",1)
|
229
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
230
|
+
item
|
231
|
+
end
|
232
|
+
|
233
|
+
@builder.image_image("sampleimg","sample photo","scale=1.2")
|
234
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\label{image:chap1:sampleimg}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_indepimage
|
238
|
+
def @chapter.image(id)
|
239
|
+
item = ImageIndex::Item.new("sampleimg",1)
|
240
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
241
|
+
item
|
242
|
+
end
|
243
|
+
|
244
|
+
# FIXME: indepimage's caption should not be with a counter.
|
245
|
+
@builder.indepimage("sampleimg","sample photo",nil)
|
246
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_indepimage_without_caption
|
250
|
+
def @chapter.image(id)
|
251
|
+
item = ImageIndex::Item.new("sampleimg",1)
|
252
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
253
|
+
item
|
254
|
+
end
|
255
|
+
|
256
|
+
# FIXME: indepimage's caption should not be with a counter.
|
257
|
+
@builder.indepimage("sampleimg",nil,nil)
|
258
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, @builder.raw_result
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_indepimage_with_metric
|
262
|
+
def @chapter.image(id)
|
263
|
+
item = ImageIndex::Item.new("sampleimg",1)
|
264
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
265
|
+
item
|
266
|
+
end
|
267
|
+
|
268
|
+
# FIXME: indepimage's caption should not be with a counter.
|
269
|
+
@builder.indepimage("sampleimg","sample photo","scale=1.2")
|
270
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_indepimage_without_caption_but_with_metric
|
274
|
+
def @chapter.image(id)
|
275
|
+
item = ImageIndex::Item.new("sampleimg",1)
|
276
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
277
|
+
item
|
278
|
+
end
|
279
|
+
|
280
|
+
# FIXME: indepimage's caption should not be with a counter.
|
281
|
+
@builder.indepimage("sampleimg",nil,"scale=1.2")
|
282
|
+
assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, @builder.raw_result
|
72
283
|
end
|
73
284
|
|
74
285
|
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'lineinput'
|
5
|
+
require 'tempfile'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class LineInputTest < Test::Unit::TestCase
|
9
|
+
def test_initialize
|
10
|
+
io = StringIO.new
|
11
|
+
li = LineInput.new(io)
|
12
|
+
assert_equal 0, li.lineno
|
13
|
+
assert !li.eof?
|
14
|
+
assert_equal "#<LineInput file=#{io.inspect} line=0>", li.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_gets
|
18
|
+
content = "abc\ndef\r\nghi\rjkl"
|
19
|
+
do_test_gets(StringIO.new(content))
|
20
|
+
Tempfile.open("lineinput_test") do |io|
|
21
|
+
io.print content
|
22
|
+
io.rewind
|
23
|
+
do_test_gets(io)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def do_test_gets(io)
|
28
|
+
li = LineInput.new(io)
|
29
|
+
|
30
|
+
assert_equal "abc\n", li.gets
|
31
|
+
assert_equal "def\r\n", li.gets
|
32
|
+
assert_equal "ghi\rjkl", li.gets
|
33
|
+
assert_equal 3, li.lineno
|
34
|
+
assert !li.eof?
|
35
|
+
|
36
|
+
assert_equal nil, li.gets
|
37
|
+
assert_equal 4, li.lineno # XXX: OK?
|
38
|
+
assert li.eof?
|
39
|
+
|
40
|
+
assert_equal nil, li.gets
|
41
|
+
assert_equal 4, li.lineno
|
42
|
+
assert li.eof?
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_ungets
|
46
|
+
io = StringIO.new('abc')
|
47
|
+
li = LineInput.new(io)
|
48
|
+
|
49
|
+
line = li.gets
|
50
|
+
assert_equal line, li.ungets(line)
|
51
|
+
assert_equal 0, li.lineno
|
52
|
+
assert_equal line, li.gets
|
53
|
+
|
54
|
+
li.ungets('xyz')
|
55
|
+
assert_equal 0, li.lineno
|
56
|
+
li.ungets('xyz')
|
57
|
+
assert_equal -1, li.lineno # XXX: OK?
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_peek
|
61
|
+
li = LineInput.new(StringIO.new)
|
62
|
+
assert_equal nil, li.peek
|
63
|
+
|
64
|
+
li = LineInput.new(StringIO.new('abc'))
|
65
|
+
assert_equal 'abc', li.peek
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_next?
|
69
|
+
li = LineInput.new(StringIO.new)
|
70
|
+
assert !li.next?
|
71
|
+
|
72
|
+
li = LineInput.new(StringIO.new('abc'))
|
73
|
+
assert li.next?
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_skip_blank_lines
|
77
|
+
if "".respond_to?(:encode)
|
78
|
+
euc_jp_spc = " ".encode("EUC-JP")
|
79
|
+
else
|
80
|
+
euc_jp_spc = "\xa1\xa1" # EUC-JP 全角空白
|
81
|
+
end
|
82
|
+
[
|
83
|
+
["", 0, nil],
|
84
|
+
["\n \n \nabc", 3, 'abc'],
|
85
|
+
["\t", 1, nil],
|
86
|
+
[euc_jp_spc, 0, euc_jp_spc],
|
87
|
+
].each do |text, n, rest|
|
88
|
+
li = LineInput.new(StringIO.new(text))
|
89
|
+
assert_equal n, li.skip_blank_lines
|
90
|
+
assert_equal rest, li.gets
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_gets_if
|
95
|
+
io = StringIO.new
|
96
|
+
li = LineInput.new(io)
|
97
|
+
assert_equal nil, li.gets_if(//)
|
98
|
+
|
99
|
+
io = StringIO.new("abc\ndef\nghi")
|
100
|
+
li = LineInput.new(io)
|
101
|
+
|
102
|
+
assert_equal "abc\n", li.gets_if(//)
|
103
|
+
assert_equal nil, li.gets_if(/^X/)
|
104
|
+
assert_equal nil, li.gets_if(/^g/)
|
105
|
+
assert_equal "def\n", li.gets_if(/^d/)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_gets_unless
|
109
|
+
io = StringIO.new
|
110
|
+
li = LineInput.new(io)
|
111
|
+
assert_equal nil, li.gets_unless(//)
|
112
|
+
|
113
|
+
io = StringIO.new("abc\ndef\nghi")
|
114
|
+
li = LineInput.new(io)
|
115
|
+
|
116
|
+
assert_equal nil, li.gets_unless(//)
|
117
|
+
assert_equal "abc\n", li.gets_unless(/^X/)
|
118
|
+
assert_equal nil, li.gets_unless(/^d/)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_each
|
122
|
+
content = "abc\ndef\nghi"
|
123
|
+
io = StringIO.new(content)
|
124
|
+
li = LineInput.new(io)
|
125
|
+
|
126
|
+
data = ''
|
127
|
+
li.each {|l| data << l }
|
128
|
+
assert_equal content, data
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_while_match
|
132
|
+
io = StringIO.new("abc\ndef\nghi")
|
133
|
+
li = LineInput.new(io)
|
134
|
+
|
135
|
+
li.while_match(/^[ad]/) {}
|
136
|
+
assert_equal 2, li.lineno
|
137
|
+
assert_equal "ghi", li.gets
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_getlines_while
|
141
|
+
io = StringIO.new("abc\ndef\nghi")
|
142
|
+
li = LineInput.new(io)
|
143
|
+
|
144
|
+
buf = li.getlines_while(/^[ad]/)
|
145
|
+
assert_equal ["abc\n", "def\n"], buf
|
146
|
+
assert_equal 2, li.lineno
|
147
|
+
assert_equal "ghi", li.gets
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_until_match
|
151
|
+
io = StringIO.new("abc\ndef\nghi")
|
152
|
+
li = LineInput.new(io)
|
153
|
+
|
154
|
+
li.until_match(/^[^a]/) {}
|
155
|
+
assert_equal 1, li.lineno
|
156
|
+
assert_equal "def\n", li.gets
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_getlines_until
|
160
|
+
io = StringIO.new("abc\ndef\nghi")
|
161
|
+
li = LineInput.new(io)
|
162
|
+
|
163
|
+
buf = li.getlines_until(/^[^a]/)
|
164
|
+
assert_equal ["abc\n"], buf
|
165
|
+
assert_equal 1, li.lineno
|
166
|
+
assert_equal "def\n", li.gets
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_until_terminator
|
170
|
+
io = StringIO.new("abc\n//}\ndef\nghi\n//}\njkl\nmno")
|
171
|
+
li = LineInput.new(io)
|
172
|
+
|
173
|
+
data = ''
|
174
|
+
li.until_terminator(%r<\A//\}>) {|l| data << l }
|
175
|
+
assert_equal "abc\n", data
|
176
|
+
assert_equal 2, li.lineno
|
177
|
+
|
178
|
+
data = ''
|
179
|
+
li.until_terminator(%r<\A//\}>) {|l| data << l }
|
180
|
+
assert_equal "def\nghi\n", data
|
181
|
+
assert_equal 5, li.lineno
|
182
|
+
|
183
|
+
data = ''
|
184
|
+
li.until_terminator(%r<\A//\}>) {|l| data << l }
|
185
|
+
assert_equal "jkl\nmno", data
|
186
|
+
assert_equal 7, li.lineno
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_until_terminator
|
190
|
+
io = StringIO.new("abc\ndef\n//}\nghi\n//}")
|
191
|
+
li = LineInput.new(io)
|
192
|
+
|
193
|
+
data = li.getblock(%r<\A//\}>)
|
194
|
+
assert_equal ["abc\n", "def\n"], data
|
195
|
+
assert_equal 3, li.lineno
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|