rexle 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +11 -6
- metadata +1 -1
data/lib/rexle.rb
CHANGED
@@ -127,24 +127,29 @@ class Rexle
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def format_attributes(condition)
|
130
|
-
raw_items = condition[1..-1].scan(
|
130
|
+
raw_items = condition[1..-1].scan(/\'[^\']+\'|and|\d+|[!=]+|[\w]+/)
|
131
131
|
|
132
132
|
if raw_items[0][/^\d+$/] then
|
133
133
|
return raw_items[0].to_i
|
134
134
|
else
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
and_items = raw_items.map.with_index.select{|x,i| x == 'and'}.map{|x| [x.last, x.last + 1]}.flatten
|
136
|
+
indices = [0] + and_items + [raw_items.length]
|
137
|
+
cons_items = indices.each_cons(2).map{|x,y| raw_items.slice(x...y)}
|
138
|
+
items = cons_items.map do |x|
|
139
|
+
if x.length >= 3 then
|
140
|
+
x[1] = '==' if x[1] == '='
|
141
|
+
"h['%s'] %s %s" % x
|
139
142
|
else
|
140
|
-
|
143
|
+
x
|
141
144
|
end
|
142
145
|
end
|
146
|
+
|
143
147
|
return items.join(' ')
|
144
148
|
end
|
145
149
|
end
|
146
150
|
|
147
151
|
|
152
|
+
|
148
153
|
def scan_match(nodes, element, attr_search, condition, rlist)
|
149
154
|
nodes.children.each.with_index do |x, i|
|
150
155
|
if x.name == element
|