rexle 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +8 -3
- metadata +2 -2
data/lib/rexle.rb
CHANGED
@@ -14,14 +14,14 @@ class Rexle
|
|
14
14
|
|
15
15
|
if fn_match.nil? then
|
16
16
|
procs = {
|
17
|
-
Array: proc {|x| x.compact
|
17
|
+
Array: proc {|x| r = x.flatten.compact; r.length == 1 ? r[0] : r},
|
18
18
|
String: proc {|x| x}
|
19
19
|
}
|
20
20
|
bucket = []
|
21
21
|
result = @doc.xpath(path, bucket)
|
22
22
|
|
23
23
|
procs[result.class.to_s.to_sym].call(result)
|
24
|
-
|
24
|
+
|
25
25
|
else
|
26
26
|
m, xpath_value = fn_match.captures
|
27
27
|
method(m.to_sym).call(xpath_value)
|
@@ -100,11 +100,13 @@ class Rexle
|
|
100
100
|
if return_elements.length > 0 then
|
101
101
|
if a.empty? then
|
102
102
|
rlist = return_elements.map.with_index {|x,i| filter(x, i+1, attr_search)}
|
103
|
+
rlist
|
103
104
|
else
|
104
105
|
return_elements.map.with_index do |x,i|
|
105
106
|
rtn_element = filter(x, i+1, attr_search){|e| r = e.xpath(a.join('/'), rlist); r || e }
|
106
107
|
|
107
108
|
rlist << rtn_element
|
109
|
+
rlist
|
108
110
|
end
|
109
111
|
end
|
110
112
|
else
|
@@ -114,6 +116,8 @@ class Rexle
|
|
114
116
|
self.xpath(new_xpath, rlist)
|
115
117
|
end
|
116
118
|
end
|
119
|
+
|
120
|
+
rlist
|
117
121
|
end
|
118
122
|
|
119
123
|
def scan_match(nodes, element, rlist)
|
@@ -121,6 +125,7 @@ class Rexle
|
|
121
125
|
rlist << x if x.name == element
|
122
126
|
x.xpath('//' + element, rlist) unless x.children.empty?
|
123
127
|
end
|
128
|
+
rlist
|
124
129
|
end
|
125
130
|
|
126
131
|
def attributes()
|
@@ -218,4 +223,4 @@ class Rexle
|
|
218
223
|
@doc.xpath(path).flatten.compact.length
|
219
224
|
end
|
220
225
|
|
221
|
-
end
|
226
|
+
end
|
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.2.
|
4
|
+
version: 0.2.8
|
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: 2010-10-
|
12
|
+
date: 2010-10-29 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|