rexle-builder 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 492edd3887ea1741d4024c90f698659c401ee65083960f91e5846dd4916f11b1
4
- data.tar.gz: e4faa2914d561ba4a896a39a78634368cd93f3bd644b0071fc2b86a6d544c427
3
+ metadata.gz: d6c908421b55a41fe3988edff4238b011358ba5b78440036593ebf4b5ff65bb7
4
+ data.tar.gz: 150737d9be007c7c9d48fe30be8f606efe2b66bb3bfcbb69f3ea18b298cded1b
5
5
  SHA512:
6
- metadata.gz: b78105a25b08b860de82960c0e2bcee2bb0434d09f97c8a2748e67402c782cc0b57f0127164bf87128470e52fdd2b139ae677a1f8610afebe7f9404b5239b293
7
- data.tar.gz: 0ee549658fefba3984efa121632e3fc6ea7a9d85979fa4e172c360eb6b8cea934474c2abca8f2389ffde4b85fdfc3c2899a066565d9204d8a05e1b4cd16a4ab0
6
+ metadata.gz: 29db012b7fcd96b56a5490afda250c9f7791c1d8354f0de0a66f40c4bf57689d130ca9db6077242a624af0882f61904c0ea77e186df480fe1194519bdadd398f
7
+ data.tar.gz: a56a35dd95093c7545bed8b7e2f5c9584947ccef4348fe2a5ccddc612167c89165dca45a79f1daa4a10dd12fb6998f5f33cbff428fe4bf23dcda58280947765c
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,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
-
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
- @current_a.concat r if r.class == RexleArray
98
- @current_a = prev_a
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
- @a.first
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
-
111
- # the following statement prevents duplicate elements where 1 key is
122
+
123
+ puts 'buildx: ' + h.inspect if @debug
124
+ # the following statement prevents duplicate elements where 1 key is
112
125
  # represented by a String and the other by a symbol.
113
126
  #
114
127
  h2 = h.map {|x| [x[0].to_sym, x[1]]}.to_h
115
-
128
+
116
129
  h2.each_pair do |key, value|
117
130
 
118
131
  if value.is_a? Hash then
119
-
120
- self.send(key.to_sym) do
132
+ puts 'buildx found Hash' + value.inspect if @debug
133
+ self.send(key.to_sym) do
121
134
  buildx value
135
+ nil
122
136
  end
123
-
124
- elsif value.is_a? Array
125
-
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
+
126
143
  self.send(key.to_sym) do
127
-
128
- if value.first.is_a? Hash then
129
- value.map {|x| buildx x}
130
- else
131
- RexleArray.new value
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
+
132
157
  end
133
-
158
+
159
+ r2
134
160
  end
135
-
161
+
136
162
  else
137
-
138
- self.send(key.to_sym, value.to_s)
139
-
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
+
140
171
  end
141
172
  end
142
173
 
143
- end
174
+ end
144
175
 
145
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.3
4
+ version: 1.0.4
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
- MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNTAxMTgyMTU4WhcN
15
- MjEwNTAxMTgyMTU4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDXvcGF
17
- KAsFoSJW5WibJ3BCxoe5RyUNGARFsSo+Y755n9YmTEoL9jCNkxHCyZAPJSXeZJlV
18
- jM1LqYD6n9MW73o0B7vy9Rq1n49cWIliXYrkIvhLlS7qviVg+ij8/o36LVeK4/4d
19
- Z5d+jRyr6tovVn6Hlqs8qoMdI4lOj1f3yb2kFhbkW2Zx/O+4TMFvQT5/pc0/JcMM
20
- b4SjzEZ8/aamSpjBNCIfML4pu2NNIaD/Zt8fLAa8kXGxCG47YP1rrnPuggz5YaOh
21
- 0AgC4f2EKjfBqGcmgQ4QHOZ4GLf5pLPdILZk6dwCE6nwg3ML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GSIb3DQEBCwUAA4IBgQANTkbRlCnyKnC93YfSYYZZIY2yG3w4
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: 2021-02-24 00:00:00.000000000 Z
39
+ date: 2022-07-24 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
- rubyforge_project:
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