amee 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/amee/exceptions.rb +1 -1
- data/lib/amee/parse_helper.rb +20 -15
- data/lib/amee/version.rb +1 -1
- metadata +4 -4
data/lib/amee/exceptions.rb
CHANGED
data/lib/amee/parse_helper.rb
CHANGED
@@ -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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
data/lib/amee/version.rb
CHANGED
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 2.5.
|
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-
|
18
|
+
date: 2010-11-08 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|