polyrex-objects 0.7.10 → 0.8.0

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
  SHA1:
3
- metadata.gz: 72f503d7863321fe795d5b313cb6e419fb8d2e86
4
- data.tar.gz: d58c45be59880853f71c6b7483313c0a1cd810de
3
+ metadata.gz: 938c943b17c79b6cce510fb7b3a1f3d91f3325e2
4
+ data.tar.gz: 41c1271c95f4b366fe738dd9ad8f26ec9b13c8ee
5
5
  SHA512:
6
- metadata.gz: 0b80d4d432164e99dad3679fe1917b44157bf83f6e287952635d5132895ab894e6da1171ef0da6954666c059316723add45938cdc01e5ab2141ca127ca6958e2
7
- data.tar.gz: bc0aa1579047a5758af253968c206b936e93f0c906a6f50a754777b1d878798d957e7c193aafdb05e0a178c06086f38c8a28ff8ebfbae6a4b20d5358fe3a8123
6
+ metadata.gz: 11b2cadddffeef0a1a7ad1fa510b2e81fc4836908c1e1448a70119f449955d24f7e855885c7a761e5215ada38997a5e1ff8ea5474cc043c1b562994294ac74f4
7
+ data.tar.gz: ca9ace6a2501f35eb57493f6d3ddd6322c538fba01052643876d38dc66b615342b42898c70ceb3f262facbb7f1f1d147cbb461f1784c70771b9d794b9088785e
checksums.yaml.gz.sig CHANGED
Binary file
@@ -134,6 +134,7 @@ EOF
134
134
 
135
135
  @node = node
136
136
  @@id = id
137
+ @schema = schema
137
138
 
138
139
  if schema then
139
140
 
@@ -143,49 +144,18 @@ EOF
143
144
 
144
145
  a.each do |x|
145
146
 
146
- name, raw_fields = x.split('[')
147
-
148
- if raw_fields then
149
- fields = raw_fields.chop.split(',').map &:strip
150
- @class_names << name.capitalize
151
-
152
- classx = []
153
- classx << "class #{name.capitalize} < PolyrexObject"
154
- classx << "def initialize(node=nil, id='0')"
155
- classx << " node ||= Rexle.new('<#{name}><summary/><records/></#{name}>').root"
156
- classx << " super(node,id)"
157
-
158
- classx << " a = node.xpath('summary/*',&:name)"
159
- classx << " yaml_fields = a - (#{fields} + %w(format_mask))"
160
- classx << "yaml_fields.each do |field|"
161
- classx << %q(instance_eval "def #{field}; YAML.load(@node.element('summary/#{field}/text()')); end")
162
- classx << "end"
163
-
164
- classx << "@fields = %i(#{fields.join(' ')})"
165
- classx << "@create = PolyrexCreateObject.new('#{schema}', @@id)"
166
- classx << "end"
167
-
168
- fields.each do |field|
169
- classx << "def #{field}"
170
- classx << " if @node.element('summary/#{field}').nil? then"
171
- classx << " @node.element('summary').add Rexle::Element.new('#{field}')"
172
- classx << " end"
173
- classx << " node = @node.element('summary/#{field}/text()')"
174
- classx << " node ? node.clone : ''"
175
- classx << "end"
176
- classx << "def #{field}=(text)"
177
- classx << " if @node.element('summary/#{field}').nil? then"
178
- classx << " @node.element('summary').add Rexle::Element.new('#{field}', text)"
179
- classx << " else"
180
- classx << " @node.element('summary/#{field}').text = text"
181
- classx << " end"
182
- classx << "end"
183
- end
184
-
185
- classx << "end"
147
+ r = x[/[^\{]+(?=\})/]
186
148
 
187
- eval classx.join("\n")
149
+ if r then
150
+ r.split(/\s*;\s*/).each do |s|
151
+ name, raw_fields = s.split('[')
152
+ make_class(name, raw_fields)
153
+ end
154
+ else
155
+ name, raw_fields = x.split('[')
156
+ make_class(name, raw_fields)
188
157
  end
