rexleparser 0.9.5 → 0.9.9
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 +52 -52
- data.tar.gz.sig +0 -0
- metadata +27 -26
- 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: 3059b4fd1544e6c16167934dbc60e77c82c0bf57674e0d99e71c39b96909efb1
|
4
|
+
data.tar.gz: 6f3377d006cd852abe4b88881a320207579d138fbadf5e8aa830a3d4ca24d598
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ddf0f05e84df521185a1606aa98b6a745902e2d35235d2ff6948e430ced3cfa2772aa1944191b00c8a045b16c58be884ce0a2f5dcdc7ec2e4e7cc078c5caa6
|
7
|
+
data.tar.gz: 8ef7aae9fc024a71d8ab79254f6ca7abb6d301ebd02696e15ea5138ab68074b2f57ebd8166a4f4421c61d24db2f94101654d753bf4af800ef593ae44c99d06ff
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rexleparser.rb
CHANGED
@@ -7,48 +7,48 @@
|
|
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
|
-
self.gsub('&
|
27
|
+
|
28
|
+
def to_s(unescape: true)
|
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
|
41
|
-
|
41
|
+
|
42
42
|
def merge(h)
|
43
43
|
|
44
|
-
h2 = h.inject({}) do |r, kv|
|
44
|
+
h2 = h.inject({}) do |r, kv|
|
45
45
|
k, raw_v = kv
|
46
46
|
v = raw_v.is_a?(String) ? Value.new(raw_v) : raw_v
|
47
|
-
r.merge(k => v)
|
47
|
+
r.merge(k => v)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
super(h2)
|
51
|
-
|
51
|
+
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -64,7 +64,7 @@ class RexleParser
|
|
64
64
|
super()
|
65
65
|
s = raw_s.clone.strip
|
66
66
|
return if s.empty?
|
67
|
-
|
67
|
+
|
68
68
|
raw_xml, raw_instrctns = if s.lines.first =~ /<?xml/ then
|
69
69
|
s.split(/(?=\?>\s*<\w)/,2).reverse
|
70
70
|
else
|
@@ -76,10 +76,10 @@ class RexleParser
|
|
76
76
|
@to_a = reverse(parse_node(raw_xml.strip.reverse))
|
77
77
|
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
private
|
81
81
|
|
82
|
-
|
82
|
+
|
83
83
|
def scan_next(r, tagname)
|
84
84
|
|
85
85
|
j = tagname
|
@@ -88,7 +88,7 @@ class RexleParser
|
|
88
88
|
|
89
89
|
# end tag match
|
90
90
|
tag = r[/^>[^<]+</]
|
91
|
-
|
91
|
+
|
92
92
|
if tag[1][/[ \w"']/] and tag[-2] != '/' then
|
93
93
|
|
94
94
|
# is it the end tag to match the start tag?
|
@@ -96,18 +96,18 @@ class RexleParser
|
|
96
96
|
end_tag = tag[/^>[^>]*#{j}<$/]
|
97
97
|
|
98
98
|
if end_tag then
|
99
|
-
|
99
|
+
|
100
100
|
j = nil
|
101
101
|
return [:end_tag, end_tag]
|
102
102
|
|
103
103
|
elsif tag[/^>[^>]*\w+<$/] then
|
104
104
|
# broken tag found
|
105
105
|
broken_tag = tag
|
106
|
-
return [:child, [nil, [], broken_tag]] if broken_tag
|
106
|
+
return [:child, [nil, [], broken_tag]] if broken_tag
|
107
107
|
else
|
108
|
-
|
108
|
+
|
109
109
|
text, newtag = tag.sub('>',';tg&').split(/>/,2)
|
110
|
-
|
110
|
+
|
111
111
|
if newtag then
|
112
112
|
tag = newtag
|
113
113
|
r.prepend '>' + tag
|
@@ -116,16 +116,16 @@ class RexleParser
|
|
116
116
|
return [:child, text]
|
117
117
|
end
|
118
118
|
elsif r[0,3] == '>--' then # comment tag found
|
119
|
-
|
119
|
+
|
120
120
|
r.slice!(0,3)
|
121
121
|
i = r =~ /(\-\-!<)/
|
122
122
|
s = r.slice!(0,i)
|
123
123
|
r.slice!(0,4)
|
124
124
|
|
125
125
|
tagname, content = ['-!',s]
|
126
|
-
|
126
|
+
|
127
127
|
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
128
|
-
|
128
|
+
|
129
129
|
elsif r[0,3] == '>]]' then # CDATA tag found
|
130
130
|
|
131
131
|
r.slice!(0,3)
|
@@ -135,22 +135,22 @@ class RexleParser
|
|
135
135
|
|
136
136
|
tagname, content = ['[!',s]
|
137
137
|
|
138
|
-
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
139
|
-
|
138
|
+
return [:child, [">#{tagname}<", [content], ">#{tagname}/<"]]
|
139
|
+
|
140
140
|
elsif tag[/>\/|\/<$/] or tag[/^>.*[\w!]+\/<$/] then
|
141
|
-
|
142
|
-
return [:newnode]
|
143
|
-
|
141
|
+
|
142
|
+
return [:newnode]
|
143
|
+
|
144
144
|
else
|
145
|
-
|
146
|
-
r.sub!('>',';tg&')
|
145
|
+
|
146
|
+
r.sub!('>',';tg&')
|
147
147
|
i = r =~ />(?:[\-\/"'\w]|\]\])/ # collect until a tag is found or a CDATA element
|
148
148
|
text = r.slice!(0,i)
|
149
149
|
|
150
150
|
return [:child, text] if text
|
151
151
|
|
152
152
|
end # end of tag match
|
153
|
-
|
153
|
+
|
154
154
|
else
|
155
155
|
|
156
156
|
# it's a text value
|
@@ -160,12 +160,12 @@ class RexleParser
|
|
160
160
|
return [:child, text] if text
|
161
161
|
end
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
def parse_node(r, j=nil)
|
165
|
-
|
165
|
+
|
166
166
|
return unless r.length > 0
|
167
167
|
tag = r.slice!(/^>[^<]+</) if (r =~ /^>[^<]+</) == 0
|
168
|
-
tagname = tag[/([\w!:]+)\/?<$/,1]
|
168
|
+
tagname = tag[/([\w!:]+)\/?<$/,1]
|
169
169
|
|
170
170
|
# self closing tag?
|
171
171
|
if tag[/^>\/.*#{tagname}<$/m] then
|
@@ -179,16 +179,16 @@ class RexleParser
|
|
179
179
|
start_tag.reverse + '; context: ' + r[0..120].reverse.inspect
|
180
180
|
end
|
181
181
|
|
182
|
-
until end_tag do
|
183
|
-
|
184
|
-
key, res = scan_next r, tagname
|
185
|
-
|
186
|
-
case key
|
182
|
+
until end_tag do
|
183
|
+
|
184
|
+
key, res = scan_next r, tagname
|
185
|
+
|
186
|
+
case key
|
187
187
|
when :end_tag
|
188
188
|
end_tag = res
|
189
189
|
r2 = [start_tag, children, end_tag]
|
190
190
|
end_tag = nil
|
191
|
-
|
191
|
+
|
192
192
|
return r2
|
193
193
|
when :child
|
194
194
|
children << res
|
@@ -203,13 +203,13 @@ class RexleParser
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def get_attributes(raw_attributes)
|
206
|
-
|
206
|
+
|
207
207
|
r1 = /([\w\-:\(\)]+\='[^']*)'/
|
208
208
|
r2 = /([\w\-:\(\)]+\="[^"]*)"/
|
209
|
-
|
209
|
+
|
210
210
|
r = raw_attributes.scan(/#{r1}|#{r2}/).map(&:compact)\
|
211
211
|
.flatten.inject(Attributes.new) do |r, x|
|
212
|
-
attr_name, raw_val = x.split(/=/,2)
|
212
|
+
attr_name, raw_val = x.split(/=/,2)
|
213
213
|
val = attr_name != 'class' ? raw_val[1..-1] : raw_val[1..-1].split
|
214
214
|
r.merge(attr_name.to_sym => val)
|
215
215
|
end
|
@@ -218,17 +218,17 @@ class RexleParser
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def reverse(raw_obj)
|
221
|
-
|
221
|
+
|
222
222
|
return unless raw_obj
|
223
223
|
obj = raw_obj.clone
|
224
224
|
return obj.reverse! if obj.is_a? String
|
225
225
|
|
226
226
|
tag = obj.pop.reverse
|
227
|
-
|
227
|
+
|
228
228
|
children = obj[-1]
|
229
229
|
|
230
230
|
r = children.reverse.map {|x| reverse(x)}
|
231
|
-
|
231
|
+
|
232
232
|
return [tag[/[!\-\w:\[]+/], get_attributes(tag), *r]
|
233
|
-
end
|
233
|
+
end
|
234
234
|
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.9.
|
4
|
+
version: 0.9.9
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|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
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-15 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: []
|
@@ -63,7 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 2.7.10
|
67
68
|
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: Rexleparser is an XML parser used by the Rexle gem
|
metadata.gz.sig
CHANGED
Binary file
|