polyrex-createobject 0.6.1 → 0.7.0
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.tar.gz.sig +0 -0
- data/lib/polyrex-createobject.rb +36 -27
- metadata +6 -6
- 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: d775e35504720ac98162324d077add3f9c101513
|
4
|
+
data.tar.gz: 950c2cdce548c151d1962c86bdd5650e4e375755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d044f58eb656f6a392389d72b02620f60a5f428a7a4cdecefd603f19b2ba98fc3b783a159dc3ed6e58c4475bb53aa25864bd794b1c02a61800d881695b655f
|
7
|
+
data.tar.gz: 4e06f448472dbd830ed41ed0ce5d628a9a7bff4868f9b2012143995f6abe3a6619f85011c244f6843b18b3ab85c1d49ee661e1abf022f2caa2fe3f9f9030ea7c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/polyrex-createobject.rb
CHANGED
@@ -13,27 +13,40 @@ class PolyrexCreateObject
|
|
13
13
|
attr_reader :obj
|
14
14
|
|
15
15
|
|
16
|
-
def initialize(schema, id:
|
16
|
+
def initialize(schema=nil, id: nil, order: 'ascending', record: nil,
|
17
|
+
debug: false)
|
17
18
|
|
18
|
-
|
19
|
+
@order = order.to_s
|
20
|
+
@id = id
|
19
21
|
|
22
|
+
if @debug then
|
23
|
+
puts 'inside PolyrexCreateObject: record: ' + record.xml.inspect
|
24
|
+
puts 'record.text' + record.text('summary/schema')
|
25
|
+
end
|
26
|
+
|
27
|
+
@parent_node = record ? record.element('records') : record
|
28
|
+
schema = record.text('summary/schema')
|
29
|
+
puts ': schema: ' + schema.inspect if @debug
|
20
30
|
raise "missing schema" unless schema
|
21
31
|
|
22
|
-
@schema = schema[/\/(.*)$/,1]
|
23
32
|
|
33
|
+
@schema = schema =~ /\// ? schema[/\/(.*)$/,1] : schema
|
34
|
+
|
24
35
|
a = PolyrexSchema.new(schema).to_a
|
25
|
-
|
36
|
+
puts 'a: ' + a.inspect if @debug
|
37
|
+
|
26
38
|
a.each do |rec|
|
27
39
|
|
28
40
|
@obj = attach_create_handlers(rec)
|
29
|
-
|
41
|
+
puts '@obj: ' + @obj.inspect if @debug
|
42
|
+
|
30
43
|
@obj.class_eval do
|
31
44
|
def record=(node)
|
32
45
|
@parent_node = node
|
33
46
|
end
|
34
47
|
end
|
35
48
|
|
36
|
-
self.instance_eval %Q( def #{@obj.name.downcase}(h={}, id
|
49
|
+
self.instance_eval %Q( def #{@obj.name.downcase}(h={}, id=@id, &blk)
|
37
50
|
|
38
51
|
local_schema = @schema
|
39
52
|
|
@@ -43,24 +56,20 @@ class PolyrexCreateObject
|
|
43
56
|
local_schema[/\\/.*$/].to_s]
|
44
57
|
end
|
45
58
|
|
46
|
-
new_parent = create_node(@parent_node, local_schema, h, id)
|
47
|
-
|
48
|
-
obj = @obj.new
|
49
|
-
obj.record = new_parent
|
50
|
-
obj.instance_variable_set(:@schema, @schema[/\\/(.*$)/,1])
|
59
|
+
new_parent = create_node(@parent_node, local_schema, h, id)
|
51
60
|
|
52
61
|
if block_given? then
|
53
|
-
|
62
|
+
yield(PolyrexCreateObject.new(id: id, record: new_parent))
|
54
63
|
else
|
55
|
-
|
64
|
+
self
|
56
65
|
end
|
57
66
|
end
|
58
67
|
)
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
62
|
-
def id=(s)
|
63
|
-
def id()
|
71
|
+
def id=(s) @id = s; self end
|
72
|
+
def id() @id end
|
64
73
|
|
65
74
|
def record=(node)
|
66
75
|
@parent_node = node
|
@@ -87,16 +96,16 @@ class PolyrexCreateObject
|
|
87
96
|
record.root.xpath('records/*').each(&:delete)
|
88
97
|
|
89
98
|
if id then
|
90
|
-
|
99
|
+
@id.succ!
|
91
100
|
else
|
92
|
-
if
|
93
|
-
|
101
|
+
if @id.to_i.to_s == @id.to_s then
|
102
|
+
@id.succ!
|
94
103
|
else
|
95
|
-
|
104
|
+
@id = @parent_node.element('count(//@id)').to_i + 2
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
99
|
-
record.root.add_attribute({'id' =>
|
108
|
+
record.root.add_attribute({'id' => @id.to_s.clone})
|
100
109
|
|
101
110
|
if params.length > 0 then
|
102
111
|
a = child_schema[/[^\[]+(?=\])/].split(',')
|
@@ -142,12 +151,12 @@ class PolyrexCreateObject
|
|
142
151
|
record.root.xpath('records/*').each(&:delete)
|
143
152
|
|
144
153
|
if id then
|
145
|
-
|
154
|
+
@id.succ!
|
146
155
|
else
|
147
|
-
if
|
148
|
-
|
156
|
+
if @id.to_i.to_s == @id.to_s then
|
157
|
+
@id.succ!
|
149
158
|
else
|
150
|
-
|
159
|
+
@id = @parent_node.element('count(//@id)').to_i + 1
|
151
160
|
end
|
152
161
|
end
|
153
162
|
|
@@ -169,7 +178,7 @@ class PolyrexCreateObject
|
|
169
178
|
|
170
179
|
define_method cname do |h, id=nil, &blk|
|
171
180
|
|
172
|
-
id ||=
|
181
|
+
id ||= @id
|
173
182
|
|
174
183
|
local_schema = @parent_node.parent.text('summary/schema')[/\/(.*$)/,1]
|
175
184
|
|
@@ -217,7 +226,7 @@ class PolyrexCreateObject
|
|
217
226
|
|
218
227
|
define_method remaining.name.downcase.to_sym do |h, id=nil, &blk|
|
219
228
|
|
220
|
-
id ||=
|
229
|
+
id ||= @id
|
221
230
|
local_schema = @parent_node.parent.text('summary/schema')[/\/(.*$)/,1]
|
222
231
|
if local_schema[0] == '{' then
|
223
232
|
|
@@ -246,4 +255,4 @@ class PolyrexCreateObject
|
|
246
255
|
return klass
|
247
256
|
end
|
248
257
|
|
249
|
-
end
|
258
|
+
end
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
jRgMXtv8iLFoWeilpwsM5UFNluVBef95Iw6oXMaxdoZaPfZ8KSp+IJe1ct8JNDmi
|
32
32
|
1uMwHDSm6dYjQA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2018-03-29 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: polyrex-schema
|
@@ -39,20 +39,20 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
42
|
+
version: '0.5'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.5.1
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
52
|
+
version: '0.5'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.5.1
|
56
56
|
description:
|
57
57
|
email: james@jamesrobertson.eu
|
58
58
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|