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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -2
- data/lib/rexle-xpath.rb +33 -20
- metadata +17 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 602043c3e561402f8ca1ccba80381ddf76a8aeb4
|
4
|
+
data.tar.gz: af520c3562d76c5113f5a3773bde1f6f26abf5be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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&�9�T�J��{�@@��#w�=��S7����V���b��o�r��h?����w&'�����OVCۂ�����P~)�+0�El�6�$�y�a�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
|
-
|
45
|
-
#puts 'a: ' + a.inspect
|
46
|
-
query @node, a
|
47
|
+
query xpath_instructions, @node
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
|
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
|
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
|
-
|
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
|
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
|
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
|
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
|
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(
|
142
|
+
a << query(xi.deep_clone, node)
|
130
143
|
|
131
|
-
node.each_recursive {|e| a << query(
|
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(
|
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.
|
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-----
|
13
13
|
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTE2MDUyOTEzNDcxMFoXDTE3MDUyOTEzNDcxMFowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
17
|
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
ggEBALISALPfeFb2IHDDnLTLgPjc25llYtMV4gD+oMXTIv3xOlwxJwj6b6LiTW9W
|
19
|
+
A60bBReSKThPYIFRQF9NcGuMRpH16pX8aWR+Z5SSIyj5g3t9GZJrmybdksZxR0kY
|
20
|
+
DY3/8vBqYtd1cEDQOVZpveSp1qB3E7J2Z4WNcO9L9dOd3BWSdq8YjteRPZggvGlT
|
21
|
+
k4rWmEAOHKP1YrZmFKxXv99lD9BhnHRDwuBkkIc8YIotYqbz7YJrUjxaR2/spaf7
|
22
|
+
nrJ/u70qVjagrxYfrqpTIx4/t5GXZYDEVKwcoVSD0F6v52jVc29wUDvWP2L8thZI
|
23
|
+
K+gimjnSkr+QO/JuAbY2da2cjscCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUuYfEtfspBiGjzk1B4p1281vD4PAwJgYDVR0RBB8w
|
25
25
|
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEANbAbWnyn
|
27
|
+
0AUujyss1lchjhHqQjF7BOnk5M+d32p4A73PMm4XtfqgwiD1Ix8ygZ6onARuGrcf
|
28
|
+
4NEjk0DS314WYILcXPjg5hDxyb57LJZq4Y4mnQ//a87Zb9xuR+478fZH/IldAZSc
|
29
|
+
rRwpzA/L7RE4YXq11UAMUfo/HXMd8ksCU9yL4MoJwyIDInLzZLW1gAT+cnzb2gyL
|
30
|
+
rXQIHP1YcNVmPNdYLPiBN6F6aSHZYVlJmsBQytSQGlWTcqJ4bVvKE+j7yfoxaBqi
|
31
|
+
nbFbbz3OsHrrR6h7FB5a8wQzCvYMtAr9VMPNl01QqBRi2wCEr6hR3gGBY0T1ZT5P
|
32
|
+
qYzPWuECaMhR5w==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-05-
|
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
|