rexle-xpath 0.2.15 → 0.2.16

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: ba20f6447871f17c33de45038b860e1f504ea1c2
4
- data.tar.gz: ad9f3424c0e4ce948b8e79e2dbda30ad382428a2
3
+ metadata.gz: 602043c3e561402f8ca1ccba80381ddf76a8aeb4
4
+ data.tar.gz: af520c3562d76c5113f5a3773bde1f6f26abf5be
5
5
  SHA512:
6
- metadata.gz: 4f31b4597152e487e85be19f9c80d2c60d0c6b7dff3cc20feeddc39302d31b101dda60eeedd7fa00b81def4c7e47ea5126955614aea0051d2299cc2ea5a71781
7
- data.tar.gz: b57bdfac02d9cf80a4dc641b264ae3a6c139902504f4d3852d34f53d97698d328081c6b347e0a6ab3e05478b665c1f43248ab0851758682ecd8c6f958fbe0681
6
+ metadata.gz: 8ef9645ceadaac88f925d9fe49557111c2bf82b19030f9cdf1478e90c247309ad01d81c985b7b3765c8298e9b7166b6b08a67683af99aa2c218e8ed09742a0bf
7
+ data.tar.gz: 1500e641feb3a365fa9a9954f7647e9a5459faf49cee29216e4bf0cdcd2a86312c3e8ecc4c3fde5bb93ef4c8a3771dd9ed117fd9497862bf7c9ae2ad4205669e
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ce�C:�4���W�$��Dx�(L��f^�+S 'C5�ބ_s�)̇J��T�|��7Z��\\�Zd0����1ӭ��o���B׸')�FR�����T<:Ĩ�@����!�(F>@7 �Ħ�^��$�f�*|D��0
2
- "�i?:�� ����$���ʷje!��nQ.`"�oQmj@���-��[z�Y��["�If˂�q�H�K����3�����Y�y�E��3���h�R^�����2�lJ���
1
+ �3z�n��ղ��[KN�m 8�ׇ�+�Nr;�__�R�A�<uT� �lD��.z%�g���V���W��J�e{��v&�9T�J��{ �@@��#w�=��S7����V���b��o�r��h?��� �w&'�����OVCۂ�����P~)�+0�El6�$�ya�E`�Z�W�oԧ����"��$�\�^�?�և��Ip� m�!�Y���d�\}��e�o5���>c����hkK�_M��n����
data/lib/rexle-xpath.rb CHANGED
@@ -28,7 +28,7 @@ class RexleXPath
28
28
  end
29
29
 
30
30
  def parse(s)
31
-
31
+
32
32
  # it's an xpath function only
33
33
  if /^(?<name>\w+)\(\)$/ =~ s
34
34
 
@@ -40,29 +40,42 @@ class RexleXPath
40
40
  select(@node, [name])
41
41
 
42
42
  else
43
+
44
+ xpath_instructions = RexleXPathParser.new(s).to_a
45
+ #puts 'xpath_instructions: ' + xpath_instructions.inspect
43
46
 
44
- a = RexleXPathParser.new(s).to_a
45
- #puts 'a: ' + a.inspect
46
- query @node, a
47
+ query xpath_instructions, @node
47
48
  end
48
49
  end
49
50
 
50
- def query(node=@node, xpath_instructions)
51
+
52
+ def query(xpath_instructions=[], node=@node)
51
53
 
52
54
  debug :query, node: node, xpath_instructions: xpath_instructions
53
55
 
54
- r = []
55
-
56
56
  row = xpath_instructions.shift
57
57
  method_name, *args = row
58
58
 
59
- return query node, row + xpath_instructions if row.first.is_a? Array
59
+ return query row + xpath_instructions, node if row.first.is_a? Array
60
+
61
+ result = if method_name == :predicate then
62
+
63
+ result2 = method(method_name.to_sym).call node, args,[]
64
+
65
+ if result2 and xpath_instructions.any? then
66
+ query xpath_instructions, node
67
+ else
68
+ result2
69
+ end
70
+
71
+ else
60
72
 
61
- result = method(method_name.to_sym).call node, args, xpath_instructions
73
+ method(method_name.to_sym).call node, args, xpath_instructions
74
+ end
62
75
 
63
76
  result.is_a?(Array) ? result.flatten : result
64
77
 
65
- end
78
+ end
66
79
 
67
80
  private
68
81
 
@@ -77,7 +90,7 @@ class RexleXPath
77
90
  xi = xpath_instructions
78
91
 
79
92
  if xi[0] and xi[0][0].to_sym == :value then
80
-
93
+
81
94
  _, operator, value = xi.shift
82
95
  attr.method(operator.to_sym).call value
83
96
  else
@@ -89,7 +102,7 @@ class RexleXPath
89
102
 
90
103
  def count(node, args, xpath_instructions)
91
104
 
92
- r = query node, xpath_instructions
105
+ r = query xpath_instructions, node
93
106
  [r.length]
94
107
  end
95
108
 
@@ -99,14 +112,14 @@ class RexleXPath
99
112
  xpath_instructions: xpath_instructions
100
113
 
101
114
  i = args.first.to_i
102
- r = query node, xpath_instructions
115
+ r = query xpath_instructions, node
103
116
 
104
117
  [r[i-1]]
105
118
  end
106
119
 
107
120
  def not(node, args, xpath_instructions)
108
121
 
109
- r = query node, xpath_instructions
122
+ r = query xpath_instructions, node
110
123
  !(r ? r.any? : r)
111
124
  end
112
125
 
@@ -115,7 +128,7 @@ class RexleXPath
115
128
  debug :predicate, node: node, args: args,
116
129
  xpath_instructions: xpath_instructions
117
130
 
118
- r = query node, args
131
+ r = query args, node
119
132
 
120
133
  r.is_a?(Array) ? r.any? : r
121
134
 
@@ -126,9 +139,9 @@ class RexleXPath
126
139
  xi = args #xpath_instructions
127
140
 
128
141
  a = []
129
- a << query(node, xi.deep_clone)
142
+ a << query(xi.deep_clone, node)
130
143
 
131
- node.each_recursive {|e| a << query(e, xi.deep_clone) }
144
+ node.each_recursive {|e| a << query(xi.deep_clone, e) }
132
145
 
133
146
  a
134
147
  end
@@ -158,13 +171,13 @@ class RexleXPath
158
171
  end
159
172
 
160
173
  if xpath_instructions.any? and nodes_found.any? then
161
-
174
+
162
175
  nodes_found.inject([]) do |r, child_node|
163
176
 
164
177
  # deep clone the xpath instructions
165
178
  xi = xpath_instructions.deep_clone
166
-
167
- r2 = query(child_node, xi)
179
+
180
+ r2 = query(xi, child_node)
168
181
 
169
182
  case r2.class.to_s.to_sym
170
183
  when :'Rexle::Element' then r << r2
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.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -12,26 +12,26 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
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L
30
+ rXQIHP1YcNVmPNdYLPiBN6F6aSHZYVlJmsBQytSQGlWTcqJ4bVvKE+j7yfoxaBqi
31
+ nbFbbz3OsHrrR6h7FB5a8wQzCvYMtAr9VMPNl01QqBRi2wCEr6hR3gGBY0T1ZT5P
32
+ qYzPWuECaMhR5w==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-05-28 00:00:00.000000000 Z
34
+ date: 2016-05-29 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