amee 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ module AMEE
11
11
  end
12
12
  def to_s
13
13
  if @last_err
14
- [@msg, @last_err.message, @last_err.backtrace.first].join "\n"
14
+ ([@msg, @last_err.message]+@last_err.backtrace).join "\n"
15
15
  else
16
16
  super
17
17
  end
@@ -7,24 +7,29 @@ module ParseHelper
7
7
  else
8
8
  nodes=REXML::XPath.match(doc,"#{preamble}#{xpath}")
9
9
  end
10
+ if nodes.is_a? String
11
+ return nodes
12
+ end
10
13
  if nodes.length==1
11
- if nodes.first.respond_to?(:text)
12
- return nodes.first.text
13
- elsif nodes.first.respond_to?(:to_s)
14
- return nodes.first.to_s
15
- end
14
+ return node_value(nodes.first)
15
+ elsif nodes.length>1
16
+ return nodes.map{|x| node_value(x)}
17
+ else
18
+ return nil
16
19
  end
17
-
18
- if nodes.length>1
19
- if nodes.first.respond_to?(:text)
20
- return nodes.map{|x| x.text}
21
- elsif nodes.first.respond_to?(:to_s)
22
- return nodes.map{|x| x.to_s}
23
- end
20
+ end
21
+
22
+ def node_value(node)
23
+ if node.is_a?(Nokogiri::XML::Attr) || node.is_a?(REXML::Attribute)
24
+ # Attributes are allowed to be an empty string
25
+ return node.to_s
26
+ elsif node.is_a?(Nokogiri::XML::Element) || node.is_a?(REXML::Element)
27
+ return node.text == '' ? nil : node.text
28
+ else
29
+ return node.to_s
24
30
  end
25
- return nil
26
-
27
31
  end
32
+
28
33
  def xmlpathpreamble
29
34
  ''
30
35
  end
@@ -35,4 +40,4 @@ module ParseHelper
35
40
  end
36
41
  private :x
37
42
 
38
- end
43
+ end
@@ -3,7 +3,7 @@ module AMEE
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 2
5
5
  MINOR = 5
6
- TINY = 0
6
+ TINY = 1
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amee
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- - 0
10
- version: 2.5.0
9
+ - 1
10
+ version: 2.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-03 00:00:00 +00:00
18
+ date: 2010-11-08 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency