polyrex-createobject 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/lib/polyrex-createobject.rb +46 -32
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e20a75456b2321ccb733f539cefc23d9c84952c
|
4
|
+
data.tar.gz: b9324027feb7cb1721163f4d922b906302c4b6c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65b8663f71586026030076b26c40916bf44e52bf3b0c51fb546c0388808696496cd8b4a904d733a889fcfff90daa081dd772c932b65e28e2b343607fa8f3375
|
7
|
+
data.tar.gz: 5df50d34eb25ac11fcf1072c62208927361ae2be1085d4d0031c77f0509f8f77f18db1e9dc5637d477246d41bc4100ee9ea1a6821455067c7c29439792d0efb0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�Tfc��M�֔.m�!�� l;4�B�/�?�/����ÄL�aj�-�a�����SxS�zxZC�"��<�c�
|
2
|
+
�7�[��d�5d���73k����W���Q�-��)�p�4�NT������~Ǽk,�������;�aܿ��c��e��� 7 "�$6i�0�J����>5j�<����T�4뼶��2E�U�O��.B���8|g��8��������|�4<�X�DO��o��M�to��q�G}I7��s
|
data/lib/polyrex-createobject.rb
CHANGED
@@ -37,7 +37,6 @@ class PolyrexCreateObject
|
|
37
37
|
obj.record = new_parent
|
38
38
|
obj.instance_variable_set(:@schema, @schema[/\\/(.*$)/,1])
|
39
39
|
|
40
|
-
|
41
40
|
if block_given? then
|
42
41
|
blk.call obj
|
43
42
|
else
|
@@ -59,8 +58,14 @@ class PolyrexCreateObject
|
|
59
58
|
|
60
59
|
def attach_create_handlers(a)
|
61
60
|
|
61
|
+
#return if PolyrexCreateObject
|
62
62
|
class_name = "root".capitalize
|
63
|
-
parent_klass =
|
63
|
+
parent_klass = if ObjectSpace.each_object(Class)\
|
64
|
+
.to_a.map(&:name).include? 'Root' then
|
65
|
+
Root
|
66
|
+
else
|
67
|
+
parent_klass = Object.const_set(class_name,Class.new)
|
68
|
+
end
|
64
69
|
result = scan parent_klass, a
|
65
70
|
end
|
66
71
|
|
@@ -95,7 +100,7 @@ class PolyrexCreateObject
|
|
95
100
|
|
96
101
|
def scan(parent, list)
|
97
102
|
|
98
|
-
|
103
|
+
cname = list.shift
|
99
104
|
args = list
|
100
105
|
|
101
106
|
r = []
|
@@ -103,46 +108,53 @@ class PolyrexCreateObject
|
|
103
108
|
fields = []
|
104
109
|
fields << args.shift while args.first.is_a? Symbol
|
105
110
|
|
106
|
-
class_name =
|
107
|
-
klass = Object.const_set(class_name,Class.new)
|
111
|
+
class_name = cname.capitalize
|
108
112
|
|
109
|
-
|
113
|
+
klass = if ObjectSpace.each_object(Class)\
|
114
|
+
.to_a.map(&:name).include? class_name.to_s then
|
115
|
+
Object.const_get class_name
|
116
|
+
else
|
117
|
+
Object.const_set(class_name,Class.new)
|
118
|
+
end
|
110
119
|
|
111
|
-
|
120
|
+
parent.class_eval do
|
112
121
|
|
113
|
-
|
114
|
-
|
122
|
+
define_method :create_node do |parent_node, child_schema,
|
123
|
+
params={}, id=nil|
|
115
124
|
|
116
|
-
|
117
|
-
|
118
|
-
else
|
119
|
-
if @@id.to_i.to_s == @@id.to_s then
|
120
|
-
@@id.succ!
|
121
|
-
else
|
122
|
-
@@id = @parent_node.element('count(//@id)').to_i + 2
|
123
|
-
end
|
124
|
-
end
|
125
|
+
buffer = PolyrexSchema.new(child_schema[/^[^\/]+/]).to_s
|
126
|
+
record = Rexle.new buffer
|
125
127
|
|
126
|
-
|
128
|
+
if id then
|
129
|
+
@@id.succ!
|
130
|
+
else
|
131
|
+
if @@id.to_i.to_s == @@id.to_s then
|
132
|
+
@@id.succ!
|
133
|
+
else
|
134
|
+
@@id = @parent_node.element('count(//@id)').to_i + 2
|
135
|
+
end
|
136
|
+
end
|
127
137
|
|
128
|
-
|
138
|
+
record.root.add_attribute({'id' => @@id.to_s.clone})
|
129
139
|
|
130
|
-
|
131
|
-
a.each do |field_name|
|
132
|
-
field = summary.element(field_name.strip)
|
133
|
-
field.text = params[field_name.strip.to_sym]
|
134
|
-
end
|
140
|
+
a = child_schema[/[^\[]+(?=\])/].split(',')
|
135
141
|
|
136
|
-
|
142
|
+
summary = record.root.element('summary')
|
143
|
+
a.each do |field_name|
|
144
|
+
field = summary.element(field_name.strip)
|
145
|
+
field.text = params[field_name.strip.to_sym]
|
146
|
+
end
|
137
147
|
|
138
|
-
|
148
|
+
parent_node.add record.root
|
139
149
|
|
150
|
+
end # end of define_method :create_node
|
140
151
|
|
141
|
-
define_method
|
152
|
+
define_method cname do |h, id=nil, &blk|
|
142
153
|
|
143
154
|
id ||= @@id
|
144
|
-
local_schema = "%s[%s]" % [
|
145
|
-
new_parent = create_node(@parent_node, local_schema, h, id)
|
155
|
+
local_schema = "%s[%s]" % [cname, fields.join(',')]
|
156
|
+
new_parent = create_node(@parent_node, local_schema, h, id)\
|
157
|
+
.element('records')
|
146
158
|
|
147
159
|
obj = klass.new
|
148
160
|
|
@@ -167,6 +179,7 @@ class PolyrexCreateObject
|
|
167
179
|
next_rec = args.shift
|
168
180
|
|
169
181
|
if next_rec.first.is_a? Array then
|
182
|
+
|
170
183
|
remaining = scan(parent, *args) unless args.length < 1
|
171
184
|
|
172
185
|
next_rec.each do |x|
|
@@ -182,8 +195,8 @@ class PolyrexCreateObject
|
|
182
195
|
id ||= @@id
|
183
196
|
local_schema = "%s[%s]" % [record, fields.join(',')]
|
184
197
|
|
185
|
-
new_parent = create_node(@parent_node, local_schema,
|
186
|
-
|
198
|
+
new_parent = create_node(@parent_node, local_schema,
|
199
|
+
params, id).element('records')
|
187
200
|
obj = remaining.new
|
188
201
|
obj.record = new_parent
|
189
202
|
yield obj
|
@@ -195,6 +208,7 @@ class PolyrexCreateObject
|
|
195
208
|
end
|
196
209
|
|
197
210
|
else
|
211
|
+
|
198
212
|
remaining = scan(klass, *list) unless args.length < 1
|
199
213
|
scan(klass, next_rec)
|
200
214
|
scan(r, remaining) if remaining
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex-createobject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
f3O5lCaUfMDZbRHRyvXjy/4PFRQKLr6ZLbpQN+dWceS6/82/5xWEL/7Bo/86R5xN
|
32
32
|
JL6pGH//inbMWQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-06-
|
34
|
+
date: 2014-06-22 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: polyrex-schema
|
metadata.gz.sig
CHANGED
Binary file
|