rexleparser 0.9.10 → 1.0.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rexleparser.rb +49 -49
- data.tar.gz.sig +0 -0
- metadata +28 -28
- 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: a98589dfd93cc2c5a4946f9dc5a2bc5418bd30cbfc4662330d7698bf13b1e107
|
4
|
+
data.tar.gz: 92a35568634aa47b9032aeb26cc193830adee7ba0c3d48dc2a53458119671791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1132a312974ad5eaef5b1267bf18f35e0228138a3247a867e6e9de4f366f8c654b6f24220e68922cca90698520c07bf45cdc52d44390fedf50e8c97df3ac0666
|
7
|
+
data.tar.gz: 211dddd0cd0411e4311541dd88e8742dbb1f32a2d5cdd6a25b48d90ef25ffd4a4bab7525180c5bdfe7a0b8afb1610e4b532e2fefec4980acae2d22dc160b0602
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rexleparser.rb
CHANGED
@@ -7,20 +7,20 @@
|
|
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
|
@@ -28,13 +28,13 @@ class Attributes < Hash
|
|
28
28
|
def to_s(unescape: true)
|
29
29
|
unescape ? self.gsub('&','&').gsub('&pos;',"'") : self
|
30
30
|
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
34
|
def initialize(h={})
|
35
35
|
super().merge! h
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def []=(k,v)
|
39
39
|
super(k, k != :class ? Value.new(v) : v)
|
40
40
|
end
|
@@ -48,17 +48,17 @@ class Attributes < Hash
|
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def merge(h)
|
53
53
|
|
54
|
-
h2 = h.inject({}) do |r, kv|
|
54
|
+
h2 = h.inject({}) do |r, kv|
|
55
55
|
k, raw_v = kv
|
56
56
|
v = raw_v.is_a?(String) ? Value.new(raw_v) : raw_v
|
57
|
-
r.merge(k => v)
|
57
|
+
r.merge(k => v)
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
super(h2)
|
61
|
-
|
61
|
+
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -74,7 +74,7 @@ class RexleParser
|
|
74
74
|
super()
|
75
75
|
s = raw_s.clone.strip
|
76
76
|
return if s.empty?
|
77
|
-
|
77
|
+
|
78
78
|
raw_xml, raw_instrctns = if s.lines.first =~ /<?xml/ then
|
79
79
|
s.split(/(?=\?>\s*<\w)/,2).reverse
|
80
80
|
else
|
@@ -86,10 +86,10 @@ class RexleParser
|
|
86
86
|
@to_a = reverse(parse_node(raw_xml.strip.reverse))
|
87
87
|
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
private
|
91
91
|
|
92
|
-
|
92
|
+
|
93
93
|
def scan_next(r, tagname)
|
94
94
|
|
95
95
|
j = tagname
|
@@ -98,7 +98,7 @@ class RexleParser
|
|
98
98
|
|
99
99
|
# end tag match
|
100
100
|
tag = r[/^>[^<]+</]
|
101
|
-
|
101
|
+
|
102
102
|
if tag[1][/[ \w"']/] and tag[-2] != '/' then
|
103
103
|
|
104
104
|
# is it the end tag to match the start tag?
|
@@ -106,18 +106,18 @@ class RexleParser
|
|
106
106
|
end_tag = tag[/^>[^>]*#{j}<$/]
|
107
107
|
|
108
108
|
if end_tag then
|
109
|
-
|
109
|
+
|
110
110
|
j = nil
|
111
111
|
return [:end_tag, end_tag]
|
112
112
|
|
113
113
|
elsif tag[/^>[^>]*\w+<$/] then
|
114
114
|
# broken tag found
|
115
115
|
broken_tag = tag
|
116
|
-
return [:child, [nil, [], broken_tag]] if broken_tag
|
116
|
+
return [:child, [nil, [], broken_tag]] if broken_tag
|
117
117
|
else
|
118
|
-
|
118
|
+
|
119
119
|
text, newtag = tag.sub('>',';tg&').split(/>/,2)
|
120
|
-
|
120
|
+
|
121
121
|
if newtag then
|
122
122
|
tag = newtag
|
123
123
|
r.prepend '>' + tag
|
@@ -126,16 +126,16 @@ class RexleParser
|
|
126
126
|
return [:child, text]
|
127
127
|
end
|
128
128
|
elsif r[0,3] == '>--' then # comment tag found
|
129
|
-
|
129
|
+
|
130
130
|
r.slice!(0,3)
|
131
131
|
i = r =~ /(\-\-!<)/
|
132
132
|
s = r.slice!(0,i)
|
133
133
|
r.slice!(0,4)
|
134
134
|
|
135
135
|
tagname, content = ['-!',s]
|
136
|
-
|
136
|
+
|
137
137
|
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
138
|
-
|
138
|
+
|
139
139
|
elsif r[0,3] == '>]]' then # CDATA tag found
|
140
140
|
|
141
141
|
r.slice!(0,3)
|
@@ -145,22 +145,22 @@ class RexleParser
|
|
145
145
|
|
146
146
|
tagname, content = ['[!',s]
|
147
147
|
|
148
|
-
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
149
|
-
|
148
|
+
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
149
|
+
|
150
150
|
elsif tag[/>\/|\/<$/] or tag[/^>.*[\w!]+\/<$/] then
|
151
|
-
|
152
|
-
return [:newnode]
|
153
|
-
|
151
|
+
|
152
|
+
return [:newnode]
|
153
|
+
|
154
154
|
else
|
155
|
-
|
156
|
-
r.sub!('>',';tg&')
|
155
|
+
|
156
|
+
r.sub!('>',';tg&')
|
157
157
|
i = r =~ />(?:[\-\/"'\w]|\]\])/ # collect until a tag is found or a CDATA element
|
158
158
|
text = r.slice!(0,i)
|
159
159
|
|
160
160
|
return [:child, text] if text
|
161
161
|
|
162
162
|
end # end of tag match
|
163
|
-
|
163
|
+
|
164
164
|
else
|
165
165
|
|
166
166
|
# it's a text value
|
@@ -170,12 +170,12 @@ class RexleParser
|
|
170
170
|
return [:child, text] if text
|
171
171
|
end
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
def parse_node(r, j=nil)
|
175
|
-
|
175
|
+
|
176
176
|
return unless r.length > 0
|
177
177
|
tag = r.slice!(/^>[^<]+</) if (r =~ /^>[^<]+</) == 0
|
178
|
-
tagname = tag[/([\w!:]+)\/?<$/,1]
|
178
|
+
tagname = tag[/([\w!:]+)\/?<$/,1]
|
179
179
|
|
180
180
|
# self closing tag?
|
181
181
|
if tag[/^>\/.*#{tagname}<$/m] then
|
@@ -189,16 +189,16 @@ class RexleParser
|
|
189
189
|
start_tag.reverse + '; context: ' + r[0..120].reverse.inspect
|
190
190
|
end
|
191
191
|
|
192
|
-
until end_tag do
|
193
|
-
|
194
|
-
key, res = scan_next r, tagname
|
195
|
-
|
196
|
-
case key
|
192
|
+
until end_tag do
|
193
|
+
|
194
|
+
key, res = scan_next r, tagname
|
195
|
+
|
196
|
+
case key
|
197
197
|
when :end_tag
|
198
198
|
end_tag = res
|
199
199
|
r2 = [start_tag, children, end_tag]
|
200
200
|
end_tag = nil
|
201
|
-
|
201
|
+
|
202
202
|
return r2
|
203
203
|
when :child
|
204
204
|
children << res
|
@@ -213,13 +213,13 @@ class RexleParser
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def get_attributes(raw_attributes)
|
216
|
-
|
216
|
+
|
217
217
|
r1 = /([\w\-:\(\)]+\='[^']*)'/
|
218
218
|
r2 = /([\w\-:\(\)]+\="[^"]*)"/
|
219
|
-
|
219
|
+
|
220
220
|
r = raw_attributes.scan(/#{r1}|#{r2}/).map(&:compact)\
|
221
221
|
.flatten.inject(Attributes.new) do |r, x|
|
222
|
-
attr_name, raw_val = x.split(/=/,2)
|
222
|
+
attr_name, raw_val = x.split(/=/,2)
|
223
223
|
val = attr_name != 'class' ? raw_val[1..-1] : raw_val[1..-1].split
|
224
224
|
r.merge(attr_name.to_sym => val)
|
225
225
|
end
|
@@ -228,17 +228,17 @@ class RexleParser
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def reverse(raw_obj)
|
231
|
-
|
231
|
+
|
232
232
|
return unless raw_obj
|
233
233
|
obj = raw_obj.clone
|
234
234
|
return obj.reverse! if obj.is_a? String
|
235
235
|
|
236
236
|
tag = obj.pop.reverse
|
237
|
-
|
237
|
+
|
238
238
|
children = obj[-1]
|
239
239
|
|
240
240
|
r = children.reverse.map {|x| reverse(x)}
|
241
|
-
|
241
|
+
|
242
242
|
return [tag[/[!\-\w:\[]+/], get_attributes(tag), *r]
|
243
|
-
end
|
243
|
+
end
|
244
244
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,32 +10,33 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|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
+
R19PMQIDAQABo4GKMIGHMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
27
|
+
BBQiPSrne0dHxLynj/1izBmEwv/lkTAmBgNVHREEHzAdgRtnZW1tYXN0ZXJAamFt
|
28
|
+
ZXNyb2JlcnRzb24uZXUwJgYDVR0SBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
29
|
+
c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQBWIQG28MQXuVSHsAw/rQuaE1FpOmz0
|
30
|
+
AXWhHK1oDWxkoPTBIoLil2M2PI3htcBBRLUzyli9XFvqjzuO+J8LpWqs2iddxjXP
|
31
|
+
3xtUg0h+0urVRk00xwsnPLppwT7VxvycQifN31En8rMEzd24V5FKkn90brdokVQC
|
32
|
+
5aL/9LD3S5k3t4AyUcGeOFuU+k87lEz8bzKk2wjOjzpgxjNyqeK6h0iFeA94rhnp
|
33
|
+
HPaebr7ytgAR3dKU/Zr/gmZdQroli86LaOqGK1AJQ9E1RFBKwKluNa27dR3VyqBA
|
34
|
+
VG1Z/9QNxm0ivqKr7samwkNUGiql+s4CPZndbJD/hmDDdmCtYf1mywCAUOh+DrfU
|
35
|
+
iKwWhO5Qmo/RUOvr0a4KtP5i0N7qY1LFMSCpfCRTS9zTlfTIjs1ipAnWhLcqp5Js
|
36
|
+
NMSYHad41dFYLrVyE7mdZdIVlFqIdG+V1x7iY+zPpg7FS/8EUnK5zUxMC0YoLeK2
|
37
|
+
hcHycb1NL9Ujb7onXEop5Dobym6xO6V+yBY=
|
37
38
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
39
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
39
40
|
dependencies: []
|
40
41
|
description:
|
41
42
|
email: digital.robertson@gmail.com
|
@@ -63,8 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
64
|
- !ruby/object:Gem::Version
|
64
65
|
version: '0'
|
65
66
|
requirements: []
|
66
|
-
|
67
|
-
rubygems_version: 2.7.10
|
67
|
+
rubygems_version: 3.4.4
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Rexleparser is an XML parser used by the Rexle gem
|
metadata.gz.sig
CHANGED
Binary file
|