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