rexle-builder 1.0.3 → 1.0.6
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/rexle-builder.rb +96 -56
- 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: c98998f1d62f33c83da0eae198fac89ba2f16a3652a7170130359965a7956cea
|
|
4
|
+
data.tar.gz: 15dcf04397f8e4fbd5aafe1c17cbca18ea2e6d7e094fbe50b4f9a66106cf4c53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b205afb74f88735a0f142ab84b943428a3dfbe50dc6ab6e288bdfbea2eba7b96fbeb82ed9402b92938296ee149d366c7b4bb70125208274bf0df7212e48b42f
|
|
7
|
+
data.tar.gz: daf70043a5c2ba48688c0b9fcdf726e69a94313b17f58d271f9e7b7595486d4583f00a640b4b46697036b6b02890411bf748ceb49a7d43f0398313edb9d0bbcc
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/rexle-builder.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class RexleArray < Array
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
def initialize(raw_a)
|
|
9
9
|
a = raw_a.first.is_a?(Array) ? raw_a : [raw_a]
|
|
10
10
|
super(a)
|
|
@@ -19,20 +19,20 @@ class RexleBuilder
|
|
|
19
19
|
yield(self.new(debug: debug))
|
|
20
20
|
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def initialize(obj=nil, root: 'root', debug: false)
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
@debug = debug
|
|
26
26
|
@a = []
|
|
27
27
|
@current_a = @a
|
|
28
28
|
@namespace = nil
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
if obj.is_a? Hash then
|
|
31
|
-
|
|
32
|
-
key = obj.keys.first
|
|
33
|
-
|
|
31
|
+
|
|
32
|
+
key = obj.keys.first
|
|
33
|
+
|
|
34
34
|
if obj.length > 1 or obj[key].is_a?(Array) or obj[key].is_a?(String) then
|
|
35
|
-
self.send(root.to_sym) { buildx obj}
|
|
35
|
+
self.send(root.to_sym) { buildx obj}
|
|
36
36
|
else
|
|
37
37
|
self.send(key.to_sym) {buildx obj[key]}
|
|
38
38
|
end
|
|
@@ -50,96 +50,136 @@ class RexleBuilder
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def method_missing(sym, *args)
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
puts 'args: ' + args.inspect if @debug
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
value = args.find {|x| x.is_a? String} || ''
|
|
57
57
|
attributes, obj = args.select {|x| x.is_a? Hash}
|
|
58
|
-
|
|
59
|
-
# The obj is an optional Hash object used to build nested XML
|
|
58
|
+
|
|
59
|
+
# The obj is an optional Hash object used to build nested XML
|
|
60
60
|
# after the current element
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
if value =~ /^<.*>$/ then
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
a = [
|
|
65
|
-
sym.to_s,
|
|
66
|
-
attributes,
|
|
65
|
+
sym.to_s,
|
|
66
|
+
attributes,
|
|
67
67
|
*Rexle.new("<root>%s</root>" % value, debug: @debug).to_a[2..-1]
|
|
68
68
|
]
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
end
|
|
71
|
-
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# reserved keywords are masked with ._ e.g. ._method_missing
|
|
74
|
+
a ||= [sym.to_s.sub(/^(?:\._|_)/,'').sub(/^cdata!$/,'![')\
|
|
75
|
+
.sub(/^comment!$/, '!-'), attributes || {}, value || '']
|
|
72
76
|
if @debug then
|
|
73
77
|
puts 'sym: ' + sym.inspect
|
|
74
78
|
puts 'args: ' + args.inspect
|
|
79
|
+
puts 'obj: ' + obj.inspect
|
|
80
|
+
puts 'a: ' + a.inspect
|
|
75
81
|
end
|
|
76
|
-
|
|
77
|
-
# reserved keywords are masked with ._ e.g. ._method_missing
|
|
78
|
-
a ||= [sym.to_s.sub(/^(?:\._|_)/,'').sub(/^cdata!$/,'![')\
|
|
79
|
-
.sub(/^comment!$/, '!-'), attributes || {}, value || '']
|
|
80
|
-
|
|
82
|
+
|
|
81
83
|
a.concat RexleBuilder.new(obj, debug: false).to_a[3..-1] if obj
|
|
82
84
|
|
|
83
|
-
if @namespace then
|
|
85
|
+
if @namespace then
|
|
84
86
|
a.first.prepend(@namespace + ':')
|
|
85
|
-
@namespace = nil
|
|
87
|
+
@namespace = nil
|
|
86
88
|
end
|
|
87
89
|
|
|
88
90
|
@current_a << a
|
|
89
|
-
|
|
91
|
+
puts '@current_a, before block_given : ' + @current_a.inspect if @debug
|
|
92
|
+
|
|
90
93
|
if block_given? then
|
|
91
|
-
|
|
94
|
+
|
|
92
95
|
prev_a = @current_a
|
|
93
96
|
@current_a = a
|
|
94
|
-
|
|
95
|
-
r = yield()
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@
|
|
99
|
-
|
|
97
|
+
|
|
98
|
+
r = yield()
|
|
99
|
+
@current_a = prev_a
|
|
100
|
+
|
|
101
|
+
if @debug then
|
|
102
|
+
puts 'r: ' + r.inspect
|
|
103
|
+
puts 'r.class: ' + r.class.inspect
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
return r if r == @a.first
|
|
107
|
+
|
|
108
|
+
if r.is_a? Array then
|
|
109
|
+
|
|
110
|
+
# only concat if r contains raw Rexle elements.
|
|
111
|
+
if r.all? {|field, attributes, value| attributes.is_a? Hash} then
|
|
112
|
+
@current_a.concat r
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
puts '@current_a ' + @current_a.inspect if @debug
|
|
117
|
+
#@current_a = prev_a
|
|
118
|
+
return @a.first
|
|
119
|
+
|
|
100
120
|
end
|
|
101
|
-
|
|
102
|
-
|
|
121
|
+
|
|
122
|
+
#@a.first
|
|
123
|
+
nil
|
|
103
124
|
end
|
|
104
|
-
|
|
125
|
+
|
|
105
126
|
private
|
|
106
|
-
|
|
127
|
+
|
|
107
128
|
# build from a Hash object
|
|
108
129
|
#
|
|
109
130
|
def buildx( h)
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
|
|
132
|
+
puts 'buildx: ' + h.inspect if @debug
|
|
133
|
+
# the following statement prevents duplicate elements where 1 key is
|
|
112
134
|
# represented by a String and the other by a symbol.
|
|
113
135
|
#
|
|
114
136
|
h2 = h.map {|x| [x[0].to_sym, x[1]]}.to_h
|
|
115
|
-
|
|
137
|
+
|
|
116
138
|
h2.each_pair do |key, value|
|
|
117
139
|
|
|
118
140
|
if value.is_a? Hash then
|
|
119
|
-
|
|
120
|
-
self.send(key.to_sym) do
|
|
141
|
+
puts 'buildx found Hash' + value.inspect if @debug
|
|
142
|
+
self.send(key.to_sym) do
|
|
121
143
|
buildx value
|
|
144
|
+
nil
|
|
122
145
|
end
|
|
123
|
-
|
|
124
|
-
elsif value.is_a?
|
|
125
|
-
|
|
146
|
+
|
|
147
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
|
148
|
+
|
|
149
|
+
puts 'buildx found Array' + value.inspect if @debug
|
|
150
|
+
puts 'key:' + key.inspect if @debug
|
|
151
|
+
|
|
126
152
|
self.send(key.to_sym) do
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
153
|
+
|
|
154
|
+
r2= []
|
|
155
|
+
value.each do |x|
|
|
156
|
+
|
|
157
|
+
if x.is_a? Hash then
|
|
158
|
+
puts 'x:' + x.inspect if @debug
|
|
159
|
+
buildx x
|
|
160
|
+
nil
|
|
161
|
+
else
|
|
162
|
+
puts 'x2:' + x.inspect if @debug
|
|
163
|
+
r2 << x
|
|
164
|
+
end
|
|
165
|
+
|
|
132
166
|
end
|
|
133
|
-
|
|
167
|
+
|
|
168
|
+
r2
|
|
134
169
|
end
|
|
135
|
-
|
|
170
|
+
|
|
136
171
|
else
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
|
|
173
|
+
puts 'buildx found other' + value.inspect if @debug
|
|
174
|
+
if value.is_a? String then
|
|
175
|
+
self.send(key.to_sym, value.to_s)
|
|
176
|
+
else
|
|
177
|
+
self.send(key.to_sym) {[value]}
|
|
178
|
+
end
|
|
179
|
+
|
|
140
180
|
end
|
|
141
181
|
end
|
|
142
182
|
|
|
143
|
-
end
|
|
183
|
+
end
|
|
144
184
|
|
|
145
185
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rexle-builder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9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HzAdgRtnZW1tYXN0ZXJAamFt
|
|
28
|
+
ZXNyb2JlcnRzb24uZXUwJgYDVR0SBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
|
29
|
+
c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQANTkbRlCnyKnC93YfSYYZZIY2yG3w4
|
|
30
|
+
aMC5NdlJbJKqNS5iFJFGzQmQFh64qphNYS/ER71XjeUcpQmL3G8CStlE2/Pgmw3q
|
|
31
|
+
AxGZQicTWSz7oZy0YWeAXiHu+Z+H5N9ar7r6cbN7e1X7100rXJOIoRbV30/7X2nd
|
|
32
|
+
oqq/CmaXtg5Tbr+pV461riwkEd+zq98EhVw8Mud0YOZ7QBGY1i1xK6DpTLWgzsiI
|
|
33
|
+
dCDj3IztA2K8hUJpP5aNw5nAGcLc/FxxGDySI2cQc+fDsM6RfFjch8EUd125yvRe
|
|
34
|
+
ab0Xx0Rsvj2/Z63HLArC6rESIzZVpt4FAOBlCzOtMJEC9SMBMM7+sbMbwRxoTCKj
|
|
35
|
+
VmHj3sRQB3mQj4qN3dd241Ea4y2eTa/mML8gvkx84jAYr/nmQc8tRV64bnp2G01a
|
|
36
|
+
w7Z+7EzJFzhHpXYm4QBYR+qb81pB/ZX0LWtVs/2jjCWoCOOdIuH/jh+DzQk4Qhby
|
|
37
|
+
R02xW5SGXEOiylE3Q9SDqGfvomcQ8ENDYts=
|
|
37
38
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
39
|
+
date: 2022-07-31 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.3.7
|
|
68
68
|
signing_key:
|
|
69
69
|
specification_version: 4
|
|
70
70
|
summary: Generates XML, by producing an array of raw XML elements which can parsed
|
metadata.gz.sig
CHANGED
|
Binary file
|