158
+
189
159
  end
190
160
 
191
161
  if @class_names.length < 2 then
@@ -214,6 +184,61 @@ EOF
214
184
  end
215
185
  end
216
186
 
187
+ def to_a
188
+ @class_names.map {|x| eval(x)}
189
+ end
190
+
191
+ def to_h
192
+ Hash[self.to_a.map {|x| [x.name[/\w+$/], x]}]
193
+ end
194
+
195
+ private
196
+
197
+ def make_class(name, raw_fields)
198
+
199
+ if raw_fields then
200
+ fields = raw_fields.chop.split(',').map &:strip
201
+ @class_names << name.capitalize
202
+
203
+ classx = []
204
+ classx << "class #{name.capitalize} < PolyrexObject"
205
+ classx << "def initialize(node=nil, id='0')"
206
+ classx << " node ||= Rexle.new('<#{name}><summary/><records/></#{name}>').root"
207
+ classx << " super(node,id)"
208
+
209
+ classx << " a = node.xpath('summary/*',&:name)"
210
+ classx << " yaml_fields = a - (#{fields} + %w(format_mask))"
211
+ classx << "yaml_fields.each do |field|"
212
+ classx << %q(instance_eval "def #{field}; YAML.load(@node.element('summary/#{field}/text()')); end")
213
+ classx << "end"
214
+
215
+ classx << "@fields = %i(#{fields.join(' ')})"
216
+ classx << "@create = PolyrexCreateObject.new('#{@schema}', @@id)"
217
+ classx << "end"
218
+
219
+ fields.each do |field|
220
+ classx << "def #{field}"
221
+ classx << " if @node.element('summary/#{field}').nil? then"
222
+ classx << " @node.element('summary').add Rexle::Element.new('#{field}')"
223
+ classx << " end"
224
+ classx << " node = @node.element('summary/#{field}/text()')"
225
+ classx << " node ? node.clone : ''"
226
+ classx << "end"
227
+ classx << "def #{field}=(text)"
228
+ classx << " if @node.element('summary/#{field}').nil? then"
229
+ classx << " @node.element('summary').add Rexle::Element.new('#{field}', text)"
230
+ classx << " else"
231
+ classx << " @node.element('summary/#{field}').text = text"
232
+ classx << " end"
233
+ classx << "end"
234
+ end
235
+
236
+ classx << "end"
237
+
238
+ eval classx.join("\n")
239
+ end
240
+ end
241
+
217
242
  def make_def_records(class_name, i=0)
218
243
 
219
244
  eval "#{class_name}.class_eval {
@@ -255,13 +280,6 @@ EOF
255
280
 
256
281
  end
257
282
 
258
- def to_a
259
- @class_names.map {|x| eval(x)}
260
- end
261
-
262
- def to_h
263
- Hash[self.to_a.map {|x| [x.name[/\w+$/], x]}]
264
- end
265
-
283
+
266
284
 
267
285
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  C0ZUhP8IAGCVW8QD8AfZ/AgqUdh+zTRqKdhEyhXCjYyVXqNHnD02NbyGmQvgd9SD
32
32
  XfuuGzQ3E4Mh5w==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-06-29 00:00:00.000000000 Z
34
+ date: 2014-07-19 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: polyrex-createobject
@@ -39,20 +39,20 @@ dependencies:
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0.4'
42
+ version: '0.5'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 0.4.15
45
+ version: 0.5.2
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.4'
52
+ version: '0.5'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.4.15
55
+ version: 0.5.2
56
56
  description:
57
57
  email: james@r0bertson.co.uk
58
58
  executables: []
@@ -72,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 2.1.2
75
+ version: 2.1.0
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
metadata.gz.sig CHANGED
Binary file