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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf2484b60dec398cec31fd15d4fdb5eb9671c709
4
- data.tar.gz: 23c7da936c86982362c683ff34aad29dba2a72cc
3
+ metadata.gz: 7e3af7b969033bc79cda32bf7ab3a65d9b54cc9e
4
+ data.tar.gz: 32b1214acd14d40e15c91ad212c13f6a9d279f9c
5
5
  SHA512:
6
- metadata.gz: 9edbc0f90a0f60907355b4e243d455a9df024d65bb3b413df5a007609502a232bf27fba9413d79913f474c9a8cf05dc9016860076339e0bcbeaf774d1289e31c
7
- data.tar.gz: 70cf9c629140b49899bee288ebd32ef12247d4856fe6d6b64dc99a57546dd4bdeb2324d4ba836853a0bb3f2526638fa2717c4a4c099cf76cae4abf2a24153810
6
+ metadata.gz: c0fa3140fc5bf40451319decd8aa432ddb235f6c7f8e0f6de79da0fce45d0cfa04557458e7b12733c0b7a79f0c2fac4175b8dc2927b5b142acd631e2e686dd13
7
+ data.tar.gz: 253b0aa1f5a1aeeba768ff5d5dd3d0f0a80f0e5d6c58843bc2dfa0fd86431903f285c06af1ad209e70a0be1a7b7ee8f204dbbc92194560cac822a04c9f832ce4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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(a)
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.each do |row|
31
- x, *args = row
32
- if x == :select then
33
- r = @node.select args.first
34
- elsif row.is_a? Array then
35
- r = query row
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
- r
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.0
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: 2015-11-17 00:00:00.000000000 Z
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