rexleparser 0.9.6 → 0.9.10
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/lib/rexleparser.rb +62 -53
- data.tar.gz.sig +3 -2
- metadata +25 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ab3ac71d4b2615369aa480a89962c79578eb04a3c149a929a23db877ed2e8d0
|
|
4
|
+
data.tar.gz: e3fec0abf560e6ab097ac72c869db24ebf62a901978162103cccaaa5c6b38f42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8781aafeffd836f86f1a430e4fbb6dddf93a983237db4274db8c487a79ed6ec763994f02968471cc0665e67e5fec1daee099feda9654875d705aba15ef1b1e6
|
|
7
|
+
data.tar.gz: 389d4e385e9e965489fe09d13919656f3f0a24a9dc8a15a15d1672132927a87e0751368210747c9399d03460d673c742830d3448e385f328919dfddb2e837dcb
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/rexleparser.rb
CHANGED
|
@@ -7,49 +7,58 @@
|
|
|
7
7
|
class Attributes < Hash
|
|
8
8
|
|
|
9
9
|
class Value < String
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
def initialize(value)
|
|
12
12
|
#jr2020-04-30 super(value.gsub("'", '''))
|
|
13
13
|
super(value)
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
def <(val2)
|
|
17
17
|
self.to_f < val2.to_f
|
|
18
|
-
end
|
|
19
|
-
|
|
18
|
+
end
|
|
19
|
+
|
|
20
20
|
def >(val2)
|
|
21
21
|
self.to_f > val2.to_f
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
def inspect()
|
|
25
25
|
super().gsub('<','<',).gsub('>','>').gsub('&pos;',"'")
|
|
26
26
|
end
|
|
27
|
-
|
|
28
|
-
def to_s()
|
|
29
|
-
|
|
30
|
-
self.gsub('&pos;',"'")
|
|
27
|
+
|
|
28
|
+
def to_s(unescape: true)
|
|
29
|
+
unescape ? self.gsub('&','&').gsub('&pos;',"'") : self
|
|
31
30
|
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
35
34
|
def initialize(h={})
|
|
36
35
|
super().merge! h
|
|
37
36
|
end
|
|
38
|
-
|
|
37
|
+
|
|
39
38
|
def []=(k,v)
|
|
40
39
|
super(k, k != :class ? Value.new(v) : v)
|
|
41
40
|
end
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
def delete(key=nil)
|
|
43
|
+
|
|
44
|
+
if key then
|
|
45
|
+
super(key)
|
|
46
|
+
else
|
|
47
|
+
keys.each {|key| super(key)}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
43
52
|
def merge(h)
|
|
44
53
|
|
|
45
|
-
h2 = h.inject({}) do |r, kv|
|
|
54
|
+
h2 = h.inject({}) do |r, kv|
|
|
46
55
|
k, raw_v = kv
|
|
47
56
|
v = raw_v.is_a?(String) ? Value.new(raw_v) : raw_v
|
|
48
|
-
r.merge(k => v)
|
|
57
|
+
r.merge(k => v)
|
|
49
58
|
end
|
|
50
|
-
|
|
59
|
+
|
|
51
60
|
super(h2)
|
|
52
|
-
|
|
61
|
+
|
|
53
62
|
end
|
|
54
63
|
end
|
|
55
64
|
|
|
@@ -65,7 +74,7 @@ class RexleParser
|
|
|
65
74
|
super()
|
|
66
75
|
s = raw_s.clone.strip
|
|
67
76
|
return if s.empty?
|
|
68
|
-
|
|
77
|
+
|
|
69
78
|
raw_xml, raw_instrctns = if s.lines.first =~ /<?xml/ then
|
|
70
79
|
s.split(/(?=\?>\s*<\w)/,2).reverse
|
|
71
80
|
else
|
|
@@ -77,10 +86,10 @@ class RexleParser
|
|
|
77
86
|
@to_a = reverse(parse_node(raw_xml.strip.reverse))
|
|
78
87
|
|
|
79
88
|
end
|
|
80
|
-
|
|
89
|
+
|
|
81
90
|
private
|
|
82
91
|
|
|
83
|
-
|
|
92
|
+
|
|
84
93
|
def scan_next(r, tagname)
|
|
85
94
|
|
|
86
95
|
j = tagname
|
|
@@ -89,7 +98,7 @@ class RexleParser
|
|
|
89
98
|
|
|
90
99
|
# end tag match
|
|
91
100
|
tag = r[/^>[^<]+</]
|
|
92
|
-
|
|
101
|
+
|
|
93
102
|
if tag[1][/[ \w"']/] and tag[-2] != '/' then
|
|
94
103
|
|
|
95
104
|
# is it the end tag to match the start tag?
|
|
@@ -97,18 +106,18 @@ class RexleParser
|
|
|
97
106
|
end_tag = tag[/^>[^>]*#{j}<$/]
|
|
98
107
|
|
|
99
108
|
if end_tag then
|
|
100
|
-
|
|
109
|
+
|
|
101
110
|
j = nil
|
|
102
111
|
return [:end_tag, end_tag]
|
|
103
112
|
|
|
104
113
|
elsif tag[/^>[^>]*\w+<$/] then
|
|
105
114
|
# broken tag found
|
|
106
115
|
broken_tag = tag
|
|
107
|
-
return [:child, [nil, [], broken_tag]] if broken_tag
|
|
116
|
+
return [:child, [nil, [], broken_tag]] if broken_tag
|
|
108
117
|
else
|
|
109
|
-
|
|
118
|
+
|
|
110
119
|
text, newtag = tag.sub('>',';tg&').split(/>/,2)
|
|
111
|
-
|
|
120
|
+
|
|
112
121
|
if newtag then
|
|
113
122
|
tag = newtag
|
|
114
123
|
r.prepend '>' + tag
|
|
@@ -117,16 +126,16 @@ class RexleParser
|
|
|
117
126
|
return [:child, text]
|
|
118
127
|
end
|
|
119
128
|
elsif r[0,3] == '>--' then # comment tag found
|
|
120
|
-
|
|
129
|
+
|
|
121
130
|
r.slice!(0,3)
|
|
122
131
|
i = r =~ /(\-\-!<)/
|
|
123
132
|
s = r.slice!(0,i)
|
|
124
133
|
r.slice!(0,4)
|
|
125
134
|
|
|
126
135
|
tagname, content = ['-!',s]
|
|
127
|
-
|
|
136
|
+
|
|
128
137
|
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
|
129
|
-
|
|
138
|
+
|
|
130
139
|
elsif r[0,3] == '>]]' then # CDATA tag found
|
|
131
140
|
|
|
132
141
|
r.slice!(0,3)
|
|
@@ -136,22 +145,22 @@ class RexleParser
|
|
|
136
145
|
|
|
137
146
|
tagname, content = ['[!',s]
|
|
138
147
|
|
|
139
|
-
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
|
140
|
-
|
|
148
|
+
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
|
149
|
+
|
|
141
150
|
elsif tag[/>\/|\/<$/] or tag[/^>.*[\w!]+\/<$/] then
|
|
142
|
-
|
|
143
|
-
return [:newnode]
|
|
144
|
-
|
|
151
|
+
|
|
152
|
+
return [:newnode]
|
|
153
|
+
|
|
145
154
|
else
|
|
146
|
-
|
|
147
|
-
r.sub!('>',';tg&')
|
|
155
|
+
|
|
156
|
+
r.sub!('>',';tg&')
|
|
148
157
|
i = r =~ />(?:[\-\/"'\w]|\]\])/ # collect until a tag is found or a CDATA element
|
|
149
158
|
text = r.slice!(0,i)
|
|
150
159
|
|
|
151
160
|
return [:child, text] if text
|
|
152
161
|
|
|
153
162
|
end # end of tag match
|
|
154
|
-
|
|
163
|
+
|
|
155
164
|
else
|
|
156
165
|
|
|
157
166
|
# it's a text value
|
|
@@ -161,12 +170,12 @@ class RexleParser
|
|
|
161
170
|
return [:child, text] if text
|
|
162
171
|
end
|
|
163
172
|
end
|
|
164
|
-
|
|
173
|
+
|
|
165
174
|
def parse_node(r, j=nil)
|
|
166
|
-
|
|
175
|
+
|
|
167
176
|
return unless r.length > 0
|
|
168
177
|
tag = r.slice!(/^>[^<]+</) if (r =~ /^>[^<]+</) == 0
|
|
169
|
-
tagname = tag[/([\w!:]+)\/?<$/,1]
|
|
178
|
+
tagname = tag[/([\w!:]+)\/?<$/,1]
|
|
170
179
|
|
|
171
180
|
# self closing tag?
|
|
172
181
|
if tag[/^>\/.*#{tagname}<$/m] then
|
|
@@ -180,16 +189,16 @@ class RexleParser
|
|
|
180
189
|
start_tag.reverse + '; context: ' + r[0..120].reverse.inspect
|
|
181
190
|
end
|
|
182
191
|
|
|
183
|
-
until end_tag do
|
|
184
|
-
|
|
185
|
-
key, res = scan_next r, tagname
|
|
186
|
-
|
|
187
|
-
case key
|
|
192
|
+
until end_tag do
|
|
193
|
+
|
|
194
|
+
key, res = scan_next r, tagname
|
|
195
|
+
|
|
196
|
+
case key
|
|
188
197
|
when :end_tag
|
|
189
198
|
end_tag = res
|
|
190
199
|
r2 = [start_tag, children, end_tag]
|
|
191
200
|
end_tag = nil
|
|
192
|
-
|
|
201
|
+
|
|
193
202
|
return r2
|
|
194
203
|
when :child
|
|
195
204
|
children << res
|
|
@@ -204,13 +213,13 @@ class RexleParser
|
|
|
204
213
|
end
|
|
205
214
|
|
|
206
215
|
def get_attributes(raw_attributes)
|
|
207
|
-
|
|
216
|
+
|
|
208
217
|
r1 = /([\w\-:\(\)]+\='[^']*)'/
|
|
209
218
|
r2 = /([\w\-:\(\)]+\="[^"]*)"/
|
|
210
|
-
|
|
219
|
+
|
|
211
220
|
r = raw_attributes.scan(/#{r1}|#{r2}/).map(&:compact)\
|
|
212
221
|
.flatten.inject(Attributes.new) do |r, x|
|
|
213
|
-
attr_name, raw_val = x.split(/=/,2)
|
|
222
|
+
attr_name, raw_val = x.split(/=/,2)
|
|
214
223
|
val = attr_name != 'class' ? raw_val[1..-1] : raw_val[1..-1].split
|
|
215
224
|
r.merge(attr_name.to_sym => val)
|
|
216
225
|
end
|
|
@@ -219,17 +228,17 @@ class RexleParser
|
|
|
219
228
|
end
|
|
220
229
|
|
|
221
230
|
def reverse(raw_obj)
|
|
222
|
-
|
|
231
|
+
|
|
223
232
|
return unless raw_obj
|
|
224
233
|
obj = raw_obj.clone
|
|
225
234
|
return obj.reverse! if obj.is_a? String
|
|
226
235
|
|
|
227
236
|
tag = obj.pop.reverse
|
|
228
|
-
|
|
237
|
+
|
|
229
238
|
children = obj[-1]
|
|
230
239
|
|
|
231
240
|
r = children.reverse.map {|x| reverse(x)}
|
|
232
|
-
|
|
241
|
+
|
|
233
242
|
return [tag[/[!\-\w:\[]+/], get_attributes(tag), *r]
|
|
234
|
-
end
|
|
243
|
+
end
|
|
235
244
|
end
|
data.tar.gz.sig
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
:Jlh�Td�^�L<����;d�:�1Q����:W���<b J�;��o��}��zp����v�\�Zt�h�J��5&W�ӳ�/����SQ�Í�?��[��\���\$���]��)r��6LS�z�E�����3��-o�(��)�M�z�0~�Vɾ�*�ׂ�.��w�&�t�B6��jc�,ʟF�\!��~��a��Z8��������ڢ��x�=P�%q�W��/���+�r��H�!5�5��Y�����*��Jw`f#\���*H�1�{�����UA'��/�K��l�r�fy
|
|
2
|
+
Mt��{�r��!jQA��f��h�����6�٢n�x
|
|
3
|
+
���-�vP�x%vu3E�r3��n~ƽt`a��X��L�1B�r��;�F��&ܣM�
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rexleparser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -11,34 +11,34 @@ cert_chain:
|
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19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
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
+
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEACka8bLaU+wG55T9M2lqOrmXMsKpHQ5xtmSQk29OJ
|
|
29
|
+
4FUZ4aJEhTYxzJosvMNpauZVyrk+KyF/8uuGz5CfG/aPbOboB9+EIsmIcvRZ696M
|
|
30
|
+
BUXc6OuHE8SL0C9yuB9PloIZy2nxrRENFSV5xxyMS04bcaQjKCqtKw69+QT6lbra
|
|
31
|
+
iAU2EIebKyy0UIbrJSBIDKfig9KMEUrXvFUR4hu0lWpeT1bwq4sYeIeZNcg3v/y3
|
|
32
|
+
EbV3QK7AumvKgYvaz7iTu+9FKWT7AqIOH9wuPNPeXDLgyuKhLjdMaugz0wy6RYhT
|
|
33
|
+
Q8tgppTgSzQP8XwMg3xsaM+gWHbRLy8tO+3dkWTPN1m0xETWlSWFCiyi6oq8G4wC
|
|
34
|
+
t4pClPXscWrfmQa/u189WCF/O5BbsElrKQqx0vjq73l2apKjN9xViJi4LrEsZTuz
|
|
35
|
+
cF/nszU+U7PJ1WnQ+W7QTqoViru4N0S9bwi3YV5F5NPPeVnnrtmC2yruRfgTCI4b
|
|
36
|
+
3nEas0DJDZbQSkPP1mVcybEA
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
38
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
|
39
39
|
dependencies: []
|
|
40
40
|
description:
|
|
41
|
-
email:
|
|
41
|
+
email: digital.robertson@gmail.com
|
|
42
42
|
executables: []
|
|
43
43
|
extensions: []
|
|
44
44
|
extra_rdoc_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|