xml-purifier 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/xml-purifier.rb +8 -12
- metadata +1 -1
data/lib/xml-purifier.rb
CHANGED
@@ -20,33 +20,29 @@ class XMLPurifier
|
|
20
20
|
if elem.text and elem.text.to_s[/^[\{\[][^\}\]]+[\}\]]$/] then
|
21
21
|
|
22
22
|
obj = JSON.parse(elem.text)
|
23
|
-
method('to_' + opt[:to].to_s.to_sym).call(elem, obj)
|
23
|
+
method('to_' + opt[:to].to_s.to_sym).call(elem, scan_obj_to_xml(obj))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
-
def to_xml()
|
30
|
-
@doc.to_s
|
31
|
-
end
|
29
|
+
def to_xml() @doc.to_s end
|
32
30
|
|
33
31
|
private
|
34
32
|
|
35
|
-
def to_default(elem,
|
36
|
-
node_xml = "<%s>%s</%s>" % [elem.name,
|
33
|
+
def to_default(elem, xml)
|
34
|
+
node_xml = "<%s>%s</%s>" % [elem.name, xml, elem.name]
|
37
35
|
elem.parent.add_element Document.new(node_xml).root
|
38
36
|
elem.parent.delete elem
|
39
37
|
end
|
40
38
|
|
41
39
|
alias to_native to_default
|
42
40
|
|
43
|
-
def to_cdata(elem,
|
44
|
-
elem.text = CData.new(scan_obj_to_xml(obj))
|
45
|
-
end
|
41
|
+
def to_cdata(elem, xml) elem.text = CData.new(xml) end
|
46
42
|
|
47
|
-
def to_escaped(elem,
|
43
|
+
def to_escaped(elem, xml) elem.text = xml end
|
48
44
|
|
49
|
-
def string_to_xml(x) x
|
45
|
+
def string_to_xml(x) x end
|
50
46
|
|
51
47
|
def hash_to_xml(x)
|
52
48
|
x.map do |k,v|
|
@@ -63,4 +59,4 @@ class XMLPurifier
|
|
63
59
|
method("%s_to_xml" % o.class.to_s.downcase.to_sym).call(o)
|
64
60
|
end
|
65
61
|
|
66
|
-
end
|
62
|
+
end
|