polyrex 1.0.3 → 1.0.4

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.tar.gz.sig +0 -0
  4. data/lib/polyrex.rb +27 -35
  5. metadata +43 -43
  6. metadata.gz.sig +1 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11eab879ad7a2dadd2b251db50e98a0cbfc60a1d
4
- data.tar.gz: ec59a5ae4eb683e8bbca9575343ec066c8e2a799
3
+ metadata.gz: 469ae7ce023afc77672f9269e87e6489833805a6
4
+ data.tar.gz: 5da4aedc5655379190e6a39da6fcbab9d8a00bd5
5
5
  SHA512:
6
- metadata.gz: 7e87319f23896e15bf07096cde70266ae772f33e941d87d1b9384922fe45f26167c97f7ae4daaead54ec7f04a42f88d0bd87aacb16ea07ed0d433e66b69ad349
7
- data.tar.gz: 4607c4626a464d7c611eb7fbf55711b7daa1e5b8a617a2dfeffedd605640c7a8da24bc24b54063ecf6842805de3c2d3068f1dd61bdff457ec1a66daf72116ace
6
+ metadata.gz: 86b56aa40d93d33d21333df7dddab0b4c89539b4f9789736303e34ac3265e8312ae1c7527ef621e5b06b6891123f30d4295cc33015a79d0731d43d746e91dae2
7
+ data.tar.gz: a15b862f73e85bb71f6b9f0726bbdb22f04f8e6598569442e98915f468b8f3bb0d3b56e3e4fa3f1fd6f6a2d13daa26a884a99edf4050402125f668a291420acd
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/polyrex.rb CHANGED
@@ -62,12 +62,9 @@ class Polyrex
62
62
 
63
63
  end
64
64
 
65
+ @summary = RecordX.new @doc.root.xpath("summary/*")
66
+ @summary_fields = @summary.keys
65
67
 
66
- summary_h = Hash[*@doc.root.xpath("summary/*").map {|x| [x.name, x.text]}.flatten]
67
- #@summary = OpenStruct.new summary_h
68
-
69
- @summary = RecordX.new summary_h
70
- @summary_fields = summary_h.keys.map(&:to_sym)
71
68
  end
72
69
 
73
70
  @polyrex_xslt = RecordxXSLT.new
@@ -144,8 +141,10 @@ class Polyrex
144
141
  @format_masks
145
142
  end
146
143
 
147
- def parse(buffer='', options={})
144
+ def parse(x=nil, options={})
148
145
 
146
+ buffer, type = RXFHelper.read(x)
147
+
149
148
  buffer = yield if block_given?
150
149
  string_parse buffer.clone, options
151
150
  self
@@ -175,8 +174,8 @@ class Polyrex
175
174
  def schema=(s)
176
175
 
177
176
  openx(s)
178
- summary_h = Hash[*@doc.root.xpath("summary/*").map {|x| [x.name, x.text]}.flatten]
179
- #@summary = OpenStruct.new summary_h
177
+
178
+ summary_h = Hash[*@doc.root.xpath("summary/*").map {|x| [x.name, x.text.to_s]}.flatten]
180
179
 
181
180
  @summary = RecordX.new summary_h
182
181
  @summary_fields = summary_h.keys.map(&:to_sym)
@@ -240,8 +239,8 @@ EOF
240
239
  records.map do |item|
241
240
 
242
241
  summary = item.element 'summary'
243
- format_mask = summary.text 'format_mask'
244
- line = format_mask.gsub(/\[![^\]]+\]/){|x| summary.text x[2..-2]}
242
+ format_mask = summary.text('format_mask').to_s
243
+ line = format_mask.gsub(/\[![^\]]+\]/){|x| summary.text(x[2..-2]).to_s}
245
244
 
246
245
  records = item.element('records').elements.to_a
247
246
  line = line + "\n" + build(records, indent + 1).join("\n") if records.length > 0
@@ -319,8 +318,8 @@ EOF
319
318
 
320
319
  # -- required for the parsing feature
