polyrex 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/polyrex.rb +163 -159
  4. data.tar.gz.sig +0 -0
  5. metadata +32 -31
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d41c1df7395c2dcc010153902223cf24fd73e40df7e4760fd52c3a1a2e1001d
4
- data.tar.gz: d45fbf80463978ca670db7f83c0a5d52072fee396dc9585bc220c2509a279dc2
3
+ metadata.gz: a1978a70b476b92c72bcb490c7c1b168b535752e3591970b03423d6e9d3b7140
4
+ data.tar.gz: 9a5dd6e79a45640dafaac87b9bd1379d268a93e343c196a445741c01310d2d9d
5
5
  SHA512:
6
- metadata.gz: b7688c1faacb46605abda5ea71faa119b5f7ca5ab497b366424dd96c0c723b6c23d7c426cf1c23a3c98654346b4dcd5728595174f8a15b177295cc353dd2737c
7
- data.tar.gz: 0db28f418693178a88708b7bcf1cb838a2e7d37437196638a0e327de8140bfea60c11c544454669d4aed8d7ba8f6a03df2b6a366a2d96a39535f3fea5f6228e7
6
+ metadata.gz: 69e4fe133cbf2ad21bf10dd10f4782b1f5188e924badf674d25919ad05c05052874b9cdfddc664985cc0acf8347551dc942b93a49f01e30614dfa52608036a87
7
+ data.tar.gz: e95176d1d9f367173a47ea801722da65dd828e320dc62b22c127e953872f36ee2571cba5b9d6a15b1358a700e2ccff0e02b2792d0739d3a4ac112579bc739985
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/polyrex.rb CHANGED
@@ -41,7 +41,7 @@ end
41
41
  class Polyrex
42
42
  include RXFReadWriteModule
43
43
 
44
- attr_accessor :summary_fields, :xslt_schema, :id_counter,
44
+ attr_accessor :summary_fields, :xslt_schema, :id_counter,
45
45
  :schema, :type, :delimiter, :xslt, :format_masks
46
46
 
