tenjin 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +30 -0
- data/README.txt +6 -4
- data/bin/rbtenjin +7 -2
- data/doc-api/classes/Tenjin.html +2 -2
- data/doc-api/created.rid +1 -1
- data/doc-api/files/README_txt.html +8 -5
- data/doc-api/files/lib/tenjin_rb.html +1 -1
- data/doc/examples.html +1 -1
- data/doc/faq.html +1 -1
- data/doc/users-guide.html +3 -3
- data/examples/form/Makefile +4 -1
- data/examples/form/Rakefile +5 -1
- data/examples/preprocessing/Makefile +4 -1
- data/examples/preprocessing/Rakefile +5 -1
- data/examples/preprocessing/select.rbhtml.cache +17 -0
- data/examples/table/Makefile +4 -1
- data/examples/table/Rakefile +5 -1
- data/lib/tenjin.rb +2 -2
- data/tenjin.gemspec +2 -2
- data/test/Rookbook.yaml +14 -0
- data/test/assert-text-equal.rb +1 -1
- data/test/data/users_guide/example1_S.result +1 -1
- data/test/test_all.rb +1 -1
- data/test/test_engine.rb +23 -54
- data/test/test_examples.rb +1 -1
- data/test/test_faq.rb +1 -1
- data/test/test_htmlhelper.rb +1 -1
- data/test/test_main.rb +189 -5
- data/test/test_template.rb +19 -4
- data/test/test_template.yaml +7 -6
- data/test/test_users_guide.rb +1 -1
- data/test/testcase-helper.rb +41 -13
- metadata +4 -2
data/CHANGES.txt
CHANGED
@@ -1,6 +1,36 @@
|
|
1
1
|
=begin
|
2
2
|
= CHANGES
|
3
3
|
|
4
|
+
|
5
|
+
== Release 0.6.2 (2008-02-24)
|
6
|
+
|
7
|
+
* Rubinius supported.
|
8
|
+
|
9
|
+
* Changed to convert texts before expressions into spaces when
|
10
|
+
command-line option '-S' specified.
|
11
|
+
|
12
|
+
ex. hoge.rbhtml
|
13
|
+
<?rb for item in @list ?>
|
14
|
+
<p>${item}</p>
|
15
|
+
<?rb end ?>
|
16
|
+
|
17
|
+
ex. result of '-S'
|
18
|
+
## 0.6.1
|
19
|
+
$ rbtenjin -S hoge.rbhtml
|
20
|
+
_buf = ''; for item in @list
|
21
|
+
escape((item).to_s);
|
22
|
+
end
|
23
|
+
_buf.to_s
|
24
|
+
|
25
|
+
## 0.6.2
|
26
|
+
$ rbtenjin -S hoge.rbhtml
|
27
|
+
_buf = ''; for item in @list
|
28
|
+
escape((item).to_s);
|
29
|
+
end
|
30
|
+
_buf.to_s
|
31
|
+
|
32
|
+
|
33
|
+
|
4
34
|
== Release 0.6.1 (2007-02-07)
|
5
35
|
|
6
36
|
=== Enhancements
|
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= README
|
2
2
|
|
3
|
-
release:: 0.6.
|
3
|
+
release:: 0.6.2
|
4
4
|
copyright:: copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
5
5
|
|
6
6
|
|
@@ -34,14 +34,16 @@ See doc/*.html for details.
|
|
34
34
|
|
35
35
|
$ sudo gem install tenjin
|
36
36
|
|
37
|
-
* Else download rbtenjin-0.6.
|
37
|
+
* Else download rbtenjin-0.6.2.tar.bz2 and just copy 'lib/tenjin.rb' and
|
38
38
|
'bin/rbtenjin' into proper directory.
|
39
39
|
|
40
|
-
$ tar xjf rbtenjin-0.6.
|
41
|
-
$ cd rbtenjin-0.6.
|
40
|
+
$ tar xjf rbtenjin-0.6.2.tar.bz2
|
41
|
+
$ cd rbtenjin-0.6.2/
|
42
42
|
$ sudo copy lib/tenjin.rb /usr/local/lib/ruby/1.8/site_ruby/1.8/
|
43
43
|
$ sudo copy bin/rbtenjin /usr/local/bin/
|
44
44
|
|
45
|
+
rbTenjin is tested with Ruby 1.8.6 and Rubinius.
|
46
|
+
|
45
47
|
|
46
48
|
== Attention
|
47
49
|
|
data/bin/rbtenjin
CHANGED
@@ -23,8 +23,8 @@
|
|
23
23
|
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
##
|
25
25
|
|
26
|
-
## $Rev:
|
27
|
-
## $Release: 0.6.
|
26
|
+
## $Rev: 70 $
|
27
|
+
## $Release: 0.6.2 $
|
28
28
|
|
29
29
|
require 'tenjin'
|
30
30
|
|
@@ -51,6 +51,11 @@ module Tenjin
|
|
51
51
|
n = text.count("\n")
|
52
52
|
n -= 1 if encode_newline && text[-1] == ?\n
|
53
53
|
@script << (@newline * n)
|
54
|
+
if text[-1] != ?\n
|
55
|
+
pos = text.rindex(?\n)
|
56
|
+
s = pos ? text[(pos+1)..-1] : text
|
57
|
+
@script << s.gsub(/[^\t]/, ' ')
|
58
|
+
end
|
54
59
|
end
|
55
60
|
|
56
61
|
## add expression code
|
data/doc-api/classes/Tenjin.html
CHANGED
@@ -77,7 +77,7 @@
|
|
77
77
|
<a href="Tenjin.html">Tenjin</a> module
|
78
78
|
</p>
|
79
79
|
<p>
|
80
|
-
$Rev: 65 $ $Release: 0.6.
|
80
|
+
$Rev: 65 $ $Release: 0.6.2 $
|
81
81
|
</p>
|
82
82
|
|
83
83
|
</div>
|
@@ -116,7 +116,7 @@ Class <a href="Tenjin/Template.html" class="link">Tenjin::Template</a><br />
|
|
116
116
|
<tr class="top-aligned-row context-row">
|
117
117
|
<td class="context-item-name">RELEASE</td>
|
118
118
|
<td>=</td>
|
119
|
-
<td class="context-item-value">('$Release: 0.6.
|
119
|
+
<td class="context-item-value">('$Release: 0.6.2 $' =~ /[\d.]+/) && $&</td>
|
120
120
|
</tr>
|
121
121
|
</table>
|
122
122
|
</div>
|
data/doc-api/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Mon, 25 Feb 2008 00:47:12 +0900
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Mon Feb 25 00:45:04 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -71,7 +71,7 @@
|
|
71
71
|
<div id="description">
|
72
72
|
<h1>README</h1>
|
73
73
|
<table>
|
74
|
-
<tr><td valign="top">release:</td><td>0.6.
|
74
|
+
<tr><td valign="top">release:</td><td>0.6.2
|
75
75
|
|
76
76
|
</td></tr>
|
77
77
|
<tr><td valign="top">copyright:</td><td>copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
@@ -129,18 +129,21 @@ See doc/*.html for details.
|
|
129
129
|
$ sudo gem install tenjin
|
130
130
|
</pre>
|
131
131
|
</li>
|
132
|
-
<li>Else download rbtenjin-0.6.
|
132
|
+
<li>Else download rbtenjin-0.6.2.tar.bz2 and just copy
|
133
133
|
‘lib/tenjin.rb’ and ‘bin/rbtenjin’ into proper
|
134
134
|
directory.
|
135
135
|
|
136
136
|
<pre>
|
137
|
-
$ tar xjf rbtenjin-0.6.
|
138
|
-
$ cd rbtenjin-0.6.
|
137
|
+
$ tar xjf rbtenjin-0.6.2.tar.bz2
|
138
|
+
$ cd rbtenjin-0.6.2/
|
139
139
|
$ sudo copy lib/tenjin.rb /usr/local/lib/ruby/1.8/site_ruby/1.8/
|
140
140
|
$ sudo copy bin/rbtenjin /usr/local/bin/
|
141
141
|
</pre>
|
142
142
|
</li>
|
143
143
|
</ul>
|
144
|
+
<p>
|
145
|
+
rbTenjin is tested with Ruby 1.8.6 and Rubinius.
|
146
|
+
</p>
|
144
147
|
<h2>Attention</h2>
|
145
148
|
<p>
|
146
149
|
rbTenjin is beta released. It means that API or specification may change in
|
data/doc/examples.html
CHANGED
data/doc/faq.html
CHANGED
data/doc/users-guide.html
CHANGED
@@ -14,10 +14,10 @@
|
|
14
14
|
|
15
15
|
<div align="left"><h1>rbTenjin User's Guide</h1></div>
|
16
16
|
<div align="left">
|
17
|
-
last update: $Date: 2008-02-
|
17
|
+
last update: $Date: 2008-02-24 11:43:28 +0900 (Sun, 24 Feb 2008) $<br>
|
18
18
|
</div>
|
19
19
|
|
20
|
-
<p>Release: 0.6.
|
20
|
+
<p>Release: 0.6.2
|
21
21
|
</p>
|
22
22
|
<p>Table of Contents:
|
23
23
|
<ul>
|
@@ -361,7 +361,7 @@ for item in ['<foo>', 'bar&bar', '"baz"']
|
|
361
361
|
i += 1
|
362
362
|
|
363
363
|
|
364
|
-
escape((item).to_s);
|
364
|
+
escape((item).to_s);
|
365
365
|
|
366
366
|
end
|
367
367
|
|
data/examples/form/Makefile
CHANGED
data/examples/form/Rakefile
CHANGED
@@ -2,10 +2,14 @@ task 'default' do
|
|
2
2
|
load 'main.rb'
|
3
3
|
end
|
4
4
|
|
5
|
+
task 'all2' do
|
6
|
+
system 'rbx main.rb' # Rubinius
|
7
|
+
end
|
8
|
+
|
5
9
|
task 'preprocess' do
|
6
10
|
system 'rbtenjin -a preprocess select.rbhtml'
|
7
11
|
end
|
8
12
|
|
9
13
|
task 'clean' do
|
10
|
-
rm_f Dir.glob('*.cache')
|
14
|
+
rm_f Dir.glob('*.{cache,rbc}')
|
11
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
_buf << %Q`<form>
|
2
|
+
<label>Select your language:</label>
|
3
|
+
<select name="lang">\n`
|
4
|
+
table = { @params[:lang] => ' selected="selected"' }
|
5
|
+
_buf << %Q` <option value="en" #{table["en"]}>Engilish</option>
|
6
|
+
<option value="fr" #{table["fr"]}>French</option>
|
7
|
+
<option value="de" #{table["de"]}>German</option>
|
8
|
+
<option value="es" #{table["es"]}>Spanish</option>
|
9
|
+
<option value="ch" #{table["ch"]}>Chinese</option>
|
10
|
+
<option value="ja" #{table["ja"]}>Japanese</option>
|
11
|
+
</select>
|
12
|
+
<input type="submit" value="OK" />
|
13
|
+
</form>
|
14
|
+
<p>
|
15
|
+
<a href="/app/index">Back</a> |
|
16
|
+
<a href="/app/show/#{@params[:id]}">Show #{escape((@params[:name]).to_s)}</a>
|
17
|
+
</p>\n`
|
data/examples/table/Makefile
CHANGED
data/examples/table/Rakefile
CHANGED
data/lib/tenjin.rb
CHANGED
data/tenjin.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
###
|
4
4
|
### $Rev: 68 $
|
5
|
-
### $Release: 0.6.
|
5
|
+
### $Release: 0.6.2 $
|
6
6
|
### copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
7
7
|
###
|
8
8
|
|
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
|
|
14
14
|
s.author = "makoto kuwata"
|
15
15
|
s.email = "kwa(at)kuwata-lab.com"
|
16
16
|
s.rubyforge_project = 'tenjin'
|
17
|
-
s.version = "0.6.
|
17
|
+
s.version = "0.6.2"
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
s.homepage = "http://www.kuwata-lab.com/tenjin/"
|
20
20
|
s.summary = "very fast and full-featured template engine"
|
data/test/Rookbook.yaml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
recipes:
|
3
|
+
|
4
|
+
- product: :clean
|
5
|
+
method*: |
|
6
|
+
rm_rf '**/*.rbc', 'test.log'
|
7
|
+
|
8
|
+
- product: :ruby_test
|
9
|
+
method*: |
|
10
|
+
sys 'ruby test_all.rb 2>&1 | tee test.log'
|
11
|
+
|
12
|
+
- product: :rubinius_test
|
13
|
+
method*: |
|
14
|
+
sys 'rubinius test_all.rb 2>&1 | tee test.log'
|
data/test/assert-text-equal.rb
CHANGED
data/test/test_all.rb
CHANGED
data/test/test_engine.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.6.
|
2
|
+
### $Rev: 72 $
|
3
|
+
### $Release: 0.6.2 $
|
4
4
|
### copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -8,7 +8,17 @@ require 'test/unit'
|
|
8
8
|
#require 'testutil'
|
9
9
|
require 'testcase-helper'
|
10
10
|
require 'assert-text-equal'
|
11
|
-
|
11
|
+
if defined?(RBX_VERSION)
|
12
|
+
require 'kwalify'
|
13
|
+
def load_yaml_str(s)
|
14
|
+
return Kwalify::Yaml.load(s)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
require 'yaml'
|
18
|
+
def load_yaml_str(s)
|
19
|
+
return YAML.load(s)
|
20
|
+
end
|
21
|
+
end
|
12
22
|
|
13
23
|
require 'tenjin'
|
14
24
|
|
@@ -17,7 +27,7 @@ class TenjinEngineTest < Test::Unit::TestCase
|
|
17
27
|
|
18
28
|
s = File.read(__FILE__.sub(/\.\w+$/, '.yaml'))
|
19
29
|
s.gsub!(/^\t/, ' ' * 8)
|
20
|
-
ydoc =
|
30
|
+
ydoc = load_yaml_str(s)
|
21
31
|
_data_convert(ydoc, 'ruby')
|
22
32
|
TESTDATA = {}
|
23
33
|
ydoc.each { |e| TESTDATA[e['name']] = e }
|
@@ -53,7 +63,6 @@ class TenjinEngineTest < Test::Unit::TestCase
|
|
53
63
|
end
|
54
64
|
|
55
65
|
def _test_basic
|
56
|
-
|
57
66
|
## setup
|
58
67
|
_setup()
|
59
68
|
|
@@ -298,49 +307,8 @@ class TenjinEngineTest < Test::Unit::TestCase
|
|
298
307
|
end
|
299
308
|
|
300
309
|
|
301
|
-
def test_change_layout()
|
302
|
-
data = TESTDATA['test_change_layout']
|
303
|
-
## setup
|
304
|
-
basenames = %w[baselayout customlayout content]
|
305
|
-
for basename in basenames
|
306
|
-
File.write("#{basename}.rbhtml", data[basename])
|
307
|
-
end
|
308
|
-
## body
|
309
|
-
begin
|
310
|
-
engine = Tenjin::Engine.new(:layout=>'baselayout.rbhtml',
|
311
|
-
:templateclass=>_template_class())
|
312
|
-
output = engine.render('content.rbhtml')
|
313
|
-
expected = data['expected']
|
314
|
-
assert_text_equal(expected, output)
|
315
|
-
ensure
|
316
|
-
for basename in basenames
|
317
|
-
Dir.glob("#{basename}.rbhtml*").each do |fname|
|
318
|
-
File.unlink(fname)
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
|
325
|
-
def test_context_scope
|
326
|
-
return if ENV['TEST'] && ENV['TEST'] != 'template_args'
|
327
|
-
data = TESTDATA['test_context_scope']
|
328
|
-
content = data['content']
|
329
|
-
expected = data['expected']
|
330
|
-
begin
|
331
|
-
File.write('base.rbhtml', data['base'])
|
332
|
-
File.write('part.rbhtml', data['part'])
|
333
|
-
engine = Tenjin::Engine.new()
|
334
|
-
actual = engine.render('base.rbhtml');
|
335
|
-
assert_text_equal(expected, actual)
|
336
|
-
ensure
|
337
|
-
_remove_files(['base', 'part'])
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
310
|
|
342
311
|
def test_template_args
|
343
|
-
return if ENV['TEST'] && ENV['TEST'] != 'template_args'
|
344
312
|
data = TESTDATA['test_template_args']
|
345
313
|
content = data['content']
|
346
314
|
expected = data['expected']
|
@@ -359,7 +327,9 @@ class TenjinEngineTest < Test::Unit::TestCase
|
|
359
327
|
assert_not_nil(args1)
|
360
328
|
output = engine.render('content.rbhtml', context)
|
361
329
|
end
|
362
|
-
|
330
|
+
msg = ex.to_s.sub(/:0x[0-9a-fA-F]\w+/, ':0x12345')
|
331
|
+
msg = msg[0, errormsg.length-1]+'>' if defined?(RBX_VERSION)
|
332
|
+
assert_equal(errormsg, msg)
|
363
333
|
# when cache file exist
|
364
334
|
ex = assert_raise(NameError) do
|
365
335
|
#File.unlink('content.rbhtml');
|
@@ -370,7 +340,10 @@ class TenjinEngineTest < Test::Unit::TestCase
|
|
370
340
|
assert_equal(args1, args2)
|
371
341
|
output = engine.render('content.rbhtml', context)
|
372
342
|
end
|
373
|
-
assert_equal(errormsg, ex.to_s.sub(/:0x\w+>/, '>'))
|
343
|
+
#assert_equal(errormsg, ex.to_s.sub(/:0x\w+>/, '>'))
|
344
|
+
msg = ex.to_s.sub(/:0x[0-9a-fA-F]\w+/, ':0x12345')
|
345
|
+
msg = msg[0, errormsg.length-1]+'>' if defined?(RBX_VERSION)
|
346
|
+
assert_equal(errormsg, msg)
|
374
347
|
ensure
|
375
348
|
_remove_files(['content'])
|
376
349
|
end
|
@@ -507,12 +480,8 @@ class TenjinEngineTest < Test::Unit::TestCase
|
|
507
480
|
end
|
508
481
|
|
509
482
|
|
510
|
-
|
511
|
-
|
512
|
-
for m in self.instance_methods
|
513
|
-
private m if m =~ /^test_/ && m != targetname
|
514
|
-
end
|
515
|
-
end
|
483
|
+
self.select_target_test()
|
484
|
+
|
516
485
|
|
517
486
|
end
|
518
487
|
|
data/test/test_examples.rb
CHANGED
data/test/test_faq.rb
CHANGED
data/test/test_htmlhelper.rb
CHANGED
data/test/test_main.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.6.
|
2
|
+
### $Rev: 71 $
|
3
|
+
### $Release: 0.6.2 $
|
4
4
|
### copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -211,11 +211,13 @@ class TenjinMainTest < Test::Unit::TestCase
|
|
211
211
|
# end
|
212
212
|
|
213
213
|
|
214
|
-
def
|
214
|
+
def test_render() # (nothing), -a render
|
215
215
|
@options = ""
|
216
216
|
@input = INPUT
|
217
217
|
@expected = OUTPUT
|
218
218
|
_test()
|
219
|
+
@options = '-a render'
|
220
|
+
_test()
|
219
221
|
end
|
220
222
|
|
221
223
|
|
@@ -259,6 +261,178 @@ class TenjinMainTest < Test::Unit::TestCase
|
|
259
261
|
end
|
260
262
|
|
261
263
|
|
264
|
+
INPUT_FOR_RETRIEVE = <<END
|
265
|
+
<div>
|
266
|
+
<?rb if list ?>
|
267
|
+
<table>
|
268
|
+
<thead>
|
269
|
+
<tr>
|
270
|
+
<th>#</th><th>item</th>
|
271
|
+
</tr>
|
272
|
+
</thead>
|
273
|
+
</tbody>
|
274
|
+
<?rb i = 0 ?>
|
275
|
+
<?rb for item in list ?>
|
276
|
+
\t<?rb i += 1 ?>
|
277
|
+
<tr bgcolor="${i % 2 ? "#FFCCCC" : "#CCCCFF"}">
|
278
|
+
\t<td>\#{i}</td>
|
279
|
+
\t<td>${item}</td>
|
280
|
+
</tr>
|
281
|
+
<?rb end ?>
|
282
|
+
</tbody>
|
283
|
+
</table>
|
284
|
+
<?rb end ?>
|
285
|
+
</div>
|
286
|
+
END
|
287
|
+
|
288
|
+
|
289
|
+
def test_retrieve() # -S, -a retrieve
|
290
|
+
@input = INPUT_FOR_RETRIEVE
|
291
|
+
@expected = <<'END'
|
292
|
+
_buf = '';
|
293
|
+
if list
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
i = 0
|
302
|
+
for item in list
|
303
|
+
i += 1
|
304
|
+
escape((i % 2 ? "#FFCCCC" : "#CCCCFF").to_s);
|
305
|
+
|
306
|
+
escape((item).to_s);
|
307
|
+
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
_buf.to_s
|
314
|
+
END
|
315
|
+
@options = '-S'
|
316
|
+
_test()
|
317
|
+
@options = '-a retrieve'
|
318
|
+
_test()
|
319
|
+
end
|
320
|
+
|
321
|
+
|
322
|
+
def test_retrieve2() # -SU, -SNU
|
323
|
+
@input = INPUT_FOR_RETRIEVE
|
324
|
+
@expected = <<'END'
|
325
|
+
_buf = '';
|
326
|
+
if list
|
327
|
+
|
328
|
+
i = 0
|
329
|
+
for item in list
|
330
|
+
i += 1
|
331
|
+
escape((i % 2 ? "#FFCCCC" : "#CCCCFF").to_s);
|
332
|
+
|
333
|
+
escape((item).to_s);
|
334
|
+
|
335
|
+
end
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
_buf.to_s
|
340
|
+
END
|
341
|
+
@options = '-SU'
|
342
|
+
_test()
|
343
|
+
#
|
344
|
+
@expected = <<'END'
|
345
|
+
1: _buf = '';
|
346
|
+
2: if list
|
347
|
+
|
348
|
+
10: i = 0
|
349
|
+
11: for item in list
|
350
|
+
12: i += 1
|
351
|
+
13: escape((i % 2 ? "#FFCCCC" : "#CCCCFF").to_s);
|
352
|
+
|
353
|
+
15: escape((item).to_s);
|
354
|
+
|
355
|
+
17: end
|
356
|
+
|
357
|
+
20: end
|
358
|
+
|
359
|
+
22: _buf.to_s
|
360
|
+
END
|
361
|
+
@options = '-SUN'
|
362
|
+
_test()
|
363
|
+
end
|
364
|
+
|
365
|
+
|
366
|
+
def test_retrieve3() # -SC, -SNC
|
367
|
+
@input = INPUT_FOR_RETRIEVE
|
368
|
+
@expected = <<'END'
|
369
|
+
_buf = '';
|
370
|
+
if list
|
371
|
+
i = 0
|
372
|
+
for item in list
|
373
|
+
i += 1
|
374
|
+
escape((i % 2 ? "#FFCCCC" : "#CCCCFF").to_s);
|
375
|
+
escape((item).to_s);
|
376
|
+
end
|
377
|
+
end
|
378
|
+
_buf.to_s
|
379
|
+
END
|
380
|
+
@options = '-SC'
|
381
|
+
_test()
|
382
|
+
#
|
383
|
+
@expected = <<'END'
|
384
|
+
1: _buf = '';
|
385
|
+
2: if list
|
386
|
+
10: i = 0
|
387
|
+
11: for item in list
|
388
|
+
12: i += 1
|
389
|
+
13: escape((i % 2 ? "#FFCCCC" : "#CCCCFF").to_s);
|
390
|
+
15: escape((item).to_s);
|
391
|
+
17: end
|
392
|
+
20: end
|
393
|
+
22: _buf.to_s
|
394
|
+
END
|
395
|
+
@options = '-SNC'
|
396
|
+
_test()
|
397
|
+
end
|
398
|
+
|
399
|
+
|
400
|
+
def test_statements() # -X, -a statements
|
401
|
+
@input = INPUT_FOR_RETRIEVE
|
402
|
+
@expected = <<'END'
|
403
|
+
_buf = '';
|
404
|
+
if list
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
i = 0
|
413
|
+
for item in list
|
414
|
+
i += 1
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
|
422
|
+
end
|
423
|
+
|
424
|
+
_buf.to_s
|
425
|
+
END
|
426
|
+
@options = '-X'
|
427
|
+
_test()
|
428
|
+
@options = '-a statements'
|
429
|
+
_test()
|
430
|
+
end
|
431
|
+
|
432
|
+
# def test_dump() # -d, -a dump
|
433
|
+
# end
|
434
|
+
|
435
|
+
|
262
436
|
# def test_indent() # -si2
|
263
437
|
# @options = "-si2"
|
264
438
|
# @input = INPUT
|
@@ -393,7 +567,11 @@ class TenjinMainTest < Test::Unit::TestCase
|
|
393
567
|
@context_file = context_filename
|
394
568
|
@context_data = CONTEXT1
|
395
569
|
#@exception = yaml.parser.ScannerError
|
396
|
-
|
570
|
+
if defined?(RBX_VERSION)
|
571
|
+
@exception = RbYAML::ScannerError
|
572
|
+
else
|
573
|
+
@exception = ArgumentError
|
574
|
+
end
|
397
575
|
_test()
|
398
576
|
end
|
399
577
|
|
@@ -404,7 +582,10 @@ class TenjinMainTest < Test::Unit::TestCase
|
|
404
582
|
@input = INPUT
|
405
583
|
@expected = OUTPUT
|
406
584
|
@exception = NameError
|
407
|
-
if defined?(
|
585
|
+
if defined?(RBX_VERSION)
|
586
|
+
#@errormsg = "Missing or uninitialized constant: CGI"
|
587
|
+
@errormsg = "Missing or uninitialized constant: ERB"
|
588
|
+
elsif defined?(YARVCore)
|
408
589
|
#@errormsg = "uninitialized constant Tenjin::Context::CGI"
|
409
590
|
@errormsg = "uninitialized constant Tenjin::Context::ERB"
|
410
591
|
else
|
@@ -561,4 +742,7 @@ END
|
|
561
742
|
end
|
562
743
|
|
563
744
|
|
745
|
+
self.select_target_test()
|
746
|
+
|
747
|
+
|
564
748
|
end
|
data/test/test_template.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.6.
|
2
|
+
### $Rev: 71 $
|
3
|
+
### $Release: 0.6.2 $
|
4
4
|
### copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -15,7 +15,12 @@ class TenjinTemplateTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
filename = __FILE__.sub(/\.\w+$/, '.yaml')
|
17
17
|
#load_yaml_testdata(filename)
|
18
|
-
|
18
|
+
if defined?(RBX_VERSION)
|
19
|
+
lang = ['rubinius', 'ruby']
|
20
|
+
else
|
21
|
+
lang = 'ruby'
|
22
|
+
end
|
23
|
+
eval load_yaml_testdata(filename, :lang=>lang)
|
19
24
|
|
20
25
|
def _test
|
21
26
|
|
@@ -68,7 +73,14 @@ class TenjinTemplateTest < Test::Unit::TestCase
|
|
68
73
|
template.render(@context)
|
69
74
|
end
|
70
75
|
#assert_equal(@exception, ex.class.name)
|
71
|
-
|
76
|
+
if @errormsg
|
77
|
+
errmsg = ex.to_s.sub(/:0x[0-9a-fA-F]+/, ':0x12345')
|
78
|
+
if defined?(RBX_VERSION)
|
79
|
+
assert_equal(@errormsg, errmsg[0, @errormsg.length-1] + '>')
|
80
|
+
else
|
81
|
+
assert_equal(@errormsg, errmsg)
|
82
|
+
end
|
83
|
+
end
|
72
84
|
assert_equal(@filename, ex.filename) if @filename
|
73
85
|
else
|
74
86
|
template = @templateclass.new(@options)
|
@@ -110,4 +122,7 @@ END
|
|
110
122
|
#def test_import_module2()
|
111
123
|
|
112
124
|
|
125
|
+
self.select_target_test()
|
126
|
+
|
127
|
+
|
113
128
|
end
|
data/test/test_template.yaml
CHANGED
@@ -416,7 +416,7 @@
|
|
416
416
|
desc: lspaces
|
417
417
|
testopts: { spacechar: '^' }
|
418
418
|
input*:
|
419
|
-
|
419
|
+
python: |4
|
420
420
|
<?py
|
421
421
|
i = 0
|
422
422
|
for item in ['a', 'b', 'c']:
|
@@ -430,7 +430,7 @@
|
|
430
430
|
<?py
|
431
431
|
#endfor
|
432
432
|
?>
|
433
|
-
|
433
|
+
ruby: |4
|
434
434
|
<?rb
|
435
435
|
i = 0
|
436
436
|
for item in ['a', 'b', 'c']
|
@@ -459,7 +459,7 @@
|
|
459
459
|
|
460
460
|
#endfor
|
461
461
|
|
462
|
-
"ruby": |5
|
462
|
+
"ruby": |5
|
463
463
|
^^
|
464
464
|
i = 0
|
465
465
|
for item in ['a', 'b', 'c']
|
@@ -889,7 +889,8 @@
|
|
889
889
|
"ruby": NameError
|
890
890
|
errormsg*:
|
891
891
|
"python": "name 'name2' is not defined"
|
892
|
-
"ruby": "undefined local variable or method `name2' for #<Tenjin::Context>"
|
892
|
+
"ruby": "undefined local variable or method `name2' for #<Tenjin::Context:0x12345>"
|
893
|
+
#"rubinius": 'undefined local variable or method `name2\' for #<Tenjin::Context:0x12345 @name="world" @_buf="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">\\n">'
|
893
894
|
|
894
895
|
|
895
896
|
##
|
@@ -1112,7 +1113,7 @@
|
|
1112
1113
|
#{{link_to('"Show '+_P("item['name']")+'"', '/items/show/'+_p("item['id']"))}}
|
1113
1114
|
#{{escape('<b>'+_P('item["name"]')+'</b>')}}
|
1114
1115
|
"ruby": |
|
1115
|
-
<?RB def link_to(label, url) ?>
|
1116
|
+
<?RB def self.link_to(label, url) ?>
|
1116
1117
|
<?RB require 'cgi' ?>
|
1117
1118
|
<?RB return '<a href="%s">%s</a>' % [CGI::escape(url).gsub(/%2F/,'/'), label] ?>
|
1118
1119
|
<?RB end ?>
|
@@ -1144,7 +1145,7 @@
|
|
1144
1145
|
''', to_str(_decode_params(link_to('"Show '+_P("item['name']")+'"', '/items/show/'+_p("item['id']")))), '''
|
1145
1146
|
''', to_str(_decode_params(escape('<b>'+_P('item["name"]')+'</b>'))), '''\n''', ));
|
1146
1147
|
"ruby": |
|
1147
|
-
def link_to(label, url)
|
1148
|
+
def self.link_to(label, url)
|
1148
1149
|
require 'cgi'
|
1149
1150
|
return '<a href="%s">%s</a>' % [CGI::escape(url).gsub(/%2F/,'/'), label]
|
1150
1151
|
end
|
data/test/test_users_guide.rb
CHANGED
data/test/testcase-helper.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.6.
|
2
|
+
### $Rev: 72 $
|
3
|
+
### $Release: 0.6.2 $
|
4
4
|
### copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
|
5
5
|
###
|
6
6
|
|
7
|
-
|
7
|
+
if defined?(RBX_VERSION)
|
8
|
+
require 'kwalify'
|
9
|
+
def load_yaml_documents_str(s, &block)
|
10
|
+
parser = Kwalify::Yaml::Parser.new()
|
11
|
+
parser.parse_documents(s, &block)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
require 'yaml'
|
15
|
+
def load_yaml_documents_str(s, &block)
|
16
|
+
YAML.load_documents(s, &block)
|
17
|
+
end
|
18
|
+
end
|
8
19
|
require 'test/unit/testcase'
|
9
20
|
|
10
21
|
|
@@ -19,7 +30,13 @@ def _data_convert(data, lang='ruby')
|
|
19
30
|
v = data[k]
|
20
31
|
if k[-1,1] == '*'
|
21
32
|
v.is_a?(Hash) or raise "** assertion error"
|
22
|
-
data
|
33
|
+
data.delete(k)
|
34
|
+
if lang.is_a?(Array)
|
35
|
+
v = v[ lang.find{|l| v[l]} ]
|
36
|
+
else
|
37
|
+
v = v[lang]
|
38
|
+
end
|
39
|
+
data[k[0..-2]] = v
|
23
40
|
elsif v.is_a?(Hash) && v.key?(lang)
|
24
41
|
data[k] = v[lang]
|
25
42
|
else
|
@@ -39,6 +56,15 @@ end
|
|
39
56
|
class Test::Unit::TestCase # :nodoc:
|
40
57
|
|
41
58
|
|
59
|
+
def self.select_target_test(target_name=ENV['TEST'])
|
60
|
+
if target_name
|
61
|
+
self.instance_methods.each do |method|
|
62
|
+
private method if method =~ /^test_(.*)/ && $1 != target_name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
42
68
|
def self._untabify(str, width=8) # :nodoc:
|
43
69
|
list = str.split(/\t/, -1)
|
44
70
|
return list.first if list.length == 1
|
@@ -72,13 +98,11 @@ class Test::Unit::TestCase # :nodoc:
|
|
72
98
|
identkey = options[:identkey] || 'name'
|
73
99
|
list = []
|
74
100
|
table = {}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
else
|
81
|
-
raise "*** invalid ydoc: #{ydoc.inspect}"
|
101
|
+
load_yaml_documents_str(str) do |ydoc|
|
102
|
+
case ydoc
|
103
|
+
when Hash ; list << ydoc
|
104
|
+
when Array ; list += ydoc
|
105
|
+
else ; raise "*** invalid ydoc: #{ydoc.inspect}"
|
82
106
|
end
|
83
107
|
end
|
84
108
|
#
|
@@ -115,8 +139,12 @@ class Test::Unit::TestCase # :nodoc:
|
|
115
139
|
ydoc.each do |key, val|
|
116
140
|
if key[-1] == ?*
|
117
141
|
key = key[0, key.length-1]
|
118
|
-
k = special_keys.include?(key) ? 'ruby' : lang
|
119
|
-
|
142
|
+
#k = special_keys.include?(key) ? 'ruby' : lang
|
143
|
+
if lang.is_a?(Array)
|
144
|
+
val = val[ lang.find{|l| val[l]} ]
|
145
|
+
else
|
146
|
+
val = val[lang]
|
147
|
+
end
|
120
148
|
end
|
121
149
|
s << " @#{key} = #{val.inspect}\n"
|
122
150
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tenjin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- makoto kuwata
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-25 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- test/data/users_guide/user_edit.rbhtml
|
156
156
|
- test/data/users_guide/user_form.rbhtml
|
157
157
|
- test/data/users_guide/user_layout.rbhtml
|
158
|
+
- test/Rookbook.yaml
|
158
159
|
- test/test_all.rb
|
159
160
|
- test/test_engine.rb
|
160
161
|
- test/test_engine.yaml
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- examples/preprocessing/Makefile
|
186
187
|
- examples/preprocessing/Rakefile
|
187
188
|
- examples/preprocessing/select.rbhtml
|
189
|
+
- examples/preprocessing/select.rbhtml.cache
|
188
190
|
- examples/table
|
189
191
|
- examples/table/Makefile
|
190
192
|
- examples/table/Rakefile
|