rexle-xpath 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rexle-xpath.rb +22 -9
- 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: 7e3af7b969033bc79cda32bf7ab3a65d9b54cc9e
|
|
4
|
+
data.tar.gz: 32b1214acd14d40e15c91ad212c13f6a9d279f9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0fa3140fc5bf40451319decd8aa432ddb235f6c7f8e0f6de79da0fce45d0cfa04557458e7b12733c0b7a79f0c2fac4175b8dc2927b5b142acd631e2e686dd13
|
|
7
|
+
data.tar.gz: 253b0aa1f5a1aeeba768ff5d5dd3d0f0a80f0e5d6c58843bc2dfa0fd86431903f285c06af1ad209e70a0be1a7b7ee8f204dbbc92194560cac822a04c9f832ce4
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/rexle-xpath.rb
CHANGED
|
@@ -16,26 +16,39 @@ class RexleXPath
|
|
|
16
16
|
def parse(s)
|
|
17
17
|
|
|
18
18
|
case s
|
|
19
|
+
|
|
20
|
+
# it's an xpath function
|
|
19
21
|
when /^(\w+)\(\)$/
|
|
20
22
|
@node.method(($1).to_sym).call
|
|
21
23
|
else
|
|
22
|
-
query RexleXPathParser.new(s).to_a
|
|
24
|
+
query @node, RexleXPathParser.new(s).to_a
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
def query(
|
|
28
|
+
def query(node, xpath_instructions)
|
|
27
29
|
|
|
28
30
|
r = []
|
|
31
|
+
row = xpath_instructions.shift
|
|
32
|
+
|
|
33
|
+
method_name, *args = row
|
|
29
34
|
|
|
30
|
-
a
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
r
|
|
35
|
+
a = if method_name == :select then
|
|
36
|
+
|
|
37
|
+
r = node.select args.first
|
|
38
|
+
|
|
39
|
+
if xpath_instructions.any? and r.any? then
|
|
40
|
+
r.map {|child_node| query(child_node, xpath_instructions) }
|
|
41
|
+
else
|
|
42
|
+
r
|
|
36
43
|
end
|
|
44
|
+
|
|
45
|
+
elsif row.is_a? Array then
|
|
46
|
+
query node, row
|
|
47
|
+
else
|
|
48
|
+
[]
|
|
37
49
|
end
|
|
38
|
-
|
|
50
|
+
|
|
51
|
+
a.flatten
|
|
39
52
|
|
|
40
53
|
end
|
|
41
54
|
|
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.1
|
|
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:
|
|
34
|
+
date: 2016-05-05 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
|