rexle 0.8.8 → 0.8.9

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 +8 -4
  2. metadata +2 -12
@@ -79,6 +79,7 @@ class Rexle
79
79
  Array: proc {|x| x},
80
80
  :"REXML::Document" => proc {|x| scan_doc x.root}
81
81
  }
82
+
82
83
  a = procs[x.class.to_s.to_sym].call(x)
83
84
  @doc = scan_element(*a)
84
85
  end
@@ -479,13 +480,16 @@ class Rexle
479
480
  def root() @doc end
480
481
 
481
482
  def write(f)
482
- f.write "<?xml version='1.0' encoding='UTF-8'?>\n" + xml
483
+ f.write xml
483
484
  end
484
485
 
485
486
  def xml(options={})
486
- o = {pretty: false}.merge(options)
487
+ o = {pretty: false, declaration: true}.merge(options)
487
488
  msg = o[:pretty] == false ? :doc_print : :doc_pretty_print
488
- "<?xml version='1.0' encoding='UTF-8'?>\n" + method(msg).call(self.root.children)
489
+ r = ''
490
+ r = "<?xml version='1.0' encoding='UTF-8'?>\n" if o[:declaration] == true
491
+ r << method(msg).call(self.root.children)
492
+ r
489
493
  end
490
494
 
491
495
  private
@@ -524,7 +528,7 @@ class Rexle
524
528
 
525
529
  # scan a rexml doc
526
530
  #
527
- def scan_doc(node)a = rexle.xpath("records/url"){|e| %w(full_url short_url).map{|x| e.text(x)}}
531
+ def scan_doc(node)
528
532
  children = node.elements.map {|child| scan_doc child}
529
533
  attributes = node.attributes.inject({}){|r,x| r.merge(Hash[*x])}
530
534
  [node.name, node.text.to_s, attributes, *children]
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.8.8
4
+ version: 0.8.9
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: 2011-02-04 00:00:00 +00:00
12
+ date: 2011-02-06 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,16 +42,6 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: "0"
44
44
  version:
45
- - !ruby/object:Gem::Dependency
46
- name: pretty-xml
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: "0"
54
- version:
55
45
  description:
56
46
  email:
57
47
  executables: []