rexle 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +8 -2
- metadata +2 -2
data/lib/rexle.rb
CHANGED
@@ -83,6 +83,7 @@ class Rexle
|
|
83
83
|
s = a_path.shift
|
84
84
|
end
|
85
85
|
|
86
|
+
# isolate the xpath to return just the path to the current element
|
86
87
|
elmnt_path = s[/^([\w\*]+\[[^\]]+\])|[\/]+{,2}[^\/]+/]
|
87
88
|
element_part = elmnt_path[/(^@?[^\[]+)?/,1] if elmnt_path
|
88
89
|
|
@@ -240,10 +241,13 @@ class Rexle
|
|
240
241
|
end
|
241
242
|
|
242
243
|
def format_condition(condition)
|
243
|
-
raw_items = condition[1..-1].scan(/\'[^\']*\'|and|or|\d+|[!=]+|[@\w\.\/]+/)
|
244
|
+
#raw_items = condition[1..-1].scan(/\'[^\']*\'|and|or|\d+|[!=]+|[@\w\.\/]+/)
|
245
|
+
raw_items = condition[1..-1].scan(/\'[^\']*\'|and|or|\d+|[!=<>]+|position\(\)|[@\w\.\/]+/)
|
244
246
|
|
245
247
|
if raw_items[0][/^\d+$/] then
|
246
248
|
return raw_items[0].to_i
|
249
|
+
elsif raw_items[0] == 'position()' then
|
250
|
+
return "i %s %s" % raw_items[1..-1]
|
247
251
|
else
|
248
252
|
|
249
253
|
andor_items = raw_items.map.with_index.select{|x,i| x[/\band\b|\bor\b/]}.map{|x| [x.last, x.last + 1]}.flatten
|
@@ -333,6 +337,8 @@ class Rexle
|
|
333
337
|
if attr_search then
|
334
338
|
if attr_search.is_a? Fixnum then
|
335
339
|
block_given? ? blk.call(e) : e if i == attr_search
|
340
|
+
elsif attr_search[/i\s[<>\=]\s\d+/] and eval(attr_search) then
|
341
|
+
block_given? ? blk.call(e) : e
|
336
342
|
elsif h and attr_search[/^h\[/] and eval(attr_search)
|
337
343
|
block_given? ? blk.call(e) : e
|
338
344
|
elsif attr_search[/^name ==/] and \
|
@@ -486,7 +492,7 @@ class Rexle
|
|
486
492
|
out = ["%s<%s>%s" % [start, tag, ind1]]
|
487
493
|
|
488
494
|
out << x.value.sub(/^[\n\s]+$/,'') unless x.value.nil? || x.value.empty?
|
489
|
-
out << pretty_print(x.children, (indent +
|
495
|
+
out << pretty_print(x.children, (indent + 1).to_s.clone)
|
490
496
|
ind2 = x.children.length > 0 ? ("\n" + ' ' * (indent - 1)) : ''
|
491
497
|
out << "%s</%s>" % [ind2, x.name]
|
492
498
|
else
|
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.8.
|
4
|
+
version: 0.8.4
|
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: 2011-01-
|
12
|
+
date: 2011-01-21 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|