polyrex 1.1.13 → 1.2.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: 7b5969096e2a90c6076f804745cd2722cc88f908
4
- data.tar.gz: 9f98b301dd9c402b8d3398986366aff7403500ed
3
+ metadata.gz: 88cb8e71bff63b0569512e98f4fa9019cbd41be1
4
+ data.tar.gz: 9a2ec75e486de8da01a1a141b8f544f8953aa6e5
5
5
  SHA512:
6
- metadata.gz: fa339d87856a0284db91be4042c8a18cc9b20013ff023b5d3d5bfd2d003322edbf04c9962d1b5bf2ff277e8ee041d7836f5cbec535f25a9994beadd9cac7e820
7
- data.tar.gz: 2d546271156b0ce4cc4e6f77fd77da81f7f148a56bee31423600d73df23ce226bb98546c734d9c68906180a9a2e5abf9665bb8d86b683024efa19b85ce62e0c2
6
+ metadata.gz: 81e136370547e87c7f974ffcbcf48ccf53641901f0f4c41c6034855d3b6871ff1d075c1d9df96fc4b94ecfcfc93df9bc1737fe9285a915eba948bdcc15ce454a
7
+ data.tar.gz: 492653c62b318392805f21d9d3fb870467f5e5f226f059f6b1a1a9f9f647759aa74f08013c4080a2ac98fed339298602f5153ad36aa712fde1e6bab4cd6a6755
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -3,10 +3,10 @@
3
3
  # file: polyrex.rb
4
4
 
5
5
  #require 'open-uri'
6
- require 'polyrex-schema'
6
+ #require 'polyrex-schema'
7
7
  #require 'line-tree'
8
8
  require 'polyrex-objects'
9
- require 'polyrex-createobject'
9
+ #require 'polyrex-createobject'
10
10
  require 'polyrex-object-methods'
11
11
  require 'recordx-xslt'
12
12
  #require 'rexle'
@@ -42,10 +42,10 @@ class Polyrex
42
42
  attr_accessor :summary_fields, :xslt_schema, :id_counter,
43
43
  :schema, :type, :delimiter, :xslt, :format_masks
44
44
 
45
- def initialize(location=nil, schema: nil, id_counter: '1')
45
+ def initialize(location=nil, schema: nil, id_counter: '1', debug: debug)
46
46
 
47
47
 
48
- @id_counter = id_counter
48
+ @id_counter, @debug = id_counter, debug
49
49
  @format_masks = []
50
50
  @delimiter = ''
51
51
 
@@ -70,6 +70,7 @@ class Polyrex
70
70
  end
71
71
 
72
72
  @polyrex_xslt = RecordxXSLT.new
73
+ #@parent_node = @doc.root if @doc
73
74
  end
74
75
 
75
76
  def add(pxobj)
@@ -80,15 +81,9 @@ class Polyrex
80
81
  CGI.unescapeHTML(to_xml(options))
81
82
  end
82
83
 
83
- def create(id: nil)
84
-
85
- # @create is a PolyrexCreateObject,
86
- # @parent_node is a Rexle::Element pointing to the current record
87
-
88
- @create.id = id || @id_counter
89
- @create.record = @parent_node.name == 'records' ? \
90
- @parent_node.root : @parent_node.root.element('records')
91
- @create
84
+ def create(id: @id_counter)
85
+ puts 'id: ' + id.inspect if @debug
86
+ @create = PolyrexCreateObject.new(id: id, record: @doc.root)
92
87
  end
93
88
 
94
89
  def delete(x=nil)
@@ -176,6 +171,7 @@ class Polyrex
176
171
 
177
172
  buffer = yield if block_given?
178
173
  string_parse buffer.clone, options
174
+
179
175
  self
180
176
  end
181
177
 
@@ -212,9 +208,10 @@ class Polyrex
212
208
 
213
209
  def records
214
210
 
215
- @doc.root.xpath("records/*").map do |record|
216
- @objects_a[0].new(record)
211
+ @doc.root.xpath("records/*").map do |node|
212
+ Kernel.const_get(node.name.capitalize).new node, id: @id_counter
217
213
  end
214
+
218
215
  end
219
216
 
220
217
  def rxpath(s)
@@ -222,7 +219,9 @@ class Polyrex
222
219
  a = @doc.root.xpath s.split('/').map \
223
220
  {|x| x.sub('[','[summary/').prepend('records/')}.join('/')
224
221
 
225
- a.map {|x| @objects[x.name].new(x, id: x.attributes[:id]) }
222
+ a.map do |node|
223
+ Kernel.const_get(node.name.capitalize).new node, id: node.attributes[:id]
224
+ end
226
225
 
227
226
  end
228
227
 
@@ -524,10 +523,9 @@ xsl_buffer = '
524
523
 
525
524
  def load_handlers(schema)
526
525
 
527
- @create = PolyrexCreateObject.new(schema, id: @id_counter)
528
- objects = PolyrexObjects.new(schema)
526
+ objects = PolyrexObjects.new(schema, debug: @debug)
529
527
  h = objects.to_h