321
320
  doc = PolyrexSchema.new(schema).to_doc
322
-
323
321
  fm = doc.root.xpath('//format_mask/text()')
322
+
324
323
  @format_masks = fm.zip(@format_masks).map{|x,y| y || x }
325
324
 
326
325
  schema_rpath = schema.gsub(/\[[^\]]+\]/,'')
@@ -352,7 +351,7 @@ EOF
352
351
  # get the fields
353
352
  fields = summary.elements.map do |x|
354
353
  next if %w(schema format_mask recordx_type).include? x.name
355
- r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text : x.cdatas.join.strip
354
+ r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text.to_s : x.cdatas.join.strip
356
355
  REXML::Text::unnormalize(r)
357
356
  end
358
357
 
@@ -369,10 +368,7 @@ EOF
369
368
 
370
369
  if @raw_header then
371
370
  header = @raw_header[/<?polyrex (.*)?>/,1]
372
- #a = header.scan(/[\w\[\]]+\=["'][^"']+["']/).map do |x|
373
- # r = x.split(/=/)
374
- # [(r[0] + "=").to_sym, r[1][/^["'](.*)["']$/,1]]
375
- #end
371
+
376
372
  r1 = /([\w\[\]\-]+\s*\=\s*'[^']*)'/
377
373
  r2 = /([\w\[\]\-]+\s*\=\s*"[^"]*)"/
378
374
 
@@ -395,14 +391,14 @@ EOF
395
391
 
396
392
  else
397
393
  unless options.keys.include? attr[0..-2].to_sym then
398
- #self.method(name).call(value)
399
394
  self.method((attr + '=').to_sym).call(unescape val)
400
395
  end
401
396
  end
402
397
  end
398
+
403
399
  end
404
400
 
405
- raw_lines = buffer.strip.split(/\r?\n|\r(?!\n)/)
401
+ raw_lines = buffer.strip.lines.map(&:rstrip)
406
402
 
407
403
  raw_summary = schema[/^\w+\[([^\]]+)/,1]
408
404
 
@@ -422,13 +418,14 @@ EOF
422
418
  records = @parent_node.root
423
419
  @parent_node = records.parent
424
420
  records.delete
421
+
425
422
  lines = LineTree.new(raw_lines.join("\n").strip, ignore_label: true).to_a
426
423
  @parent_node.root.add format_line!( lines)
427
424
 
428
425
  end
429
426
 
430
427
  def unescape(s)
431
- s.gsub('&lt;', '<').gsub('&gt;','>')
428
+ r = s.gsub('&lt;', '<').gsub('&gt;','>')
432
429
  end
433
430
 
434
431
  def load_handlers(schema)
@@ -446,7 +443,7 @@ EOF
446
443
  end
447
444
 
448
445
  def format_line!(a, i=0)
449
-
446
+
450
447
  records = Rexle::Element.new('records')
451
448
 
452
449
  # add code here for rowx
@@ -481,7 +478,6 @@ EOF
481
478
 
482
479
 
483
480
  line = raw_line
484
-
485
481
 
486
482
  if line[/\w+\s*---/] then
487
483
 
@@ -491,18 +487,16 @@ EOF
491
487
  summary.add ynode
492
488
  next
493
489
  end
494
-
495
490
 
496
491
  unless @format_masks[i][/^\(.*\)$/] then
497
492
 
498
493
  @field_names, field_values = RXRawLineParser.new(format_masks[i])\
499
- .parse(line)
500
-
494
+ .parse(line)
501
495
  else
502
496
 
503
497
  format_masks = @format_masks[i][1..-2].split('|')
504
498
  patterns = format_masks.map do |x|
505
- regexify_fmask(x) #.sub(/\[/,'\[').sub(/\]/,'\]')
499
+ regexify_fmask(x)
506
500
  end
507
501
 
