rexle 0.5.12 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +21 -12
- metadata +1 -1
data/lib/rexle.rb
CHANGED
@@ -76,15 +76,18 @@ class Rexle
|
|
76
76
|
end
|
77
77
|
|
78
78
|
elmnt_path = s[/^([\w\*]+\[[^\]]+\])|[\/]+{,2}[^\/]+/]
|
79
|
-
element_part, condition = elmnt_path.match(/(^@?[^\[]+)(\[[^\]]+\])?/).captures
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
element_part, condition = elmnt_path.match(/(^@?[^\[]+)?(\[[^\]]+\])?/).captures
|
81
|
+
|
82
|
+
if element_part then
|
83
|
+
unless element_part[/^@/] then
|
84
|
+
element_name = element_part
|
85
|
+
else
|
86
|
+
condition = element_part
|
87
|
+
element_name = nil
|
88
|
+
end
|
86
89
|
end
|
87
|
-
|
90
|
+
|
88
91
|
attr_search = format_attributes(condition) if condition
|
89
92
|
|
90
93
|
if xpath_value[0,2] == '//'
|
@@ -166,6 +169,8 @@ class Rexle
|
|
166
169
|
s.empty? ? @value : self.xpath(s).first.value
|
167
170
|
end
|
168
171
|
|
172
|
+
alias text= value=
|
173
|
+
|
169
174
|
private
|
170
175
|
|
171
176
|
def scan_print(nodes)
|
@@ -226,6 +231,7 @@ class Rexle
|
|
226
231
|
end
|
227
232
|
|
228
233
|
def scan_match(nodes, element, attr_search, condition, rlist)
|
234
|
+
|
229
235
|
nodes.children.each.with_index do |x, i|
|
230
236
|
|
231
237
|
h = x.attributes
|
@@ -240,10 +246,13 @@ class Rexle
|
|
240
246
|
end
|
241
247
|
else
|
242
248
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
249
|
+
if condition[/^@/] then
|
250
|
+
attribute = condition[/@(.*)/,1]
|
251
|
+
if h.has_key? attribute then
|
252
|
+
rlist << h[attribute]
|
253
|
+
end
|
254
|
+
else
|
255
|
+
rlist << x if h and eval(attr_search)
|
247
256
|
end
|
248
257
|
end
|
249
258
|
|
@@ -362,4 +371,4 @@ class Rexle
|
|
362
371
|
[node.name, node.text.to_s, attributes, *children]
|
363
372
|
end
|
364
373
|
|
365
|
-
end
|
374
|
+
end
|