530
-
528
+ puts 'h: ' + h.inspect if @debug
531
529
  @objects = h.inject({}){|r,x| r.merge x[0].downcase => x[-1]}
532
530
 
533
531
  @objects_a = objects.to_a
@@ -582,12 +580,18 @@ xsl_buffer = '
582
580
  next
583
581
  end
584
582
 
583
+ puts '@schema: ' + @schema.inspect if @debug
584
+ schema_a = @schema.split('/')[1..-1]
585
+
586
+ if @debug then
587
+ puts 'schema_a: ' + schema_a.inspect
588
+ puts 'i: ' + i.inspect
589
+ end
590
+
585
591
  unless @format_masks[i][/^\(.*\)$/] then
586
592
 
587
593
  @field_names, field_values = RXRawLineParser.new(format_masks[i])\
588
594
  .parse(line)
589
-
590
- schema_a = @schema.split('/')[1..-1]
591
595
 
592
596
  @field_names = schema_a[i] ? \
593
597
  schema_a[i][/\[([^\]]+)/,1].split(/\s*,\s*/).map(&:to_sym) : \
@@ -625,7 +629,9 @@ xsl_buffer = '
625
629
 
626
630
  format_mask = @format_masks[i].to_s
627
631
 
628
- schema = "%s[%s]" % [tag_name, @field_names.join(', ')]
632
+ index = i >= schema_a.length ? schema_a.length - 1 : i
633
+
634
+ schema = schema_a[index..-1].join('/')
629
635
  summary.add Rexle::Element.new('format_mask').add_text(format_mask)
630
636
  summary.add Rexle::Element.new('schema').add_text(schema)
631
637
  summary.add Rexle::Element.new('recordx_type').add_text('polyrex')
@@ -752,7 +758,7 @@ xsl_buffer = '
752
758
  node = #{xpath}
753
759
 
754
760
  if node then
755
- @objects['#{class_name}'].new(node, id: @id, objects: @objects)
761
+ Kernel.const_get(node.name.capitalize).new node, id: @id
756
762
  else
757
763
  nil
758
764
  end
@@ -765,7 +771,7 @@ xsl_buffer = '
765
771
 
766
772
  if nodes then
767
773
  nodes.map do |node|
768
- @objects['#{class_name}'].new(node, id: @id, objects: @objects)
774
+ Kernel.const_get(node.name.capitalize).new node, id: @id
769
775
  end
770
776
  else
771
777
  nil
@@ -785,7 +791,9 @@ xsl_buffer = '
785
791
  def refresh_summary()
786
792
 
787
793
  summary = @doc.root.element('summary')
788
- @summary.to_h.each do |k,v|
794
+ @summary.to_h.each do |k,v|
795
+
796
+ puts "k: %s; v: %s" % [k, v] if @debug
789
797
  e = summary.element(k.to_s)
790
798
  if e then
791
799
  e.text = v
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.1.13
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,68 +30,28 @@ cert_chain:
30
30
  hCr2pfiPoS3nhbgAf3XvP4D146WaQbEgU87QlxPJLhz3yXKi7lwa9XgHQzuifNDi
31
31
  OXU=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-03-17 00:00:00.000000000 Z
33
+ date: 2018-03-29 00:00:00.000000000 Z
34
34
  dependencies:
35
- - !ruby/object:Gem::Dependency
36
- name: polyrex-schema
37
- requirement: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '0.4'
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: 0.4.2
45
- type: :runtime
46
- prerelease: false
47
- version_requirements: !ruby/object:Gem::Requirement
48
- requirements:
49
- - - "~>"
50
- - !ruby/object:Gem::Version
51
- version: '0.4'
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.4.2
55
35
  - !ruby/object:Gem::Dependency
56
36
  name: polyrex-objects
57
37
  requirement: !ruby/object:Gem::Requirement
58
38
  requirements:
59
39
  - - "~>"
60
40
  - !ruby/object:Gem::Version
61
- version: '0.9'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 0.9.8
65
- type: :runtime
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - "~>"
70
- - !ruby/object:Gem::Version
71
- version: '0.9'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 0.9.8
75
- - !ruby/object:Gem::Dependency
76
- name: polyrex-createobject
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.6'
41
+ version: '1.0'
82
42
  - - ">="
83
43
  - !ruby/object:Gem::Version
84
- version: 0.6.1
44
+ version: 1.0.0
85
45
  type: :runtime
86
46
  prerelease: false
87
47
  version_requirements: !ruby/object:Gem::Requirement
88
48
  requirements:
89
49
  - - "~>"
90
50
  - !ruby/object:Gem::Version
91
- version: '0.6'
51
+ version: '1.0'
92
52
  - - ">="
93
53
  - !ruby/object:Gem::Version
94
- version: 0.6.1
54
+ version: 1.0.0
95
55
  - !ruby/object:Gem::Dependency
96
56
  name: polyrex-object-methods
97
57
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file