508
502
  pattern = patterns.detect {|x| line.match(/#{x}/)}
@@ -522,14 +516,13 @@ EOF
522
516
  record.add_attribute(id: @id_counter.clone)
523
517
  summary = Rexle::Element.new('summary')
524
518
 
525
-
526
519
  @field_names.zip(field_values).each do |name, value|
527
520
  field = Rexle::Element.new(name.to_s)
528
521
  field.text = value
529
522
  summary.add field
530
523
  end
531
524
 
532
- format_mask = @format_masks[i]
525
+ format_mask = @format_masks[i].to_s
533
526
 
534
527
  schema = "%s[%s]" % [tag_name, @field_names.join(', ')]
535
528
  summary.add Rexle::Element.new('format_mask').add_text(format_mask)
@@ -537,7 +530,7 @@ EOF
537
530
  summary.add Rexle::Element.new('recordx_type').add_text('polyrex')
538
531
 
539
532
  record.add summary
540
- child_records = format_line!(x, i+1) #jr071213 unless x.empty?
533
+ child_records = format_line!(x, i+1)
541
534
 
542
535
  record.add child_records
543
536
  records.add record
@@ -578,24 +571,22 @@ EOF
578
571
  elsif s[/\[/] then # schema
579
572
  buffer = polyrex_new s
580
573
  elsif s[/^https?:\/\//] then # url
581
- buffer = open(s, 'UserAgent' => 'Polyrex-Reader'){|x| x.read}
574
+ buffer = open(s, 'UserAgent' => 'Polyrex-Reader').read
582
575
  else # local file
583
- buffer = File.open(s,'r').read
576
+ buffer = File.read s
584
577
  @local_filepath = s
585
578
  end
586
579
 
587
580
  buffer.gsub!(/<schema>[^<]+/, '<schema>' + @schema) if @schema
588
-
589
581
  @doc = Rexle.new buffer
590
582
 
591
- schema = @doc.root.text('summary/schema')
583
+ schema = @doc.root.text('summary/schema').to_s
592
584
 
593
585
  if schema.nil? then
594
586
  schema = PolyrexSchema.new.parse(buffer).to_schema
595
587
  e = @doc.root.element('summary')
596
588
  e.add Rexle::Element.new('schema').add_text(schema)
597
589
  end
598
-
599
590
 
600
591
  unless @format_masks
601
592
  schema_rpath = schema.gsub(/\[[^\]]+\]/,'')
@@ -605,7 +596,7 @@ EOF
605
596
 
606
597
  id = @doc.root.xpath('max(//@id)')
607
598
  @id_counter = id.to_s.succ if id
608
-
599
+
609
600
  if schema then
610
601
  load_handlers(schema)
611
602
  load_find_by(schema) unless schema[/^\w+[^\/]+\/\{/]
@@ -639,7 +630,8 @@ EOF
639
630
  end
640
631
 
641
632
 
642
- def load_find_by(schema)
633
+ def load_find_by(schema)
634
+
643
635
  a = PolyrexObjectMethods.new(schema).to_a
644
636
 
645
637
  methodx = a.map do |class_name, methods|
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.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -12,26 +12,26 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
14
  YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE0MDIyMTIyMTYzNloXDTE1MDIyMTIyMTYzNlowSDESMBAG
15
+ 8ixkARkWAmV1MB4XDTE1MDMwMTAwMzcyM1oXDTE2MDIyOTAwMzcyM1owSDESMBAG
16
16
  A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
17
  EjAQBgoJkia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dEgQfMB2BG2dlbW1h
26
- c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAQg0q7eMS
27
- Z1rPmcl6F3eycyeqNfD9r0pFUNdMtYH/L7X7VK4hRv7qNkXmijXdqOCgb5eiYFaF
28
- viysSGLsXEmNz+QII0ODPTmUnwfkjANdUkl5hZhOm2l8kGfgJo7GZHttUw2Yk3Sc
29
- z5ICpEhB4PAu5v+VCYtLge2wAHMjNpuWlMV8PoLRBTVkp+kpL8QZ5A/R8JRWdPs+
30
- s7qQTcvKLvmnMjw49hmfeXROSl8nEawKNd9T5udpCUP0Lm9cMgoX8h6LDft9iv7C
31
- wbQnaFmJMPFyXo9Yh/95QJEinnBsM0Yk8nJhmcChjdCpQL5243BjgzVEjHI1Ouxe
32
- SmUIljyExpxiHQ==
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAuECbwC99
27
+ 4lpyCgV5nukGp4kHAP9sHWvLFaO3aE2nplBb9DpFs+s4h5gZmzZuzfrcSEhpXj2j
28
+ TE0Jh10eSXXUKXM763yTy9pJ0giXYVIGuKMTfQF/1A8YLkHrg7SeSoJiyqXYfIW2
29
+ linBUQ2SMsR2G2Y694/8s0z7bfkHdExYO4vJBweft3w57OCBAjsvAnhR/Di7tnGM
30
+ ayA0vQpuh7bQgMt+3OkO2+Y5k3q/k/BGFwy8M5Vi7D1m59UlW5qSlVjJ02ugD0PX
31
+ xutogBWBRwktcdg7bc24/mbFcXcx5WhspVwfj6isE6q3A1nNkMtk3DHHKmUrfemr
32
+ pWpTJQi2DFAx/g==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-01-29 00:00:00.000000000 Z
34
+ date: 2015-03-01 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: polyrex-schema
@@ -39,100 +39,100 @@ dependencies:
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0.1'
42
+ version: '0.4'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.15
45
+ version: 0.4.0
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.1'
52
+ version: '0.4'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.1.15
55
+ version: 0.4.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: line-tree
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.4'
62
+ version: '0.5'
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 0.4.7
65
+ version: 0.5.2
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '0.4'
72
+ version: '0.5'
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.4.7
75
+ version: 0.5.2
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: polyrex-objects
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.7'
82
+ version: '0.8'
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.7.8
85
+ version: 0.8.5
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '0.7'
92
+ version: '0.8'
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: 0.7.8
95
+ version: 0.8.5
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: polyrex-createobject
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0.4'
102
+ version: '0.5'
103
103
  - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: 0.4.15
105
+ version: 0.5.7
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '0.4'
112
+ version: '0.5'
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: 0.4.15
115
+ version: 0.5.7
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: polyrex-object-methods
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.1'
122
+ version: '0.2'
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 0.1.2
125
+ version: 0.2.2
126
126
  type: :runtime
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '0.1'
132
+ version: '0.2'
133
133
  - - ">="
134
134
  - !ruby/object:Gem::Version
135
- version: 0.1.2
135
+ version: 0.2.2
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: recordx-xslt
138
138
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0.1'
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 0.1.3
145
+ version: 0.1.4
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
@@ -152,27 +152,27 @@ dependencies:
152
152
  version: '0.1'
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- version: 0.1.3
155
+ version: 0.1.4
156
156
  - !ruby/object:Gem::Dependency
157
157
  name: dynarex
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: '1.3'
162
+ version: '1.4'
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 1.3.5
165
+ version: 1.4.1
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '1.3'
172
+ version: '1.4'
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: 1.3.5
175
+ version: 1.4.1
176
176
  description:
177
177
  email: james@r0bertson.co.uk
178
178
  executables: []
metadata.gz.sig CHANGED
@@ -1,5 +1 @@
1
- Lv#�J&��5m2�:����
2
-
3
- +��,Hd�o���M�����)ގ2ۻ��D�2��CG
4
- 7%�8R���>z{�Z�Q��
5
- ��t�U�Wa��Zj��bN�\Q|
1
+ (Pl݌�G��B�cK�ˮU6j�>`�#�Y*wN0lM1�Qa��BVs��E./Н9�2�z�n�����%E�H�{��C��!�b�[���%�8�f��y����+��JW���)���t��bfo��p&������ڶ��`�NN��~Eu/��4�� �z����'��)FF��4Z�E7�F���g�h6���VM3*%��#Nm��\>Q�:��s�{|��*=A�ȅW�G!v\�/@�B