47
47
  def initialize(location=nil, schema: nil, id_counter: '1',
@@ -50,13 +50,13 @@ class Polyrex
50
50
  @id_counter, @debug = id_counter, debug
51
51
  @format_masks = []
52
52
 
53
- self.method(:schema=).call(schema) if schema
54
-
55
- if location then
53
+ self.method(:schema=).call(schema) if schema
54
+
55
+ if location then
56
56
 
57
57
  s, type = RXFReader.read(location)
58
58
  return import(s) if s =~ /^\<\?polyrex\b/
59
-
59
+
60
60
  @local_filepath = location if type == :file or type == :dfs
61
61
 
62
62
  openx(s)
@@ -71,10 +71,10 @@ class Polyrex
71
71
 
72
72
  @summary = RecordX.new @doc.root.xpath("summary/*")
73
73
  @summary_fields = @summary.keys
74
-
74
+
75
75
 
76
76
  end
77
-
77
+
78
78
  @polyrex_xslt = RecordxXSLT.new
79
79
  #@parent_node = @doc.root if @doc
80
80
 
@@ -102,7 +102,7 @@ class Polyrex
102
102
  @doc.root.xpath(x).each(&:delete)
103
103
  end
104
104
  end
105
-
105
+
106
106
  def delimiter=(separator)
107
107
 
108
108
  @delimiter = separator
@@ -110,20 +110,20 @@ class Polyrex
110
110
  @format_masks.map! do |format_mask|
111
111
  format_mask.to_s.gsub(/\s/, separator)
112
112
  end
113
- end
113
+ end
114
114
 
115
115
  alias set_delimiter delimiter=
116
-
116
+
117
117
  def each_recursive(parent=self, level=0, &blk)
118
-
118
+
119
119
  parent.records.each.with_index do |x, index|
120
120
 
121
121
  blk.call(x, parent, level, index) if block_given?
122
122
 
123
123
  each_recursive(x, level+1, &blk) if x.records.any?
124
-
124
+
125
125
  end
126
-
126
+
127
127
  end
128
128
 
129
129
  def export(filepath)
@@ -139,76 +139,80 @@ class Polyrex
139
139
  @doc.to_s(options)
140
140
  end
141
141
 
142
- def save(filepath=nil, opt={}, options: opt, pretty: false)
143
-
142
+ def save(filepath=nil, opt={}, options: opt, pretty: false)
143
+
144
144
  refresh_summary
145
145
  filepath ||= @local_filepath
146
146
  @local_filepath = filepath
147
-
147
+
148
148
  options.merge!({pretty: pretty}) if options.empty?
149
149
  xml = @doc.to_s(options)
150
-
150
+
151
151
  buffer = block_given? ? yield(xml) : xml
152
152
  FileX.write filepath, buffer
153
153
  end
154
-
155
- # -- start of crud methods --
154
+
155
+ # -- start of crud methods --
156
156
 
157
157
  def find_by_id(id)
158
+
159
+ puts 'inside find_by_id: ' + id if @debug
160
+ #return @doc if @debug
158
161
  @parent_node = @doc.root.element("//[@id='#{id}']")
159
- @objects[@parent_node.name].new(@parent_node, id: @id)
162
+ @objects[@parent_node.name.to_sym].new(@parent_node, id: @id)
163
+
160
164
  end
161
165
 
162
166
  def id(id)
163
167
  @parent_node = @doc.root.element("//[@id='#{id}']")
164
168
  self
165
169
  end
166
-
170
+
167
171
  def order=(val)
168
172
  @order = val.to_s
169
173
  end
170
174
 
171
175
  # -- end of crud methods --
172
-
176
+
173
177
  # -- start of full text edit methods
174
178
  def format_masks
175
179
  @format_masks
176
- end
177
-
180
+ end
181
+
178
182
  def parse(x=nil, options={})
179
183
 
180
184
  buffer, type = RXFReader.read(x)
181
-
185
+
182
186
  if type == :unknown and buffer.lines.length <= 1 then
183
187
  raise PolyrexException, 'File not found: ' + x.inspect
184
188
  end
185
-
186
- buffer = yield if block_given?
189
+
190
+ buffer = yield if block_given?
187
191
  string_parse buffer.clone, options
188
192
 
189
193
  self
190
- end
191
-
194
+ end
195
+
192
196
  alias import parse
193
197
 
194
198
  def element(s)
195
199
  @doc.root.element(s)
196
200
  end
197
-
201
+
198
202
  def leaf_nodes_to_dx()
199
-
203
+
200
204
  schema, record_name = @summary.schema\
201
205
  .match(/([^\/]+\/([^\/]+)\[[^\[]+$)/).captures
202
-
206
+
203
207
  xml = RexleBuilder.new
204
208
 
205
209
  xml.items do
206
210
  xml.summary do
207
211
  xml.schema schema.sub(/(\/\w+)\[([^\]]+)\]/,'\1(\2)')
208
212
  end
209
- xml.records
213
+ xml.records
210
214
  end
211
-
215
+
212
216
  doc = Rexle.new xml.to_a
213
217
  body = doc.root.element 'records'
214
218
  a = self.xpath('//' + record_name)
@@ -219,43 +223,43 @@ class Polyrex
219
223
 
220
224
  make_dynarex doc.root
221
225
  end
222
-
226
+
223
227
  def records
224
228
 
225
- @doc.root.xpath("records/*").map do |node|
229
+ @doc.root.xpath("records/*").map do |node|
226
230
  Kernel.const_get(node.name.capitalize).new node, id: @id_counter
227
231
  end
228
-
232
+
229
233
  end
230
234
 
231
235
  def rxpath(s)
232
-
236
+
233
237
  a = @doc.root.xpath s.split('/').map \
234
238
  {|x| x.sub('[','[summary/').prepend('records/')}.join('/')
235
-
236
- a.map do |node|
239
+
240
+ a.map do |node|
237
241
  Kernel.const_get(node.name.capitalize).new node, id: node.attributes[:id]
238
242
  end
239
243
 
240
244
  end
241
-
245
+
242
246
  def schema=(s)
243
247
 
244
248
  if s =~ /gem\[/ then
245
- raise PolyrexException, "invalid schema: cannot contain the " +
249
+ raise PolyrexException, "invalid schema: cannot contain the " +
246
250
  "word gem as a record name"
247
251
  end
248
-
252
+
249
253
  openx(s)
250
254
 
251
255
  summary_h = Hash[*@doc.root.xpath("summary/*").\
252
256
  map {|x| [x.name, x.text.to_s]}.flatten]
253
257
 
254
258
  @summary = RecordX.new summary_h
255
- @summary_fields = summary_h.keys.map(&:to_sym)
259
+ @summary_fields = summary_h.keys.map(&:to_sym)
256
260
  self
257
261
  end
258
-
262
+
259
263
  def summary
260
264
  @summary
261
265
  end
@@ -263,7 +267,7 @@ class Polyrex
263
267
  def to_a()
264
268
  recordx_map @doc.root
265
269
  end
266
-
270
+
267
271
  def to_dynarex()
268
272
 
269
273
  root = @doc.root.deep_clone
@@ -272,17 +276,17 @@ class Polyrex
272
276
  #summary.delete('format_mask')
273
277
  #summary.element('recordx_type').text = 'dynarex'
274
278
 
275
- summary.add root.element('records/*/summary/format_mask').clone
279
+ summary.add root.element('records/*/summary/format_mask').clone
276
280
  e = summary.element('schema')
277
281
  e.text = e.text[/[^\/]+\/[^\/]+/].sub(/(\/\w+)\[([^\]]+)\]/,'\1(\2)')
278
282
 
279
283
  make_dynarex(root)
280
284
  end
281
-
285
+
282
286
  def to_opml()
283
-
287
+
284
288
  puts '@schema: ' + @schema.inspect if @debug
285
-
289
+
286
290
  head, body = @schema.split(/(?<=\])/,2)
287
291
  schema_body = body.gsub(/(?<=\[)[^\]]+/) do |x|
288
292
  x.split(/\s*,\s*/).map {|field| '@' + field + ':' + field}.join(', ')
@@ -293,16 +297,16 @@ class Polyrex
293
297
 
294
298
  puts 'schema_body: ' + schema_body.inspect if @debug
295
299
  puts 'schema_head: ' + schema_head.inspect if @debug
296
- xslt_schema = schema_head.sub(/^\w+/,'opml>head') +
300
+ xslt_schema = schema_head.sub(/^\w+/,'opml>head') +
297
301
  schema_body.gsub(/\w+(?=\[)/,'outline')\
298
302
  .sub(/\/(\w+)(?=\[)/,'/body>outline')
299
-
303
+
300
304
  puts 'xslt_schema: ' + xslt_schema.inspect if @debug
301
-
305
+
302
306
  recxslt = RecordxXSLT.new(schema: @schema, xslt_schema: xslt_schema)
303
-
304
- Rexslt.new(recxslt.to_xslt, self.to_xml).to_s
305
-
307
+
308
+ Rexslt.new(recxslt.to_xslt, self.to_xml).to_s
309
+
306
310
  end
307
311
 
308
312
  def to_s(header: true)
@@ -317,9 +321,9 @@ class Polyrex
317
321
  puts 'line: ' + line.inspect if @debug
318
322
 
319
323
  recordsx = item.element('records').elements.to_a
320
-
324
+
321
325
  if recordsx.length > 0 then
322
- line = line + "\n" + build(recordsx, indent + 1).join("\n")
326
+ line = line + "\n" + build(recordsx, indent + 1).join("\n")
323
327
  end
324
328
  (' ' * indent) + line
325
329
  end
@@ -339,9 +343,9 @@ class Polyrex
339
343
  declaration = @raw_header
340
344
  else
341
345
 
342
- smry_fields = %i(schema)
346
+ smry_fields = %i(schema)
343
347
  if self.delimiter.length > 0 then
344
- smry_fields << :delimiter
348
+ smry_fields << :delimiter
345
349
  else
346
350
  smry_fields << :format_mask
347
351
  end
@@ -355,22 +359,22 @@ class Polyrex
355
359
  docheader = declaration + "\n" + sumry
356
360
  out = build(self.records).join("\n")
357
361
  header ? docheader + "\n" + out : out
358
-
362
+
359
363
  end
360
-
364
+
361
365
  def to_tree()
362
-
366
+
363
367
  s = @schema.gsub(/(?<=\[)[^\]]+/) do |x|
364
368
  x.split(/\s*,\s*/).map {|field| '@' + field + ':' + field}.join(', ')
365
369
  end
366
370
 
367
- xslt_schema = s.gsub(/\w+(?=\[)/,'item').sub(/^\w+/,'tree')
368
- recxslt = RecordxXSLT.new(schema: @schema, xslt_schema: xslt_schema)
369
- Rexslt.new(recxslt.to_xslt, self.to_xml).to_s
371
+ xslt_schema = s.gsub(/\w+(?=\[)/,'item').sub(/^\w+/,'tree')
372
+ recxslt = RecordxXSLT.new(schema: @schema, xslt_schema: xslt_schema)
373
+ Rexslt.new(recxslt.to_xslt, self.to_xml).to_s
374
+
375
+ end
370
376
 
371
- end
372
-
373
- def to_xslt()
377
+ def to_xslt()
374
378
  @polyrex_xslt.schema = @schema
375
379
  @polyrex_xslt.to_xslt
376
380
  end
@@ -385,26 +389,26 @@ class Polyrex
385
389
  end
386
390
 
387
391
  def xslt=(value)
388
-
392
+
389
393
  @summary.xslt = value
390
394
 
391
- end
392
-
395
+ end
396
+
393
397
  def xslt_schema=(s)
394
398
  @polyrex_xslt.xslt_schema = s
395
399
  self
396
400
  end
397
-
401
+
398
402
  protected
399
-
403
+
400
404
  def doc()
401
405
  @doc
402
406
  end
403
407
 
404
408
  private
405
-
409
+
406
410
  def make_dynarex(root)
407
-
411
+
408
412
  root.delete('summary/recordx_type')
409
413
  root.delete('summary/format_mask')
410
414
  root.xpath('records/*/summary/format_mask').each(&:delete)
@@ -438,8 +442,8 @@ xsl_buffer = '
438
442
 
439
443
  buffer = Rexslt.new(xsl_buffer, root.xml).to_s
440
444
  Dynarex.new buffer
441
-
442
- end
445
+
446
+ end
443
447
 
444
448
  def refresh_records(records, fields, level)
445
449
 
@@ -474,10 +478,10 @@ xsl_buffer = '
474
478
  flatten.map(&:to_sym)
475
479
  summary = field_names.map {|x| "<%s/>" % x}.join
476
480
  end
477
-
481
+
478
482
  summary << "<recordx_type>polyrex</recordx_type><schema>#{schema}</schema>"
479
483
  #----
480
-
484
+
481
485
  @schema = schema
482
486
  @id_counter = '0'
483
487
 
@@ -486,12 +490,12 @@ xsl_buffer = '
486
490
  [root_name, (summary || '') , root_name])
487
491
 
488
492
  end
489
-
493
+
490
494
  def recordx_map(node)
491
-
495
+
492
496
  # get the summary
493
497
  fields = node.xpath('summary/*').map do |x|
494
- next if %w(schema format_mask recordx_type).include? x.name
498
+ next if %w(schema format_mask recordx_type).include? x.name
495
499
  r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text.to_s : \
496
500
  x.cdatas.join.strip
497
501
  r
@@ -499,28 +503,28 @@ xsl_buffer = '
499
503
 
500
504
  # get the records
501
505
  a = node.xpath('records/*').map {|x| recordx_map x}
502
-
506
+
503
507
  [fields.compact, a]
504
- end
505
-
508
+ end
509
+
506
510
  def string_parse(buffer, options={})
507
511
 
508
512
  @raw_header = buffer.slice!(/<\?polyrex[^>]+>/)
509
-
513
+
510
514
  if @raw_header then
511
515
  header = @raw_header[/<?polyrex (.*)?>/,1]
512
516
 
513
517
  r1 = /([\w\[\]\-]+\s*\=\s*'[^']*)'/
514
518
  r2 = /([\w\[\]\-]+\s*\=\s*"[^"]*)"/
515
519
 
516
- a = header.scan(/#{r1}|#{r2}/).map(&:compact).flatten
517
-
520
+ a = header.scan(/#{r1}|#{r2}/).map(&:compact).flatten
518
521
 
522
+
519
523
  a.each do |x|
520
-
524
+
521
525
  attr, val = x.split(/\s*=\s*["']/,2)
522
526
 
523
- i = attr[/format_masks?\[(\d+)/,1]
527
+ i = attr[/format_masks?\[(\d+)/,1]
524
528
 
525
529
  if i then
526
530
 
@@ -532,16 +536,16 @@ xsl_buffer = '
532
536
  end
533
537
  end
534
538
  end
535
-
539
+
536
540
  options.each do |k,v|
537
-
541
+
538
542
  if options[k] then
539
543
  a.delete a.assoc(k)
540
544
  self.method(((k.to_s) + '=').to_sym).call(options[k])
541
545
  end
542
-
546
+
543
547
  end
544
-
548
+
545
549
  end
546
550
 
547
551
  raw_lines = buffer.lstrip.lines.map(&:chomp)
@@ -551,9 +555,9 @@ xsl_buffer = '
551
555
  if raw_summary then
552
556
  a_summary = raw_summary.split(',').map(&:strip)
553
557
 
554
- while raw_lines.first[/#{a_summary.join('|')}:\s+\w+/] do
558
+ while raw_lines.first[/#{a_summary.join('|')}:\s+\w+/] do
555
559
 
556
- label, val = raw_lines.shift.match(/(\w+):\s+([^$]+)$/).captures
560
+ label, val = raw_lines.shift.match(/(\w+):\s+([^$]+)$/).captures
557
561
  @summary.send((label + '=').to_sym, val)
558
562
  end
559
563
 
@@ -570,50 +574,50 @@ xsl_buffer = '
570
574
  puts 'lines: ' + lines.inspect if @debug
571
575
  @parent_node.root.add format_line!( lines)
572
576
 
573
- end
574
-
577
+ end
578
+
575
579
  def unescape(s)
576
580
  r = s.gsub('&lt;', '<').gsub('&gt;','>')
577
581
  end
578
-
582
+
579
583
  def load_handlers(schema)
580
584
 
581
- objects = PolyrexObjects.new(schema, debug: @debug)
585
+ objects = PolyrexObjects.new(schema, debug: @debug)
582
586
  h = objects.to_h
583
587
  puts 'h: ' + h.inspect if @debug
584
588
  @objects = h.inject({}){|r,x| r.merge x[0].downcase => x[-1]}
585
589
 
586
590
  @objects_a = objects.to_a
587
591
  attach_create_handlers(@objects.keys)
588
- #attach_edit_handlers(@objects)
592
+ #attach_edit_handlers(@objects)
589
593
 
590
594
  end
591
-
595
+
592
596
  def format_line!(a, i=0)
593
597
 
594
598
  records = Rexle::Element.new('records')
595
-
599
+
596
600
  # add code here for rowx
597
601
  @field_names = format_masks[i].to_s.scan(/\[!(\w+)\]/)\
598
602
  .flatten.map(&:to_sym)
599
603
 
600
604
  rowx_fields = a.map{|x| x.first[/^\w+(?=:)/].to_s.to_sym}.uniq
601
-
605
+
602
606
  records = if (@field_names & rowx_fields).length >= 2 then
603
607
  # rowx implementation still to-do
604
608
  #vertical_fiedlparse(records, a, i)
605
609
  else
606
610
  horizontal_fieldparse(records, a, i)
607
611
  end
608
-
612
+
609
613
  end
610
-
611
-
614
+
615
+
612
616
  # -- end of full text edit methods
613
-
617
+
614
618
  def horizontal_fieldparse(records, a, i)
615
619
 
616
- a.each do |x|
620
+ a.each do |x|
617
621
 
618
622
  unless @recordx[i] then
619
623
  @recordx[i] = @recordx[-1].clone
@@ -625,28 +629,28 @@ xsl_buffer = '
625
629
 
626
630
 
627
631
  line = raw_line
628
-
632
+
629
633
  if line[/\w+\s*---/] then
630
634
 
631
635
  node_name = line.sub(/\s*---/,'')
632
636
  ynode = Rexle::Element.new(node_name).add_text("---\n" + x.join("\n"))
633
-
637
+
634
638
  summary.add ynode
635
639
  next
636
640
  end
637
-
641
+
638
642
  puts '@schema: ' + @schema.inspect if @debug
639
643
  schema_a = @schema.split('/')[1..-1]
640
-
644
+
641
645
  if @debug then
642
646
  puts 'schema_a: ' + schema_a.inspect
643
647
  puts 'i: ' + i.inspect
644
648
  end
645
-
649
+
646
650
  unless @format_masks[i][/^\(.*\)$/] then
647
651
 
648
652
  @field_names, field_values = RXRawLineParser.new(format_masks[i])\
649
- .parse(line)
653
+ .parse(line)
650
654
 
651
655
  @field_names = schema_a[i] ? \
652
656
  schema_a[i][/\[([^\]]+)/,1].split(/\s*,\s*/).map(&:to_sym) : \
@@ -661,12 +665,12 @@ xsl_buffer = '
661
665
 
662
666
  pattern = patterns.detect {|x| line.match(/#{x}/)}
663
667
  i = patterns.index(pattern)
664
-
668
+
665
669
  @field_names = format_masks[i].to_s.scan(/\[!(\w+)\]/)\
666
670
  .flatten.map(&:to_sym)
667
671
 
668
- field_values = line.match(/#{pattern}/).captures
669
-
672
+ field_values = line.match(/#{pattern}/).captures
673
+
670
674
  end
671
675
 
672
676
  @id_counter.succ!
@@ -676,9 +680,9 @@ xsl_buffer = '
676
680
  record.add_attribute(id: @id_counter.clone)
677
681
  summary = Rexle::Element.new('summary')
678
682
 
679
- @field_names.zip(field_values).each do |name, value|
683
+ @field_names.zip(field_values).each do |name, value|
680
684
  field = Rexle::Element.new(name.to_s)
681
- field.text = value
685
+ field.text = value
682
686
  summary.add field
683
687
  end
684
688
 
@@ -690,42 +694,42 @@ xsl_buffer = '
690
694
  summary.add Rexle::Element.new('format_mask').add_text(format_mask)
691
695
  summary.add Rexle::Element.new('schema').add_text(schema)
692
696
  summary.add Rexle::Element.new('recordx_type').add_text('polyrex')
693
-
697
+
694
698
  record.add summary
695
699
  child_records = format_line!(x, i+1)
696
700
 
697
701
  record.add child_records
698
702
  records.add record
699
703
  end
700
-
704
+
701
705
  records
702
706
  end
703
707
 
704
708
  def attach_create_handlers(names)
705
709
  methodx = names.map do |name|
706
710
  %Q(
707
- def create_#{name.downcase}(params, &blk)
711
+ def create_#{name.downcase}(params, &blk)
708
712
  self.create.#{name.downcase}(params, &blk)
709
713
  end
710
714
  )
711
715
  end
712
716
 
713
717
  self.instance_eval(methodx.join("\n"))
714
-
718
+
715
719
  end
716
-
720
+
717
721
  def attach_edit_handlers(objects)
718
722
  objects.keys.each do |name|
719
723
  self.instance_eval(
720
724
  %Q(
721
- def #{name.downcase}()
725
+ def #{name.downcase}()
722
726
  @objects['#{name}'].new(@parent_node, id: @id)
723
727
  end
724
728
  ))
725
729
  end
726
-
730
+
727
731
  end
728
-
732
+
729
733
  def openx(s)
730
734
 
731
735
  puts 'inside openx' if @debug
@@ -745,9 +749,9 @@ xsl_buffer = '
745
749
  @doc = Rexle.new buffer
746
750
 
747
751
  schema = @doc.root.text('summary/schema').to_s
748
-
752
+
749
753
  if schema.nil? then
750
- schema = PolyrexSchema.new.parse(buffer).to_schema
754
+ schema = PolyrexSchema.new.parse(buffer).to_schema
751
755
  e = @doc.root.element('summary')
752
756
  e.add Rexle::Element.new('schema').add_text(schema)
753
757
  end
@@ -770,7 +774,7 @@ xsl_buffer = '
770
774
  @parent_node = @doc.root.element('records')
771
775
 
772
776
  end
773
-
777
+
774
778
  def regexify_fmask(f)
775
779
 
776
780
  a = f.split(/(?=\[!\w+\])/).map do |x|
@@ -787,45 +791,45 @@ xsl_buffer = '
787
791
  end
788
792
  end
789
793
 
790
- a.join
794
+ a.join
791
795
  end
792
-
796
+
793
797
  def tail_map(a)
794
798
  [a] + (a.length > 1 ? tail_map(a[0..-2]) : [])
795
799
  end
796
-
800
+
797
801
 
798
802
  def load_find_by(schema)
799
803
 
800
804
  a = PolyrexObjectMethods.new(schema).to_a
801
805
 
802
- methodx = a.map do |class_name, methods|
803
-
806
+ methodx = a.map do |class_name, methods|
807
+
804
808
  class_name.downcase!
805
-
806
- methods.map do |method_name|
807
-
809
+
810
+ methods.map do |method_name|
811
+
808
812
  xpath = %Q(@doc.root.element("//%s[summary/%s='\#\{val\}']")) % \
809
813
  [class_name, method_name]
810
814
  xpath2 = %Q(@doc.root.xpath("//%s[summary/%s='\#\{val\}']")) % \
811
815
  [class_name, method_name]
812
-
813
- "def find_by_#{class_name}_#{method_name}(val)
814
-
816
+
817
+ "def find_by_#{class_name}_#{method_name}(val)
818
+
815
819
  node = #{xpath}
816
-
820
+
817
821
  if node then
818
822
  Kernel.const_get(node.name.capitalize).new node, id: @id
819
823
  else
820
824
  nil
821
825
  end
822
-
826
+
823
827
  end
824
828
 
825
- def find_all_by_#{class_name}_#{method_name}(val)
826
-
829
+ def find_all_by_#{class_name}_#{method_name}(val)
830
+
827
831
  nodes = #{xpath2}
828
-
832
+
829
833
  if nodes then
830
834
  nodes.map do |node|
831
835
  Kernel.const_get(node.name.capitalize).new node, id: @id
@@ -833,35 +837,35 @@ xsl_buffer = '
833
837
  else
834
838
  nil
835
839
  end
836
-
837
- end
840
+
841
+ end
838
842
  "
839
- end
843
+ end
840
844
  end
841
845
 
842
846
  self.instance_eval methodx.join("\n")
843
847
  end
844
848
 
845
849
 
846
- # refreshes the XML document with any new modification from
850
+ # refreshes the XML document with any new modification from
847
851
  # the summary object
848
852
  def refresh_summary()
849
-
850
- summary = @doc.root.element('summary')
853
+
854
+ summary = @doc.root.element('summary')
851
855
  @summary.to_h.each do |k,v|
852
-
856
+
853
857
  puts "k: %s; v: %s" % [k, v] if @debug
854
858
  e = summary.element(k.to_s)
855
859
  if e then
856
860
  e.text = v
857
861
  else
858
- summary.add Rexle::Element.new(k.to_s).add_text(v)
862
+ summary.add Rexle::Element.new(k.to_s).add_text(v)
859
863
  end
860
864
  end
861
-
865
+
862
866
  if @summary.xslt then
863
- @doc.instructions = [['xml-stylesheet',
864
- "title='XSL_formatting' type='text/xsl' href='#{@summary.xslt}'"]]
867
+ @doc.instructions = [['xml-stylesheet',
868
+ "title='XSL_formatting' type='text/xsl' href='#{@summary.xslt}'"]]
865
869
  end
866
870
  end
867
871
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
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
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwNTI0MTI1MjMzWhcN
15
- MjIwNTI0MTI1MjMzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDxKAjh
17
- s6uPs8gcMaoia91NWkBsYkIRp98yXB/MeTcAcK+jM3Y3jbKfbsOa1QVETY+KNZPH
18
- byDLynjQE7xOQhZjMrtDB128+iWT+fCvF/OQS0tMMT5ki3qHQDJSqUfxKngwK9p2
19
- TlV4EVRaejuPYwGvXxb8qmx9jrR9S3HZVQMHd6aMNAwBb1ZNkSQymWQeEoM+45Un
20
- p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HzAdgRtnZW1tYXN0ZXJAamFt
28
+ ZXNyb2JlcnRzb24uZXUwJgYDVR0SBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
29
+ c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQBtyb3vC1KZ54hwkTPBCzje7oeXK+S9
30
+ u8RZExckOgWJqe5/wrXBAYGTsY1FVczMu9GIB+I9bDcXnc84SEqXVkCzaRx8qH72
31
+ iu/PD7yyJ7vsyxaYpmHEMx/e6MPWbpZAyN3zdcJKskJiHuIs1MIFgM4x9XYRssG/
32
+ pauXDTm3d+aDHCQIU/mKl8W23GDdOFUXYxlTWb8YkIZ8vfrnIo0j3mXFc8bQhzok
33
+ Ra160UC0/Hn9GTjXsxOz1qrRFUFx9C23QmXI7tups2HVXatd1Rz98pGIPQvzFatX
34
+ m3bhpURabliJES7NVeIHedjEJZSuqnKs/hmrdeZ/YyCyCC+9HfKUDSKWA1a26O7A
35
+ GucOFNDVx2u22ho5ooJw4eYwzKcFWXKjnVhnzMVANWEpPhqjG4PDV4bt8hv04k7Y
36
+ Ci8O8LX0nSoB5+VgMbcnZuLDK7xzQ2Lm+EdS9mcAQJGMxuOVi3g250tvTG2E62K1
37
+ UvbY/fh5fJ0WhGdQwGjK93u1PXwHh/NGnjE=
37
38
  -----END CERTIFICATE-----
38
- date: 2022-03-16 00:00:00.000000000 Z
39
+ date: 2023-02-06 00:00:00.000000000 Z
39
40
  dependencies:
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: polyrex-objects
@@ -103,20 +104,20 @@ dependencies:
103
104
  requirements:
104
105
  - - "~>"
105
106
  - !ruby/object:Gem::Version
106
- version: '1.9'
107
+ version: '1.10'
107
108
  - - ">="
108
109
  - !ruby/object:Gem::Version
109
- version: 1.9.8
110
+ version: 1.10.0
110
111
  type: :runtime
111
112
  prerelease: false
112
113
  version_requirements: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - "~>"
115
116
  - !ruby/object:Gem::Version
116
- version: '1.9'
117
+ version: '1.10'
117
118
  - - ">="
118
119
  - !ruby/object:Gem::Version
119
- version: 1.9.8
120
+ version: 1.10.0
120
121
  description:
121
122
  email: digital.robertson@gmail.com
122
123
  executables: []
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  - !ruby/object:Gem::Version
144
145
  version: '0'
145
146
  requirements: []
146
- rubygems_version: 3.2.22
147
+ rubygems_version: 3.4.4
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: A flavour of XML for storing and retrieving records in a Polyrex hierarchy
metadata.gz.sig CHANGED
Binary file