rexle 0.9.67 → 0.9.68
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +37 -32
- metadata +2 -2
data/lib/rexle.rb
CHANGED
@@ -64,22 +64,24 @@ module XMLhelper
|
|
64
64
|
nodes.map do |x|
|
65
65
|
|
66
66
|
if x.is_a? Rexle::Element then
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
out = ["<%s>" % tag]
|
73
|
-
#out << x.value unless x.value.nil? || x.value.empty?
|
74
|
-
out << scan_print(x.children)
|
75
|
-
out << "</%s>" % x.name
|
67
|
+
case x.name
|
68
|
+
when '!-'
|
69
|
+
"<!--%s-->" % x.value
|
70
|
+
when '!['
|
71
|
+
"<![CDATA[%s]]>" % x.value
|
76
72
|
else
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
73
|
+
|
74
|
+
a = x.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
75
|
+
tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
|
76
|
+
|
77
|
+
if x.value.length > 0 or (x.children.length > 0 and not x.children.is_an_empty_string?) then
|
78
|
+
out = ["<%s>" % tag]
|
79
|
+
#out << x.value unless x.value.nil? || x.value.empty?
|
80
|
+
out << scan_print(x.children)
|
81
|
+
out << "</%s>" % x.name
|
82
|
+
else
|
83
|
+
out = ["<%s/>" % tag]
|
84
|
+
end
|
83
85
|
end
|
84
86
|
elsif x.is_a? String then
|
85
87
|
x
|
@@ -114,23 +116,26 @@ module XMLhelper
|
|
114
116
|
.map.with_index do |x, i|
|
115
117
|
|
116
118
|
if x.is_a? Rexle::Element then
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
119
|
+
case x.name
|
120
|
+
when '!-'
|
121
|
+
"<!--%s-->" % x.value
|
122
|
+
when '!['
|
123
|
+
"<![CDATA[%s]]>" % x.value
|
124
|
+
else
|
125
|
+
#return ["<%s/>" % x.name] if x.value = ''
|
126
|
+
a = x.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
127
|
+
a ||= []
|
128
|
+
tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
|
129
|
+
|
130
|
+
start = i > 0 ? ("\n" + ' ' * (indent - 1)) : ''
|
131
|
+
ind1 = x.children.grep(Rexle::Element).length > 0 ?
|
132
|
+
("\n" + ' ' * indent) : ''
|
133
|
+
out = ["%s<%s>%s" % [start, tag, ind1]]
|
134
|
+
|
135
|
+
out << pretty_print(x.children, (indent + 1).to_s.clone)
|
136
|
+
ind2 = ind1.length > 0 ? ("\n" + ' ' * (indent - 1)) : ''
|
137
|
+
out << "%s</%s>" % [ind2, x.name]
|
138
|
+
end
|
134
139
|
elsif x.is_a? String then
|
135
140
|
x.sub(/^[\n\s]+$/,'')
|
136
141
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rexle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.68
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Robertson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-30 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rexleparser
|