rexle-xpath-parser 0.1.3 → 0.1.4

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: e83436a145b867565019bd5bf8b2a2028fc7e59b
4
- data.tar.gz: e4b6fffcd15477d8576a7c4f6fd4cce940a7bf84
3
+ metadata.gz: ae7e450416eff042a5fd74f13acac2ccc8776e9f
4
+ data.tar.gz: 4370f0becd6d8b0a0bccdc3b238f296ba34e8242
5
5
  SHA512:
6
- metadata.gz: a6a435fdf7d5bdd5112bfa582dc297309b2abfe5fd76af224729542f13bf85a1a06cd3131a5b72204aec2601ec221174967791d19c04cfc5d0a2fd1537088995
7
- data.tar.gz: cbc71821bd6d7449369b1e997780a7c023551cad540851c264cd52078f695e3420409da494c958b43f2882043c4bd4d274b73a1934acaf2eb866b58340f83689
6
+ metadata.gz: 1d03728e8f4fc8956478bf2255bb1535834d1acb374fc936ced40ad703d4ebdec0287ee2e7c3321971e9369cafdbdf5d57887dbf98193ef516cb1972eda571e7
7
+ data.tar.gz: 6b6320900430ccf877871072f1f9bfd20e85f423f8d9ac22c95a231ec1968beea2025f248fd2e357d7bff75c112b1c07b0d53486c4252a83717bb45a5bb39a9f
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- � �=6���� ���8kt��=� q��S ��߃�C�WD���E�Ж8$O^ŕ��aD����4�Ol�����!�B��%�^��c�?Owy���F*��y����RN����T�|ޠ���A���Hz ��e4���eF��]�áX��� Q�Z믗d1z�3�#��-}���/�����&���o���u-s ��ve9���*Ÿ�@6C����"0��IM.��`|P*tǘ9���x@��S$
1
+ �T-���Z^�].=ni���O��^B��W`��Ǝ����IDX\;GU��3��{{�;8I���s2s���1�*KT��i0�;�F_K-�G���.Ob���=��I������SߘV���?gtW��Ů��3-Q�V]�]�\���2Y��&�h�֜�4��_�lQ��*�4��o �j�����88�U{9��X��L�����}>���˜?Gn9p/�WRkR ���I���n)�����ߧ
data.tar.gz.sig CHANGED
Binary file
@@ -8,7 +8,7 @@ class RexleXPathParser
8
8
  attr_reader :to_a
9
9
 
10
10
  def initialize(string)
11
-
11
+ #puts 'inside RExleXpathParser'
12
12
  tokens = tokenise string
13
13
  #puts 'tokens: ' + tokens.inspect
14
14
  nested_tokens = tokens.map {|x| scan(x)}
@@ -25,8 +25,8 @@ class RexleXPathParser
25
25
  def functionalise(a)
26
26
 
27
27
  a.map do |x|
28
-
29
- if x =~ /[\w\/]+\[/ then
28
+
29
+ r = if x =~ /[\w\/]+\[/ then
30
30
 
31
31
  epath, predicate, remainder = x.match(/^([^\[]+)\[([^\]]+)\](.*)/).captures
32
32
 
@@ -37,8 +37,11 @@ class RexleXPathParser
37
37
  []
38
38
  end
39
39
 
40
- epath.split('/').map {|e| [:select, e]} + [:predicate, predicate] + r
40
+ epath.split('/').map {|e| [:select, e]} << \
41
+ [:predicate, RexleXPathParser.new(predicate).to_a] + r
41
42
 
43
+ elsif x =~ /=/
44
+ [:text, :==, x[/=(.*)/,1].sub(/^["'](.*)["']$/,'\1')]
42
45
  elsif x =~ /\|/
43
46
  [:union]
44
47
  elsif x =~ /\w+\(/
@@ -50,6 +53,8 @@ class RexleXPathParser
50
53
  elsif x.is_a? Array
51
54
  functionalise(x)
52
55
  end
56
+
57
+ r
53
58
 
54
59
  end
55
60
 
@@ -110,6 +115,7 @@ class RexleXPathParser
110
115
 
111
116
  a = []
112
117
 
118
+ # e.g. position()
113
119
  if s =~ /^\w+\(/ then
114
120
 
115
121
  found, token, remainder = lmatch(s.chars, '(',')')
@@ -118,6 +124,7 @@ class RexleXPathParser
118
124
  a << token
119
125
  end
120
126
 
127
+ # e.g. b[c='45']
121
128
  elsif s =~ /^[\w\/]+\[/
122
129
 
123
130
  found, token, remainder = lmatch(s.chars, '[',']')
@@ -139,6 +146,8 @@ class RexleXPathParser
139
146
 
140
147
  if operator then
141
148
  a.concat [operator, *match(remainder)]
149
+ else
150
+ a << remainder if remainder.length > 0
142
151
  end
143
152
 
144
153
  a
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.3
4
+ version: 0.1.4
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: 2015-06-05 00:00:00.000000000 Z
34
+ date: 2016-05-07 00:00:00.000000000 Z
35
35
  dependencies: []
36
36
  description:
37
37
  email: james@r0bertson.co.uk
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 2.4.6
63
+ rubygems_version: 2.4.8
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: rexle-xpath-parser
metadata.gz.sig CHANGED
Binary file