rexle-xpath 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb702835dcf62b001d9577586640e2097763f93f
4
- data.tar.gz: 2c9940716120f543309787e37c56460fc206cd63
3
+ metadata.gz: a6830597770b873aa7b054e23d48deac4df7f203
4
+ data.tar.gz: 0b4b8f7dd040ee4a6d875c75690e02b75f5fd647
5
5
  SHA512:
6
- metadata.gz: 3268a62a478743455c26782d3fcd2402deec696ac0c0a437b36793dfc5d4436d4a321b4a468af4f499dd09f0976d024bb7537bf52cfb88aa773d6e0ff32bd6dc
7
- data.tar.gz: 3fa51c81b7ecfbf13fdb285a4f142baa0949de5374dcb1c7869f8481ad1b1da53135034a2e784fb083bd59188bdda032bd66d5c812769846255a5165a637c83f
6
+ metadata.gz: 0b827b5c398cb520dc0cdd27810504f696a1dbc0ce87caec856a329323004847c06d4af8734f6cc637826fe3a36a3a1daf3a91517f731cb68ba230ac9973df48
7
+ data.tar.gz: 27c6d89519ee72af78975f69426e18edddcc682b97c36318296d040b4126fcf27b2790f066e7399c022e6f615269bcc338d2e1a0deaccb4561d7f1e6d0be1652
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/rexle-xpath.rb CHANGED
@@ -42,7 +42,6 @@ class RexleXPath
42
42
  else
43
43
 
44
44
  xpath_instructions = RexleXPathParser.new(s).to_a
45
- #puts 'xpath_instructions: ' + xpath_instructions.inspect
46
45
 
47
46
  query xpath_instructions, @node
48
47
  end
@@ -56,7 +55,11 @@ class RexleXPath
56
55
  row = xpath_instructions.shift
57
56
  method_name, *args = row
58
57
 
59
- return query row + xpath_instructions, node if row.first.is_a? Array
58
+ return query xpath_instructions, node if row == :|
59
+
60
+ if row.is_a? Array and row.first.is_a? Array then
61
+ return query row + xpath_instructions, node
62
+ end
60
63
 
61
64
  result = if method_name == :predicate then
62
65
 
@@ -70,7 +73,8 @@ class RexleXPath
70
73
 
71
74
  else
72
75
 
73
- method(method_name.to_sym).call node, args, xpath_instructions
76
+ r3 = method(method_name.to_sym).call node, args, xpath_instructions
77
+ r3
74
78
  end
75
79
 
76
80
  result.is_a?(Array) ? result.flatten : result
@@ -171,17 +175,18 @@ class RexleXPath
171
175
  return nodes_found[i]
172
176
 
173
177
  end
174
-
178
+
175
179
  if xpath_instructions.any? and nodes_found.any? then
176
180
 
177
181
  nodes_found.inject([]) do |r, child_node|
178
182
 
179
183
  # deep clone the xpath instructions
180
184
  xi = xpath_instructions.deep_clone
185
+ operand = xi.shift if xi.first == :|
181
186
 
182
187
  r2 = query(xi, child_node)
183
188
 
184
- case r2.class.to_s.to_sym
189
+ r3 = case r2.class.to_s.to_sym
185
190
  when :'Rexle::Element' then r << r2
186
191
  when :TrueClass
187
192
  predicate ? r << child_node : r << true
@@ -192,11 +197,27 @@ class RexleXPath
192
197
  when :NilClass
193
198
  r
194
199
  else
195
- r2.any? ? r << r2 : r
200
+ r2.any? ? r << r2 : r #<< child_node
196
201
  end # /case
197
202
 
203
+ if operand == :| then
204
+ nodes_found + r3
205
+ else
206
+ r3
207
+ end
208
+
198
209
  end # /inject
199
210
 
211
+ elsif xpath_instructions.any? and nodes_found.empty?
212
+
213
+ operator = xpath_instructions.shift
214
+
215
+ if operator == :| then
216
+ query xpath_instructions, node
217
+ else
218
+ nodes_found
219
+ end
220
+
200
221
  else
201
222
  nodes_found
202
223
  end # /if
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexle-xpath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  nbFbbz3OsHrrR6h7FB5a8wQzCvYMtAr9VMPNl01QqBRi2wCEr6hR3gGBY0T1ZT5P
32
32
  qYzPWuECaMhR5w==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-06-02 00:00:00.000000000 Z
34
+ date: 2016-07-09 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle-xpath-parser
metadata.gz.sig CHANGED
Binary file