rexle 0.3.7 → 0.3.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 +11 -6
  2. 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(/[\w]+=\'[^\']+\'|and|\d+/)
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
- items = raw_items.map do |x|
136
- name, value = x.split(/=/)
137
- if value then
138
- "h['%s'] == '%s'" % [name,value[1..-2]]
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
- name
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
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.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors: []
7
7