rexle 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rexle.rb +28 -10
  2. metadata +1 -1
@@ -74,9 +74,16 @@ class Rexle
74
74
 
75
75
  s = a_path.shift
76
76
  end
77
-
77
+
78
78
  elmnt_path = s[/^([\w\*]+\[[^\]]+\])|[\/]+{,2}[^\/]+/]
79
- element_name, condition = elmnt_path.match(/(^[^\[]+)(\[[^\]]+\])?/).captures
79
+ element_part, condition = elmnt_path.match(/(^@?[^\[]+)(\[[^\]]+\])?/).captures
80
+
81
+ unless element_part[/^@/] then
82
+ element_name = element_part
83
+ else
84
+ condition = element_part
85
+ element_name = nil
86
+ end
80
87
 
81
88
  attr_search = format_attributes(condition) if condition
82
89
 
@@ -212,16 +219,27 @@ class Rexle
212
219
 
213
220
  def scan_match(nodes, element, attr_search, condition, rlist)
214
221
  nodes.children.each.with_index do |x, i|
215
- if x.name == element
216
- h = x.attributes
217
- if attr_search then
218
- rlist << x if h and eval(attr_search)
219
- else
220
- rlist << x
222
+
223
+ h = x.attributes
224
+
225
+ if element and not(element.empty?) then
226
+ if x.name == element
227
+ if attr_search then
228
+ rlist << x if h and eval(attr_search)
229
+ else
230
+ rlist << x
231
+ end
221
232
  end
222
- end
233
+ else
223
234
 
224
- x.xpath('//' + element + condition.to_s, rlist) unless x.children.empty?
235
+ attribute = condition[/@(.*)/,1]
236
+
237
+ if h.has_key? attribute then
238
+ rlist << h[attribute]
239
+ end
240
+ end
241
+
242
+ x.xpath('//' + element.to_s + condition.to_s, rlist) unless x.children.empty?
225
243
  end
226
244
  rlist
227
245
  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.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors: []
7
7