rexle 0.5.16 → 0.5.17
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +8 -3
- metadata +2 -2
data/lib/rexle.rb
CHANGED
@@ -145,6 +145,7 @@ class Rexle
|
|
145
145
|
@child_elements << item
|
146
146
|
# add a reference from this element (the parent) to the child
|
147
147
|
item.parent = self
|
148
|
+
item
|
148
149
|
end
|
149
150
|
|
150
151
|
alias add add_element
|
@@ -305,6 +306,10 @@ class Rexle
|
|
305
306
|
self
|
306
307
|
end
|
307
308
|
|
309
|
+
def add_element(element) @doc.root.add_element(element) end
|
310
|
+
|
311
|
+
alias add add_element
|
312
|
+
|
308
313
|
def delete(xpath) @doc.element(xpath).delete end
|
309
314
|
def element(xpath) @doc.element(xpath) end
|
310
315
|
def text(xpath) @doc.text(xpath) end
|
@@ -313,7 +318,7 @@ class Rexle
|
|
313
318
|
def xml()
|
314
319
|
body = scan_print(self.root.children).join
|
315
320
|
a = self.root.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
316
|
-
"<%s%s>%s</%s>" % [self.root.name, a.empty? ? '' : a, body, self.root.name]
|
321
|
+
"<%s%s>%s</%s>" % [self.root.name, a.empty? ? '' : ' ' + a.join(' '), body, self.root.name]
|
317
322
|
end
|
318
323
|
|
319
324
|
private
|
@@ -354,7 +359,7 @@ class Rexle
|
|
354
359
|
tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
|
355
360
|
|
356
361
|
out = ["<%s>" % tag]
|
357
|
-
out << x.value unless x.value.empty?
|
362
|
+
out << x.value unless x.value.nil? || x.value.empty?
|
358
363
|
out << scan_print(x.children)
|
359
364
|
out << "</%s>" % x.name
|
360
365
|
end
|
@@ -372,4 +377,4 @@ class Rexle
|
|
372
377
|
[node.name, node.text.to_s, attributes, *children]
|
373
378
|
end
|
374
379
|
|
375
|
-
end
|
380
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.17
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-12-01 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|