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