rexle-builder 1.0.1 → 1.0.4
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 +1 -1
- data/lib/rexle-builder.rb +92 -56
- 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: d6c908421b55a41fe3988edff4238b011358ba5b78440036593ebf4b5ff65bb7
|
4
|
+
data.tar.gz: 150737d9be007c7c9d48fe30be8f606efe2b66bb3bfcbb69f3ea18b298cded1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29db012b7fcd96b56a5490afda250c9f7791c1d8354f0de0a66f40c4bf57689d130ca9db6077242a624af0882f61904c0ea77e186df480fe1194519bdadd398f
|
7
|
+
data.tar.gz: a56a35dd95093c7545bed8b7e2f5c9584947ccef4348fe2a5ccddc612167c89165dca45a79f1daa4a10dd12fb6998f5f33cbff428fe4bf23dcda58280947765c
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
E*�56����
|
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,127 @@ 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
|
-
|
56
|
-
value = args.
|
57
|
-
|
58
|
-
|
55
|
+
|
56
|
+
value = args.find {|x| x.is_a? String} || ''
|
57
|
+
attributes, obj = args.select {|x| x.is_a? Hash}
|
58
|
+
|
59
|
+
# The obj is an optional Hash object used to build nested XML
|
59
60
|
# after the current element
|
60
|
-
|
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
|
+
@current_a.concat r if r.is_a? Array
|
107
|
+
puts '@current_a ' + @current_a.inspect if @debug
|
108
|
+
@current_a = prev_a
|
109
|
+
return @a.first
|
110
|
+
|
100
111
|
end
|
101
|
-
|
102
|
-
|
112
|
+
|
113
|
+
#@a.first
|
114
|
+
nil
|
103
115
|
end
|
104
|
-
|
116
|
+
|
105
117
|
private
|
106
|
-
|
118
|
+
|
107
119
|
# build from a Hash object
|
108
120
|
#
|
109
121
|
def buildx( h)
|
110
122
|
|
111
|
-
h.
|
123
|
+
puts 'buildx: ' + h.inspect if @debug
|
124
|
+
# the following statement prevents duplicate elements where 1 key is
|
125
|
+
# represented by a String and the other by a symbol.
|
126
|
+
#
|
127
|
+
h2 = h.map {|x| [x[0].to_sym, x[1]]}.to_h
|
128
|
+
|
129
|
+
h2.each_pair do |key, value|
|
112
130
|
|
113
131
|
if value.is_a? Hash then
|
114
|
-
|
115
|
-
self.send(key.to_sym) do
|
132
|
+
puts 'buildx found Hash' + value.inspect if @debug
|
133
|
+
self.send(key.to_sym) do
|
116
134
|
buildx value
|
135
|
+
nil
|
117
136
|
end
|
118
|
-
|
119
|
-
elsif value.is_a?
|
120
|
-
|
137
|
+
|
138
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
139
|
+
|
140
|
+
puts 'buildx found Array' + value.inspect if @debug
|
141
|
+
puts 'key:' + key.inspect if @debug
|
142
|
+
|
121
143
|
self.send(key.to_sym) do
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
144
|
+
|
145
|
+
r2= []
|
146
|
+
value.each do |x|
|
147
|
+
|
148
|
+
if x.is_a? Hash then
|
149
|
+
puts 'x:' + x.inspect if @debug
|
150
|
+
buildx x
|
151
|
+
nil
|
152
|
+
else
|
153
|
+
puts 'x2:' + x.inspect if @debug
|
154
|
+
r2 << x
|
155
|
+
end
|
156
|
+
|
127
157
|
end
|
128
|
-
|
158
|
+
|
159
|
+
r2
|
129
160
|
end
|
130
|
-
|
161
|
+
|
131
162
|
else
|
132
|
-
|
133
|
-
|
134
|
-
|
163
|
+
|
164
|
+
puts 'buildx found other' + value.inspect if @debug
|
165
|
+
if value.is_a? String then
|
166
|
+
self.send(key.to_sym, value.to_s)
|
167
|
+
else
|
168
|
+
self.send(key.to_sym) {[value]}
|
169
|
+
end
|
170
|
+
|
135
171
|
end
|
136
172
|
end
|
137
173
|
|
138
|
-
end
|
174
|
+
end
|
139
175
|
|
140
176
|
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.4
|
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
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTIyMDcyNDE5NTI0N1oXDTIzMDcyNDE5NTI0N1owSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
|
18
|
+
ggGBAPcD/W+g9XKq4ugEgFrJ0o3aMpOPQPMMTQYMqPdadoRFsCqj32619ryDKWrr
|
19
|
+
5U1T3cf/I9Y/6Qh8sKKbdmqX8+H/hd5YgppWnPRjcThEAiR04Cek9MGH0I4qgztB
|
20
|
+
dNaanZNqeFWj3gPuAJq27wzOyPAzltnCeG2BW9hF6ZnDytfXFCv29Mtjhd+ZnLYu
|
21
|
+
/vCl7BVB8STrDEFz0IUACWZpBI7kfnKOiwUf97Akx24qWu8sVYovoxl5IwssG4Zb
|
22
|
+
Y3SYJRnMt+VpDj0NfMEJ3z6gsz+71dUrGfJgzra3xASpZfO1UnsJ2Y6r+CClFOkt
|
23
|
+
2j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ts=
|
37
38
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
39
|
+
date: 2022-07-24 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
|