rexle-xpath 0.2.2 → 0.2.3
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 +2 -3
- data/lib/rexle-xpath.rb +30 -42
- metadata +1 -1
- 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: 7715f6fa6fed4841965fe1e1b72a32222f47a242
|
4
|
+
data.tar.gz: 6c17c63d65f2c6b0ece0410ecbb63b2c021d1dfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 886a1cc9f4d53176fb1103f7dc57a849563330cb8d6fb7850c21b32573973fd58f9a406efb4e7abcdc3aeb7c5c93eafa289e7d5fac8f21cd27f31a19ef20cda5
|
7
|
+
data.tar.gz: 7f70490345d52947f38424eda78b7321b01c91c4ce8e0afd9cc5c31509b01a5ca7224150f897ff4b59af23c76f9b63a150dd7b0348d4ea1ed2fb5dadb88c52cf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
K�
|
2
|
-
|
3
|
-
��S�`H�pP@EР����Vx?�Jgڋ���ͪ|J�9,���>���~��q�E ����y4�w�FK�IA��x!�S��p�y�
|
1
|
+
j��J�+8��� ��]/���z�A��.Q����$���}23��2��K�jAQno�c0�m�Dh"5�ٕ��ޚ�o�P`��A��T���}�o��2a������Tc)��̵���ʰ��2���@S�M}~AM��kbg�[�K]�V�6ϡ
|
2
|
+
⒖qL;�T��� ��S���_a6�G�]C�=~����=�yʀ��/~���i8~D�KL�sފOa��w �j���KhQ����HG,�\z��5���
|
data/lib/rexle-xpath.rb
CHANGED
@@ -29,86 +29,74 @@ class RexleXPath
|
|
29
29
|
|
30
30
|
r = []
|
31
31
|
|
32
|
-
row = xpath_instructions.shift
|
33
|
-
|
32
|
+
row = xpath_instructions.shift
|
34
33
|
method_name, *args = row
|
35
34
|
|
36
|
-
return query node, row if row.first.is_a? Array
|
37
|
-
|
38
|
-
result = if method_name.to_sym == :select then
|
39
|
-
|
40
|
-
method(:select).call node, args, xpath_instructions
|
41
|
-
|
42
|
-
elsif method_name.to_sym == :text or method_name.to_sym == :value then
|
43
|
-
|
44
|
-
method(:value).call node, args, xpath_instructions
|
45
|
-
|
46
|
-
elsif method_name.to_sym == :predicate then
|
47
|
-
|
48
|
-
method(:predicate).call node, args, xpath_instructions
|
49
|
-
|
50
|
-
elsif row.is_a? Array then
|
51
|
-
query node, row
|
52
|
-
else
|
53
|
-
[]
|
54
|
-
end
|
35
|
+
return query node, row if row.first.is_a? Array
|
55
36
|
|
37
|
+
result = method(method_name.to_sym).call node, args, xpath_instructions
|
56
38
|
result.is_a?(Array) ? result.flatten : result
|
57
39
|
|
58
40
|
end
|
59
41
|
|
60
42
|
private
|
61
43
|
|
44
|
+
def not(node, args, xpath_instructions)
|
45
|
+
|
46
|
+
r = query node, xpath_instructions
|
47
|
+
!(r ? r.any? : r)
|
48
|
+
end
|
49
|
+
|
62
50
|
def predicate(node, args, xpath_instructions)
|
63
51
|
|
64
|
-
|
65
|
-
r
|
66
|
-
r ? r.any? : r
|
52
|
+
r = query node, args
|
53
|
+
r ? r.any? : r
|
67
54
|
end
|
68
55
|
|
69
56
|
def select(node, args, xpath_instructions)
|
70
57
|
|
71
58
|
a = node.select args.first
|
72
59
|
|
60
|
+
predicate = xpath_instructions.flatten.first.to_s == 'predicate'
|
61
|
+
|
73
62
|
if xpath_instructions.any? and a.any? then
|
74
63
|
|
75
64
|
a.inject([]) do |r, child_node|
|
76
65
|
|
77
66
|
r2 = query(child_node, xpath_instructions.clone)
|
78
67
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
r << child_node
|
83
|
-
|
84
|
-
r
|
68
|
+
case r2.class.to_s.to_sym
|
69
|
+
when :'Rexle::Element' then r << r2
|
70
|
+
when :TrueClass
|
71
|
+
predicate ? r << child_node : r << true
|
72
|
+
when :FalseClass
|
73
|
+
!predicate ? r << false : r
|
85
74
|
else
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
r
|
91
|
-
end
|
92
|
-
end
|
75
|
+
|
76
|
+
r2.any? ? r << r2 : r
|
77
|
+
|
78
|
+
end # /case
|
93
79
|
|
94
|
-
end
|
80
|
+
end # /inject
|
81
|
+
|
95
82
|
else
|
96
83
|
a
|
97
|
-
end
|
84
|
+
end # /if
|
85
|
+
|
98
86
|
end
|
99
87
|
|
100
88
|
def value(node, args, xpath_instructions)
|
101
89
|
|
102
90
|
operator, operand = args
|
103
91
|
|
104
|
-
|
92
|
+
case operator.to_sym
|
105
93
|
when :== then node.text == operand
|
106
94
|
when :> then node.value > operand
|
107
95
|
when :< then node.value < operand
|
108
96
|
end
|
109
|
-
|
110
|
-
r
|
111
97
|
|
112
98
|
end
|
113
99
|
|
100
|
+
alias text value
|
101
|
+
|
114
102
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|