rexle-xpath 0.2.7 → 0.2.8

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: 18b76b3785397c285d8ecedb10d9717490fd9e45
4
- data.tar.gz: d5044d586690bc448ba9a8c0878ed2d77bd7a03f
3
+ metadata.gz: dc19a5685ab632af86ca73c09d7ee0d7fd0c0c47
4
+ data.tar.gz: b8a22111b544136a8363fb2b6ca082812b542055
5
5
  SHA512:
6
- metadata.gz: 366a3f5ebb06eb8ce44897d677755536bace9bbcd8f53ef9bb8f03167a8e1cc6e0a56a70a1462bcbe1e8285b2c9133d4e75aec8f4310869ff87061251c8bd9df
7
- data.tar.gz: 6fd386b3acd708c283d93ee3a9f709803bc2a99bbbd2b18d7f02f739e81673658c6db0098ef43ef6f5e0cdfb4267a772058a267a32d83d47420ced7f68692caa
6
+ metadata.gz: 14fa027a28f621e4bcb335a7436cb3f23a74144fea115e7a942b1c9c6ebf940beaa5477725205f8e32979a2899e5ba5ccde830d50e01ff38468493745426b261
7
+ data.tar.gz: 5b987f8b421d82b2e002ad6332f3e47893fd8a7ae6b21084d198555df037c3909673a575cffbb2ddc0f3a63f20ce7546702b9c844b339e5bed7a0f242334af81
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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
- r = node.attributes[key]
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
- r.method(operator.to_sym).call value
73
+ attr.method(operator.to_sym).call value
61
74
  else
62
- r ? true : false
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
- xi = Marshal.load( Marshal.dump(xpath_instructions) )
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.7
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-08 00:00:00.000000000 Z
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