roxo 0.1.6 → 0.1.7

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 (3) hide show
  1. data/lib/roxo.rb +14 -4
  2. data/roxo.gemspec +1 -1
  3. metadata +3 -3
@@ -8,12 +8,15 @@ class ROXO
8
8
  include Comparable
9
9
 
10
10
  attr_reader :raw, :name, :value, :children
11
- def __attributes; @attributes.sort; end
12
11
  def attributes; @attributes.keys; end
13
12
  def has?(o); !! send(o); end # Boolean. Does this exist?
14
13
  def [](o); @attributes[o.to_s]; end # Only lookup attributes
15
14
  def to_s; @value; end
16
15
 
16
+ def __attributes
17
+ @attributes.sort.reject{|a|a.to_s =~ /^xmlns/}
18
+ end
19
+
17
20
  def initialize(xml)
18
21
  xml = ::LibXML::XML::Parser.string(xml).parse.root unless xml.kind_of?(LibXML::XML::Node)
19
22
 
@@ -31,13 +34,20 @@ class ROXO
31
34
  end # A node is terminal if we can't descend any further
32
35
 
33
36
  def <=>(other)
34
- [:class, :__attributes, :value, :name].each do |key|
35
- return z unless (z = self.send(key) <=> other.send(key)).zero?
36
- end
37
+ return z unless (z = self.class <=> other.class).zero?
38
+ return z unless (z = self.__attributes <=> other.__attributes).zero?
39
+ return z unless (z = self.value <=> other.value).zero?
40
+ return z unless (z = self.name <=> other.name).zero?
41
+
37
42
  nodes = lambda{|obj|obj.children.values.flatten.map{|n|self.class.new(n)}}
38
43
  nodes[self] <=> nodes[other]
39
44
  end
40
45
 
46
+ def ==(o)
47
+ self.<=>(o) == 0
48
+ end
49
+
50
+
41
51
  def method_missing(sym, *args)
42
52
  if terminal? # Proxy all method calls to the wrapped object.
43
53
  return @value.send(sym, *args)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'roxo'
3
- gem.version = '0.1.6'
3
+ gem.version = '0.1.7'
4
4
 
5
5
  gem.author, gem.email = 'Burke Libbey', "burke@burkelibbey.org"
6
6
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Burke Libbey
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-21 00:00:00 -05:00
17
+ date: 2010-04-22 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency