rexle-builder 1.0.2 → 1.0.5
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 +98 -54
- data.tar.gz.sig +0 -0
- metadata +29 -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: ff62c53e5a7dd2775aa78650ebdc6bafeec01f666af4c0f88cd4ea85ddc407d2
|
|
4
|
+
data.tar.gz: b2b64bb339c75f2082d3be69675c4e9bf871df5a4b2d0aaf1dca4c2a1fe1c9c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd689817a5975e66798398cfb361dba7d25cef704c97078c4a23f00b8cfb1fd6915172a809cc692bf7b3983372bbb9c722bb870bc2d2e6382f35736cb1ade03b
|
|
7
|
+
data.tar.gz: 47707186dbe3b2bf49b26418f2c44a0ad30dfd3bee5c5814a36e21d2956355b7e18016330ce77b80271f10efeb608153f67b7bf4339cd64ba33a99d8f356e061
|
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,91 +50,135 @@ 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
|
+
|
|
100
|
+
if @debug then
|
|
101
|
+
puts 'r: ' + r.inspect
|
|
102
|
+
puts 'r.class: ' + r.class.inspect
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
return r if r == @a.first
|
|
106
|
+
|
|
107
|
+
if r.is_a? Array then
|
|
108
|
+
|
|
109
|
+
# only concat if r contains raw Rexle elements.
|
|
110
|
+
if r.all? {|field, attributes, value| attributes.is_a? Hash} then
|
|
111
|
+
@current_a.concat r
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
puts '@current_a ' + @current_a.inspect if @debug
|
|
116
|
+
@current_a = prev_a
|
|
117
|
+
return @a.first
|
|
118
|
+
|
|
100
119
|
end
|
|
101
|
-
|
|
102
|
-
|
|
120
|
+
|
|
121
|
+
#@a.first
|
|
122
|
+
nil
|
|
103
123
|
end
|
|
104
|
-
|
|
124
|
+
|
|
105
125
|
private
|
|
106
|
-
|
|
126
|
+
|
|
107
127
|
# build from a Hash object
|
|
108
128
|
#
|
|
109
129
|
def buildx( h)
|
|
110
130
|
|
|
111
|
-
h.
|
|
131
|
+
puts 'buildx: ' + h.inspect if @debug
|
|
132
|
+
# the following statement prevents duplicate elements where 1 key is
|
|
133
|
+
# represented by a String and the other by a symbol.
|
|
134
|
+
#
|
|
135
|
+
h2 = h.map {|x| [x[0].to_sym, x[1]]}.to_h
|
|
136
|
+
|
|
137
|
+
h2.each_pair do |key, value|
|
|
112
138
|
|
|
113
139
|
if value.is_a? Hash then
|
|
114
|
-
|
|
115
|
-
self.send(key.to_sym) do
|
|
140
|
+
puts 'buildx found Hash' + value.inspect if @debug
|
|
141
|
+
self.send(key.to_sym) do
|
|
116
142
|
buildx value
|
|
143
|
+
nil
|
|
117
144
|
end
|
|
118
|
-
|
|
119
|
-
elsif value.is_a?
|
|
120
|
-
|
|
145
|
+
|
|
146
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
|
147
|
+
|
|
148
|
+
puts 'buildx found Array' + value.inspect if @debug
|
|
149
|
+
puts 'key:' + key.inspect if @debug
|
|
150
|
+
|
|
121
151
|
self.send(key.to_sym) do
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
152
|
+
|
|
153
|
+
r2= []
|
|
154
|
+
value.each do |x|
|
|
155
|
+
|
|
156
|
+
if x.is_a? Hash then
|
|
157
|
+
puts 'x:' + x.inspect if @debug
|
|
158
|
+
buildx x
|
|
159
|
+
nil
|
|
160
|
+
else
|
|
161
|
+
puts 'x2:' + x.inspect if @debug
|
|
162
|
+
r2 << x
|
|
163
|
+
end
|
|
164
|
+
|
|
127
165
|
end
|
|
128
|
-
|
|
166
|
+
|
|
167
|
+
r2
|
|
129
168
|
end
|
|
130
|
-
|
|
169
|
+
|
|
131
170
|
else
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
171
|
+
|
|
172
|
+
puts 'buildx found other' + value.inspect if @debug
|
|
173
|
+
if value.is_a? String then
|
|
174
|
+
self.send(key.to_sym, value.to_s)
|
|
175
|
+
else
|
|
176
|
+
self.send(key.to_sym) {[value]}
|
|
177
|
+
end
|
|
178
|
+
|
|
135
179
|
end
|
|
136
180
|
end
|
|
137
181
|
|
|
138
|
-
end
|
|
182
|
+
end
|
|
139
183
|
|
|
140
184
|
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.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -10,35 +10,36 @@ 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
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
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+
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
|
-
email:
|
|
42
|
+
email: digital.robertson@gmail.com
|
|
42
43
|
executables: []
|
|
43
44
|
extensions: []
|
|
44
45
|
extra_rdoc_files: []
|
|
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
63
64
|
- !ruby/object:Gem::Version
|
|
64
65
|
version: '0'
|
|
65
66
|
requirements: []
|
|
66
|
-
rubygems_version: 3.
|
|
67
|
+
rubygems_version: 3.3.7
|
|
67
68
|
signing_key:
|
|
68
69
|
specification_version: 4
|
|
69
70
|
summary: Generates XML, by producing an array of raw XML elements which can parsed
|
metadata.gz.sig
CHANGED
|
Binary file
|