tagz 1.0.0 → 4.2.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.
data/sample/a.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'tagz'
2
- #
3
- # the simplest way to use tagz is to include the module and genrate something
4
- # tagged
5
- #
6
-
7
- include Tagz
8
-
9
- puts html_{ body_{ 'content' } }
data/test/tagz.rb DELETED
@@ -1,470 +0,0 @@
1
- require 'test/unit'
2
- STDOUT.sync = true
3
- $:.unshift 'lib'
4
- $:.unshift '../lib'
5
- $:.unshift '.'
6
- require 'tagz'
7
-
8
- class TagzTest < Test::Unit::TestCase
9
- include Tagz
10
-
11
- class ::String
12
- Equal = instance_method '=='
13
- remove_method '=='
14
- def == other
15
- Equal.bind(self.delete(' ')).call other.to_s.delete(' ')
16
- end
17
- end
18
-
19
- def test_000
20
- expected = '<foo ></foo>'
21
- actual = tagz{
22
- foo_
23
- _foo
24
- }
25
- assert_equal expected, actual
26
- end
27
-
28
- def test_010
29
- expected = '<foo ><bar ></bar></foo>'
30
- actual = tagz{
31
- foo_
32
- bar_
33
- _bar
34
- _foo
35
- }
36
- assert_equal expected, actual
37
- end
38
-
39
- def test_020
40
- expected = '<foo ><bar /></foo>'
41
- actual = tagz{
42
- foo_
43
- bar_{}
44
- _foo
45
- }
46
- assert_equal expected, actual
47
- end
48
-
49
- def test_030
50
- expected = '<foo ><bar /></foo>'
51
- actual = tagz{
52
- foo_{
53
- bar_{}
54
- }
55
- }
56
- assert_equal expected, actual
57
- end
58
-
59
- def test_040
60
- expected = '<foo >bar</foo>'
61
- actual = tagz{
62
- foo_{ 'bar' }
63
- }
64
- assert_equal expected, actual
65
- end
66
-
67
- def test_050
68
- expected = '<foo ><bar >foobar</bar></foo>'
69
- actual = tagz{
70
- foo_{
71
- bar_{ 'foobar' }
72
- }
73
- }
74
- assert_equal expected, actual
75
- end
76
-
77
- def test_060
78
- expected = '<foo key="value" ><bar a="b" >foobar</bar></foo>'
79
- actual = tagz{
80
- foo_('key' => 'value'){
81
- bar_(:a => :b){ 'foobar' }
82
- }
83
- }
84
- assert_equal expected, actual
85
- end
86
-
87
- def test_070
88
- expected = '<foo /><bar />'
89
- actual = tagz{
90
- foo_{} + bar_{}
91
- }
92
- assert_equal expected, actual
93
- end
94
-
95
- =begin
96
- def test_080
97
- assert_raises(Tagz::NotOpen) do
98
- foo_{ _bar }
99
- end
100
- end
101
- def test_090
102
- assert_raises(Tagz::NotOpen) do
103
- _foo
104
- end
105
- end
106
- def test_100
107
- assert_nothing_raised do
108
- foo_
109
- _foo
110
- end
111
- end
112
- =end
113
-
114
- def test_110
115
- expected = '<foo ><bar >foobar</bar></foo>'
116
- actual = tagz{
117
- foo_{
118
- bar_{ 'foobar' }
119
- 'this content is ignored because the block added content'
120
- }
121
- }
122
- assert_equal expected, actual
123
- end
124
-
125
- def test_120
126
- expected = '<foo ><bar >foobar</bar><baz >barfoo</baz></foo>'
127
- actual = tagz{
128
- foo_{
129
- bar_{ 'foobar' }
130
- baz_{ 'barfoo' }
131
- }
132
- }
133
- assert_equal expected, actual
134
- end
135
-
136
- def test_121
137
- expected = '<foo ><bar >foobar</bar><baz >barfoo</baz></foo>'
138
- actual = tagz{
139
- foo_{
140
- bar_{ 'foobar' }
141
- baz_{ 'barfoo' }
142
- }
143
- }
144
- assert_equal expected, actual
145
- end
146
-
147
- def test_130
148
- expected = '<foo >a<bar >foobar</bar>b<baz >barfoo</baz></foo>'
149
- actual = tagz{
150
- foo_{ |t|
151
- t << 'a'
152
- bar_{ 'foobar' }
153
- t << 'b'
154
- baz_{ 'barfoo' }
155
- }
156
- }
157
- assert_equal expected, actual
158
- end
159
-
160
- def test_140
161
- expected = '<foo ><bar >baz</bar></foo>'
162
- actual = tagz{
163
- foo_{
164
- bar_ << 'baz'
165
- _bar
166
- }
167
- }
168
- assert_equal expected, actual
169
- end
170
-
171
- def test_150
172
- expected = '<foo ><bar >bar<baz >baz</baz></bar></foo>'
173
- actual = tagz{
174
- foo_{
175
- bar_ << 'bar'
176
- tag = baz_
177
- tag << 'baz'
178
- _baz
179
- _bar
180
- }
181
- }
182
- assert_equal expected, actual
183
- end
184
-
185
- def test_160
186
- expected = '<foo >a<bar >b</bar></foo>'
187
- actual = tagz{
188
- foo_{ |foo|
189
- foo << 'a'
190
- bar_{ |bar|
191
- bar << 'b'
192
- }
193
- }
194
- }
195
- assert_equal expected, actual
196
- end
197
-
198
- def test_170
199
- expected = '<html ><body ><ul ><li >a</li><li >b</li><li >c</li></ul></body></html>'
200
- @list = %w( a b c )
201
- actual = tagz{
202
- html_{
203
- body_{
204
- ul_{
205
- @list.each{|elem| li_{ elem } }
206
- }
207
- }
208
- }
209
- }
210
- assert_equal expected, actual
211
- end
212
-
213
- def test_180
214
- expected = '<html ><body >42</body></html>'
215
- actual = tagz{
216
- html_{
217
- b = body_
218
- b << 42
219
- _body
220
- }
221
- }
222
- assert_equal expected, actual
223
- end
224
-
225
- def test_190
226
- expected = '<html ><body >42</body></html>'
227
- actual = tagz{
228
- html_{
229
- body_
230
- tagz << 42 ### tagz is always the current tag!
231
- _body
232
- }
233
- }
234
- assert_equal expected, actual
235
- end
236
-
237
- def test_200
238
- expected = '<html ><body >42</body></html>'
239
- actual = tagz{
240
- html_{
241
- body_{
242
- tagz << 42 ### tagz is always the current tag!
243
- }
244
- }
245
- }
246
- assert_equal expected, actual
247
- end
248
-
249
- def test_210
250
- expected = '<html ><body >42</body></html>'
251
- actual = tagz{
252
- html_{
253
- body_{ |body|
254
- body << 42
255
- }
256
- }
257
- }
258
- assert_equal expected, actual
259
- end
260
-
261
- =begin
262
- def test_220
263
- expected = '<html ><body >42</body></html>'
264
- actual = tagz{
265
- 'html'.tag do
266
- 'body'.tag do
267
- 42
268
- end
269
- end
270
- }
271
- assert_equal expected, actual
272
- end
273
- =end
274
-
275
- def test_230
276
- expected = '<html ><body ><div k="v" >content</div></body></html>'
277
- actual = tagz{
278
- html_{
279
- body_{
280
- div_(:k => :v){ "content" }
281
- }
282
- }
283
- }
284
- assert_equal expected, actual
285
- end
286
-
287
- def test_240
288
- expected = '<html ><body ><div k="v" >content</div></body></html>'
289
- actual = tagz{
290
- html_{
291
- body_{
292
- div_ "content", :k => :v
293
- }
294
- }
295
- }
296
- assert_equal expected, actual
297
- end
298
-
299
- def test_241
300
- expected = '<html ><body ><div k="v" >content</div></div></body></html>'
301
- actual = tagz{
302
- html_{
303
- body_{
304
- div_ "content", :k => :v
305
- _div
306
- }
307
- }
308
- }
309
- assert_equal expected, actual
310
- end
311
-
312
- def test_250
313
- expected = '<html ><body ><div k="v" >content and more content</div></body></html>'
314
- actual = tagz{
315
- html_{
316
- body_{
317
- div_("content", :k => :v){ ' and more content' }
318
- }
319
- }
320
- }
321
- assert_equal expected, actual
322
- end
323
-
324
- def test_260
325
- expected = '<html ><body ><div k="v" >content</div></body></html>'
326
- actual = tagz{
327
- html_{
328
- body_{
329
- div_ :k => :v
330
- tagz << "content"
331
- _div
332
- }
333
- }
334
- }
335
- assert_equal expected, actual
336
- end
337
-
338
- def test_270
339
- expected = '<html ><body ><div k="v" >content</div></body></html>'
340
- actual = tagz{
341
- html_{
342
- body_{
343
- div_ :k => :v
344
- tagz << "content"
345
- _div
346
- }
347
- }
348
- }
349
- assert_equal expected, actual
350
- end
351
-
352
- def test_280
353
- expected = 'content'
354
- actual = tagz{
355
- tagz << "content"
356
- }
357
- assert_equal expected, actual
358
- end
359
-
360
- def test_290
361
- expected = 'foobar'
362
- actual = tagz{
363
- tagz {
364
- tagz << 'foo' << 'bar'
365
- }
366
- }
367
- assert_equal expected, actual
368
- end
369
-
370
- =begin
371
- def test_300
372
- expected = 'foobar'
373
- actual = tagz{
374
- tagz{ tagz 'foo', 'bar' }
375
- }
376
- assert_equal expected, actual
377
- end
378
- =end
379
-
380
- def test_310
381
- expected = '<html ><body ><div k="v" >foobar</div></body></html>'
382
- actual = tagz{
383
- html_{
384
- body_{
385
- div_! "foo", "bar", :k => :v
386
- }
387
- }
388
- }
389
- assert_equal expected, actual
390
- end
391
-
392
- def test_320
393
- expected = '<html ><body ><a href="a" >a</a><span >|</span><a href="b" >b</a><span >|</span><a href="c" >c</a></body></html>'
394
- links = %w( a b c )
395
- actual = tagz{
396
- html_{
397
- body_{
398
- links.map{|link| e(:a, :href => link){ link }}.join e(:span){ '|' }
399
- }
400
- }
401
- }
402
- assert_equal expected, actual
403
- end
404
-
405
- def test_330
406
- expected = '<a ><b ><c >'
407
- actual = tagz{
408
- tagz {
409
- a_
410
- b_
411
- c_
412
- }
413
- }
414
- assert_equal expected, actual
415
- end
416
-
417
- def test_340
418
- expected = '<a ><b ><c ></a>'
419
- actual = tagz{
420
- a_ {
421
- b_
422
- c_
423
- }
424
- }
425
- assert_equal expected, actual
426
- end
427
-
428
- def test_350
429
- expected = '<a ><b ><c >content</c></a>'
430
- actual = tagz{
431
- a_ {
432
- b_
433
- c_ "content"
434
- }
435
- }
436
- assert_equal expected, actual
437
- end
438
-
439
- def test_360
440
- expected = '<a ><b >content</b><c ><d >more content</d></a>'
441
- actual = tagz{
442
- a_ {
443
- b_ "content"
444
- c_
445
- d_ "more content"
446
- }
447
- }
448
- assert_equal expected, actual
449
- end
450
-
451
- =begin
452
- def test_370
453
- expected = 'ab'
454
- actual = tagz{
455
- re = 'a'
456
- re << tagz{'b'}
457
- re
458
- }
459
- assert_equal expected, actual
460
- end
461
- =end
462
-
463
- def test_380
464
- expected = 'ab'
465
- actual = tagz{
466
- tagz{ 'a' } + tagz{ 'b' }
467
- }
468
- assert_equal expected, actual
469
- end
470
- end