tagz 0.0.1 → 0.0.2
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/a.rb +3 -2
- data/lib/tagz.rb +47 -1
- data/test/tagz.rb +3 -3
- metadata +2 -2
data/a.rb
CHANGED
data/lib/tagz.rb
CHANGED
@@ -5,6 +5,49 @@ module Tagz
|
|
5
5
|
class NotOpen < StandardError; end
|
6
6
|
class StillOpen < StandardError; end
|
7
7
|
|
8
|
+
class << self
|
9
|
+
#--{{{
|
10
|
+
def default_non_container_tag_list
|
11
|
+
%w[
|
12
|
+
br hr input img area base basefont
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def non_container_tag_list *argv
|
17
|
+
#--{{{
|
18
|
+
if argv.first
|
19
|
+
@non_container_tag_list = [argv.first].flatten.uniq.map{|arg| arg.to_s}
|
20
|
+
@non_container_tags = @non_container_tag_list.inject(Hash.new){|h,k| h.update k => true}
|
21
|
+
@non_container_tag_list
|
22
|
+
else
|
23
|
+
if defined?(@non_container_tag_list) and @non_container_tag_list
|
24
|
+
@non_container_tag_list
|
25
|
+
else
|
26
|
+
non_container_tag_list default_non_container_tag_list
|
27
|
+
@non_container_tag_list
|
28
|
+
end
|
29
|
+
end
|
30
|
+
#--}}}
|
31
|
+
end
|
32
|
+
def non_container_tags
|
33
|
+
#--{{{
|
34
|
+
if defined?(@non_container_tags) and @non_container_tags
|
35
|
+
@non_container_tags
|
36
|
+
else
|
37
|
+
non_container_tag_list
|
38
|
+
@non_container_tags
|
39
|
+
end
|
40
|
+
#--}}}
|
41
|
+
end
|
42
|
+
def container? tag
|
43
|
+
not(non_container_tags[tag.to_s] or false)
|
44
|
+
end
|
45
|
+
def emtpy? tag
|
46
|
+
not container?(tag)
|
47
|
+
end
|
48
|
+
#--}}}
|
49
|
+
end
|
50
|
+
|
8
51
|
module Fragment #--{{{
|
9
52
|
attr_accessor 'tag'
|
10
53
|
attr_accessor 'open'
|
@@ -62,6 +105,7 @@ module Tagz
|
|
62
105
|
end #--}}}
|
63
106
|
end #--}}}
|
64
107
|
|
108
|
+
|
65
109
|
module Abilities #--{{{
|
66
110
|
def __tag_stack__ #--{{{
|
67
111
|
@__tag_stack__ ||= []
|
@@ -171,7 +215,7 @@ module Tagz
|
|
171
215
|
end
|
172
216
|
=end
|
173
217
|
|
174
|
-
if content
|
218
|
+
if content or Tagz.container?(tag)
|
175
219
|
top[pos] = ' >'
|
176
220
|
top.add content unless content_was_added
|
177
221
|
stop = Fragment( "</#{ tag }>", tag, :open => false )
|
@@ -312,6 +356,8 @@ module Tagz
|
|
312
356
|
end
|
313
357
|
end #--}}}
|
314
358
|
|
359
|
+
|
360
|
+
### OLD CRAP
|
315
361
|
=begin
|
316
362
|
def concat s #--{{{
|
317
363
|
tagz << s.to_s
|
data/test/tagz.rb
CHANGED
@@ -26,7 +26,7 @@ class TagzTest < Test::Unit::TestCase
|
|
26
26
|
assert_equal expected, actual
|
27
27
|
end #--}}}
|
28
28
|
def test_020 #--{{{
|
29
|
-
expected = '<foo ><bar
|
29
|
+
expected = '<foo ><bar ></bar></foo>'
|
30
30
|
actual = (
|
31
31
|
foo_
|
32
32
|
bar_{}
|
@@ -35,7 +35,7 @@ class TagzTest < Test::Unit::TestCase
|
|
35
35
|
assert_equal expected, actual
|
36
36
|
end #--}}}
|
37
37
|
def test_030 #--{{{
|
38
|
-
expected = '<foo ><bar
|
38
|
+
expected = '<foo ><bar ></bar></foo>'
|
39
39
|
actual = (
|
40
40
|
foo_{
|
41
41
|
bar_{}
|
@@ -69,7 +69,7 @@ class TagzTest < Test::Unit::TestCase
|
|
69
69
|
assert_equal expected, actual
|
70
70
|
end #--}}}
|
71
71
|
def test_070 #--{{{
|
72
|
-
expected = '<foo
|
72
|
+
expected = '<foo ></foo><bar ></bar>'
|
73
73
|
actual = (
|
74
74
|
foo_{} + bar_{}
|
75
75
|
)
|
metadata
CHANGED