rexle 0.9.67 → 0.9.68

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.
Files changed (2) hide show
  1. data/lib/rexle.rb +37 -32
  2. 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
- if x.name.chr != '!' then
68
- a = x.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
69
- tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
70
-
71
- if x.value.length > 0 or (x.children.length > 0 and not x.children.is_an_empty_string?) then
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
- out = ["<%s/>" % tag]
78
- end
79
- elsif x.name == '!-' then
80
- "<!--%s-->" % x.value
81
- else
82
- "<![CDATA[%s]]>" % x.value
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
- unless x.name == '![' then
118
- #return ["<%s/>" % x.name] if x.value = ''
119
- a = x.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
120
- a ||= []
121
- tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
122
-
123
- start = i > 0 ? ("\n" + ' ' * (indent - 1)) : ''
124
- ind1 = x.children.grep(Rexle::Element).length > 0 ?
125
- ("\n" + ' ' * indent) : ''
126
- out = ["%s<%s>%s" % [start, tag, ind1]]
127
-
128
- out << pretty_print(x.children, (indent + 1).to_s.clone)
129
- ind2 = ind1.length > 0 ? ("\n" + ' ' * (indent - 1)) : ''
130
- out << "%s</%s>" % [ind2, x.name]
131
- else
132
- "<![CDATA[%s]]>" % x.value
133
- end
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.67
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-10 00:00:00 Z
13
+ date: 2012-11-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rexleparser