rexle-xpath 0.2.7 → 0.2.8
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 +34 -5
- 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: dc19a5685ab632af86ca73c09d7ee0d7fd0c0c47
|
4
|
+
data.tar.gz: b8a22111b544136a8363fb2b6ca082812b542055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14fa027a28f621e4bcb335a7436cb3f23a74144fea115e7a942b1c9c6ebf940beaa5477725205f8e32979a2899e5ba5ccde830d50e01ff38468493745426b261
|
7
|
+
data.tar.gz: 5b987f8b421d82b2e002ad6332f3e47893fd8a7ae6b21084d198555df037c3909673a575cffbb2ddc0f3a63f20ce7546702b9c844b339e5bed7a0f242334af81
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rexle-xpath.rb
CHANGED
@@ -5,7 +5,20 @@
|
|
5
5
|
require 'rexle-xpath-parser'
|
6
6
|
|
7
7
|
|
8
|
+
module ArrayClone
|
9
|
+
|
10
|
+
refine Array do
|
11
|
+
|
12
|
+
def deep_clone()
|
13
|
+
Marshal.load( Marshal.dump(self) )
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
8
19
|
class RexleXPath
|
20
|
+
|
21
|
+
using ArrayClone
|
9
22
|
|
10
23
|
def initialize(node=nil, debug: false)
|
11
24
|
|
@@ -24,7 +37,7 @@ class RexleXPath
|
|
24
37
|
@node.method(($1).to_sym).call
|
25
38
|
else
|
26
39
|
a = RexleXPathParser.new(s).to_a
|
27
|
-
puts 'a: ' + a.inspect
|
40
|
+
#puts 'a: ' + a.inspect
|
28
41
|
query @node, a
|
29
42
|
end
|
30
43
|
end
|
@@ -50,16 +63,16 @@ class RexleXPath
|
|
50
63
|
def attribute(node, args, xpath_instructions)
|
51
64
|
|
52
65
|
key = args.first.to_sym
|
53
|
-
|
66
|
+
attr = node.attributes[key]
|
54
67
|
|
55
68
|
xi = xpath_instructions
|
56
69
|
|
57
70
|
if xi[0] and xi[0][0].to_sym == :value then
|
58
71
|
|
59
72
|
_, operator, value = xi.shift
|
60
|
-
|
73
|
+
attr.method(operator.to_sym).call value
|
61
74
|
else
|
62
|
-
|
75
|
+
attr ? true : false
|
63
76
|
end
|
64
77
|
|
65
78
|
|
@@ -81,6 +94,20 @@ class RexleXPath
|
|
81
94
|
|
82
95
|
end
|
83
96
|
|
97
|
+
def recursive(node, args, xpath_instructions)
|
98
|
+
|
99
|
+
xi = args #xpath_instructions
|
100
|
+
|
101
|
+
a = []
|
102
|
+
a << query(node, xi.deep_clone)
|
103
|
+
|
104
|
+
node.each_recursive do |e|
|
105
|
+
a << query(e, xi.deep_clone)
|
106
|
+
end
|
107
|
+
|
108
|
+
a
|
109
|
+
end
|
110
|
+
|
84
111
|
def select(node, args, xpath_instructions)
|
85
112
|
|
86
113
|
a = node.elements.select {|x| x.name == args.first }
|
@@ -90,7 +117,9 @@ class RexleXPath
|
|
90
117
|
|
91
118
|
a.inject([]) do |r, child_node|
|
92
119
|
|
93
|
-
|
120
|
+
# deep clone the xpath instructions
|
121
|
+
xi = xpath_instructions.deep_clone
|
122
|
+
|
94
123
|
r2 = query(child_node, xi)
|
95
124
|
|
96
125
|
case r2.class.to_s.to_sym
|
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.8
|
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-14 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
|