rexle-xpath-parser 0.1.12 → 0.1.13

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: b754ed1c9cd12d73362a3f1486e6ad1d228f2d16
4
- data.tar.gz: 4455f9652ebe23bae65dcf8515c577095033d2a8
3
+ metadata.gz: 1efc1cfcaabc220aee650537721c02d544daee81
4
+ data.tar.gz: c1678f213e2d75ac6de6e2cd02107905b147ef49
5
5
  SHA512:
6
- metadata.gz: 8f157bccb8348d5ee953bc8596ecf2db0024c152c2db78a5e1fee332b30993b1178b1578e70b9a705303af39e9afeab4ea9aa39ddae4d2fdb183141b4e302662
7
- data.tar.gz: 5ed1d4c69105cd72f257d4e470f1bb2895262afebe8f49b4fd55d565a1e8663bb8869cd4d0c83e6937a326ba3083cc5ab673ed12e27e3bccce64488e7eae12a2
6
+ metadata.gz: 0840ba3af56bffdb9aa0ad72ad26a51698ef1cd0f3a69b33653bcefe12d5ce95c3ea89813051d80daa7ab04b1081f3d8caa1bce194f7301586fea9d144420a55
7
+ data.tar.gz: 1393af65fd02efd0f1a65f541faf1d4c4fde078b234a51bf9c98592b738d85bd3d835b3adf08ebb275d7ad73f6213de378dbbc884280d7adc3ed978a9076cc45
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -22,21 +22,19 @@ class RexleXPathParser
22
22
  # maps the nested tokens to XPath functions, predicates, operators,
23
23
  # and 1 or more elements
24
24
  #
25
- def functionalise(a)
25
+ def functionalise(a, r2=[])
26
26
 
27
- a.inject([]) do |r,x|
28
-
29
- #puts 'x: ' + x.inspect
27
+ a.inject(r2) do |r,x|
30
28
 
31
29
  return r << functionalise(x) if x.is_a? Array
32
30
 
33
- if /^(?<func>\w+)\(\)/ then
31
+ if /^(?<func>\w+)\(\)/ =~ x then
34
32
  r << func.to_sym
35
33
  elsif /^@(?<attribute>[\w\/]+)/ =~ x
36
34
  r << [[:attribute, attribute]]
37
35
  elsif x =~ /^\/\//
38
36
  r << [:recursive, *RexleXPathParser.new(x[2..-1]).to_a]
39
- elsif x =~ /[\w\/]+\[/
37
+ elsif x =~ /^[\w\/]+\[/
40
38
 
41
39
  epath, predicate, remainder = x.match(/^([^\[]+)\[([^\]]+)\](.*)/).captures
42
40
 
@@ -60,8 +58,17 @@ class RexleXPathParser
60
58
  r << [:index, x]
61
59
  elsif /^attribute::(?<attribute>\w+)/ =~ x
62
60
  r << [:attribute, attribute]
63
- elsif x =~ /[\w\/]+/
64
- r << x.split('/').map {|e| [:select, e]}
61
+ elsif /^(?<name>\w+)\/?/ =~ x
62
+
63
+ x.slice!(/^\w+\/?/)
64
+ r3 = [[:select, name]]
65
+
66
+ if x.length > 0 then
67
+ functionalise([x], r3)
68
+
69
+ end
70
+ r << r3
71
+
65
72
  end
66
73
 
67
74
  end
@@ -123,6 +130,7 @@ class RexleXPathParser
123
130
 
124
131
  a = []
125
132
 
133
+ #puts 's: ' + s.inspect
126
134
  # e.g. position()
127
135
  if /^\w+\(\)$/ =~ s then
128
136
  a << s
@@ -145,8 +153,10 @@ class RexleXPathParser
145
153
  a.concat a2[1..-1]
146
154
 
147
155
  a2
148
-
156
+ elsif /^(?<name>\w+)\// =~ s
157
+ a << name << match($')
149
158
  else
159
+
150
160
  token = s.slice!(/^[@?\w\/:]+/)
151
161
  a << token
152
162
  remainder = s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexle-xpath-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  adFNS7+S3VVpQqBQ7hIMoNW5ldGHINll6Z0dbjsCO8OFGOkrnzt9ovLffOXuQHpT
32
32
  Gpk2If0KQMuV2Q==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-05-25 00:00:00.000000000 Z
34
+ date: 2016-05-26 00:00:00.000000000 Z
35
35
  dependencies: []
36
36
  description:
37
37
  email: james@r0bertson.co.uk
metadata.gz.sig CHANGED
Binary file