rexle 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rexle.rb +15 -3
- metadata +2 -2
data/lib/rexle.rb
CHANGED
@@ -71,7 +71,8 @@ class Rexle
|
|
71
71
|
s = a.shift
|
72
72
|
end
|
73
73
|
|
74
|
-
|
74
|
+
elmnt_path = s[/^(\w+\[[^\]]+\])|[\/]+{,2}[^\/]+/]
|
75
|
+
element_name, condition = elmnt_path.match(/(^[^\[]+)(\[[^\]]+\])?/).captures
|
75
76
|
|
76
77
|
attr_search = format_attributes(condition) if condition
|
77
78
|
|
@@ -110,6 +111,7 @@ class Rexle
|
|
110
111
|
end
|
111
112
|
end
|
112
113
|
|
114
|
+
#a.shift # added by jr 171110
|
113
115
|
rlist
|
114
116
|
end
|
115
117
|
|
@@ -139,7 +141,7 @@ class Rexle
|
|
139
141
|
end
|
140
142
|
|
141
143
|
def format_attributes(condition)
|
142
|
-
raw_items = condition[1..-1].scan(/\'[^\']*\'|and|\d+|[!=]+|[@\w]+/)
|
144
|
+
raw_items = condition[1..-1].scan(/\'[^\']*\'|and|\d+|[!=]+|[@\w\.]+/)
|
143
145
|
|
144
146
|
if raw_items[0][/^\d+$/] then
|
145
147
|
return raw_items[0].to_i
|
@@ -165,9 +167,14 @@ class Rexle
|
|
165
167
|
|
166
168
|
cons_items = indices.each_cons(2).map{|x,y| raw_items.slice(x...y)}
|
167
169
|
items = cons_items.map do |x|
|
170
|
+
|
168
171
|
if x.length >= 3 then
|
169
172
|
x[1] = '==' if x[1] == '='
|
170
|
-
|
173
|
+
if x[0] != '.' then
|
174
|
+
"name == '%s' and value %s %s" % [x[0], x[1], x[2]]
|
175
|
+
else
|
176
|
+
"e.value %s %s" % [x[1], x[2]]
|
177
|
+
end
|
171
178
|
else
|
172
179
|
x
|
173
180
|
end
|
@@ -178,6 +185,8 @@ class Rexle
|
|
178
185
|
end
|
179
186
|
end
|
180
187
|
|
188
|
+
|
189
|
+
|
181
190
|
def scan_match(nodes, element, attr_search, condition, rlist)
|
182
191
|
nodes.children.each.with_index do |x, i|
|
183
192
|
if x.name == element
|
@@ -200,6 +209,7 @@ class Rexle
|
|
200
209
|
e = @child_elements[x.last]
|
201
210
|
h = x[0][1] # <-- fetch the attributes
|
202
211
|
|
212
|
+
|
203
213
|
if attr_search then
|
204
214
|
if attr_search.is_a? Fixnum then
|
205
215
|
block_given? ? blk.call(e) : e if i == attr_search
|
@@ -208,6 +218,8 @@ class Rexle
|
|
208
218
|
elsif attr_search[/^name ==/] and \
|
209
219
|
e.child_lookup.select{|name, attributes, value| eval(attr_search) }.length > 0
|
210
220
|
block_given? ? blk.call(e) : e
|
221
|
+
elsif attr_search[/^e\.value/] and eval(attr_search)
|
222
|
+
block_given? ? blk.call(e) : e
|
211
223
|
end
|
212
224
|
else
|
213
225
|
block_given? ? blk.call(e) : e
|
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.4.
|
4
|
+
version: 0.4.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-11-
|
12
|
+
date: 2010-11-17 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|