rexle 0.7.4 → 0.7.5
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/lib/rexle.rb +4 -3
- metadata +1 -1
data/lib/rexle.rb
CHANGED
@@ -6,6 +6,7 @@ require 'rexml/document'
|
|
6
6
|
require 'rexleparser'
|
7
7
|
require 'dynarex-parser'
|
8
8
|
require 'polyrex-parser'
|
9
|
+
require 'pretty-xml'
|
9
10
|
include REXML
|
10
11
|
|
11
12
|
class Rexle
|
@@ -382,7 +383,7 @@ class Rexle
|
|
382
383
|
def delete(xpath) @doc.element(xpath).delete end
|
383
384
|
def element(xpath) @doc.element(xpath) end
|
384
385
|
def elements(s=nil) @doc.elements(s) end
|
385
|
-
def to_s(
|
386
|
+
def to_s() self.xml end
|
386
387
|
def text(xpath) @doc.text(xpath) end
|
387
388
|
def root() @doc end
|
388
389
|
|
@@ -391,11 +392,11 @@ class Rexle
|
|
391
392
|
end
|
392
393
|
|
393
394
|
def xml(options={})
|
394
|
-
o
|
395
|
+
o.merge!{pretty: false}
|
395
396
|
body = scan_print(self.root.children).join
|
396
397
|
a = self.root.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
397
398
|
out = "<%s%s>%s</%s>" % [self.root.name, a.empty? ? '' : ' ' + a.join(' '), body, self.root.name]
|
398
|
-
o[:pretty] == false ? out :
|
399
|
+
o[:pretty] == false ? out : PrettyXML::write out
|
399
400
|
end
|
400
401
|
|
401
402
|
private
|