rexle-xpath 0.2.12 → 0.2.13
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 +0 -0
- data/lib/rexle-xpath.rb +22 -14
- metadata +2 -2
- 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: 1d4007487547f7b0f7fb68a76cfb7fd1a8874517
|
4
|
+
data.tar.gz: 14422d54c789930a6175158910adf52ce4c4a70b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38453d905aa27badd643941901d433068da7980be5a1f4b9d6650ab1ff822492bd5f620336d6691728a25ec3115ee5632baa7e6e39ddd25713e3ee46c107da62
|
7
|
+
data.tar.gz: e302f65667fc1df02ba00c3bd188dba19c81f767752e7057a2152bff2911e930862da20e32cdabcca19044d7174260975ce03546d5740b7245e55cad3d3b1ec6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rexle-xpath.rb
CHANGED
@@ -29,13 +29,19 @@ class RexleXPath
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def parse(s)
|
32
|
-
|
33
|
-
case s
|
34
32
|
|
35
|
-
# it's an xpath function
|
36
|
-
|
37
|
-
|
33
|
+
# it's an xpath function only
|
34
|
+
if /^(?<name>\w+)\(\)$/ =~ s
|
35
|
+
|
36
|
+
@node.method((name).to_sym).call
|
37
|
+
|
38
|
+
# it's an element only
|
39
|
+
elsif /^(?<name>\w+)$/ =~ s
|
40
|
+
|
41
|
+
select(@node, [name])
|
42
|
+
|
38
43
|
else
|
44
|
+
|
39
45
|
a = RexleXPathParser.new(s).to_a
|
40
46
|
#puts 'a: ' + a.inspect
|
41
47
|
query @node, a
|
@@ -122,19 +128,17 @@ class RexleXPath
|
|
122
128
|
a = []
|
123
129
|
a << query(node, xi.deep_clone)
|
124
130
|
|
125
|
-
node.each_recursive
|
126
|
-
a << query(e, xi.deep_clone)
|
127
|
-
end
|
131
|
+
node.each_recursive {|e| a << query(e, xi.deep_clone) }
|
128
132
|
|
129
133
|
a
|
130
134
|
end
|
131
135
|
|
132
|
-
def select(node, args, xpath_instructions)
|
136
|
+
def select(node, args, xpath_instructions=[])
|
133
137
|
|
134
138
|
debug :select, node: node, args: args,
|
135
139
|
xpath_instructions: xpath_instructions
|
136
140
|
|
137
|
-
|
141
|
+
nodes_found = node.elements.select {|x| x.name == args.first }
|
138
142
|
flat_xpi = xpath_instructions.flatten
|
139
143
|
|
140
144
|
predicate = flat_xpi.first.to_s == 'predicate'
|
@@ -142,13 +146,13 @@ class RexleXPath
|
|
142
146
|
if predicate and flat_xpi[1] == :index then
|
143
147
|
|
144
148
|
i = flat_xpi[2].to_i - 1
|
145
|
-
return
|
149
|
+
return nodes_found[i]
|
146
150
|
|
147
151
|
end
|
148
152
|
|
149
|
-
if xpath_instructions.any? and
|
153
|
+
if xpath_instructions.any? and nodes_found.any? then
|
150
154
|
|
151
|
-
|
155
|
+
nodes_found.inject([]) do |r, child_node|
|
152
156
|
|
153
157
|
# deep clone the xpath instructions
|
154
158
|
xi = xpath_instructions.deep_clone
|
@@ -172,11 +176,15 @@ class RexleXPath
|
|
172
176
|
end # /inject
|
173
177
|
|
174
178
|
else
|
175
|
-
|
179
|
+
nodes_found
|
176
180
|
end # /if
|
177
181
|
|
178
182
|
end
|
179
183
|
|
184
|
+
def text(node, args, xpath_instructions)
|
185
|
+
node.text
|
186
|
+
end
|
187
|
+
|
180
188
|
def value(node, args, xpath_instructions)
|
181
189
|
|
182
190
|
operator, operand = args
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
05Hvy/ad61XnzWtun98claEIk/rC/TxPrbRaOd7vN99WxTy1xn8ElfLSx7CDDrTc
|
32
32
|
qN5t1BlRcAgKNw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-05-
|
34
|
+
date: 2016-05-25 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
|