polyrex 1.0.14 → 1.0.15

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: 530e9d5026fa2ee7615fa2e5aed51feaf29abafa
4
- data.tar.gz: bdd3abdcb86751092b1b79a9595defc9eeadbf6f
3
+ metadata.gz: 972596a01d30af3f37c3e941ed4f0032ec504af7
4
+ data.tar.gz: d442512d6460ae5130ec8d902d16a7d3455e3a3f
5
5
  SHA512:
6
- metadata.gz: 63f063cf70c5c63ead0a397e68eb3f0059861260a79245e75fb789fbcb89f4653c17fb2085d0157d7ef88fa17f2a26ec803abb5415c77bc0d0b6488b177fedae
7
- data.tar.gz: 050354720e326a95118d509c1ec4c7cd178bd06311c725b7d2dacb2d95b85002f245e641def72105693de2bc5d99a59249c45abfe0a1aea2cf1459ab2ca86d09
6
+ metadata.gz: e9f91bbd86e5562604e6387f5b975a3805fb3c52d726ade138809f5c2bdd5eb48200632e6d73f733e96c45246f3bc7caecfd0695aa18f99b9fcdddd048f1a947
7
+ data.tar.gz: a9393a80decff4fdc5b3abd846847ad5cadb01e254a6e8d2ac1b652bdb94c64e02c3148c28faa8f66ed48885785ae1e7c41d3257e43633d4249a96b0c2d73533
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/polyrex.rb CHANGED
@@ -80,10 +80,13 @@ class Polyrex
80
80
  end
81
81
 
82
82
  def create(id: nil)
83
- # @create is a PolyrexCreateObject, @parent_node is a Rexle::Element pointing to the current record
83
+
84
+ # @create is a PolyrexCreateObject,
85
+ # @parent_node is a Rexle::Element pointing to the current record
84
86
 
85
87
  @create.id = id || @id_counter
86
- @create.record = @parent_node.name == 'records' ? @parent_node.root : @parent_node.root.element('records')
88
+ @create.record = @parent_node.name == 'records' ? \
89
+ @parent_node.root : @parent_node.root.element('records')
87
90
  @create
88
91
  end
89
92
 
@@ -205,7 +208,8 @@ class Polyrex
205
208
 
206
209
  openx(s)
207
210
 
208
- summary_h = Hash[*@doc.root.xpath("summary/*").map {|x| [x.name, x.text.to_s]}.flatten]
211
+ summary_h = Hash[*@doc.root.xpath("summary/*").\
212
+ map {|x| [x.name, x.text.to_s]}.flatten]
209
213
 
210
214
  @summary = RecordX.new summary_h
211
215
  @summary_fields = summary_h.keys.map(&:to_sym)
@@ -245,7 +249,10 @@ class Polyrex
245
249
  line = format_mask.gsub(/\[![^\]]+\]/){|x| summary.text(x[2..-2]).to_s}
246
250
 
247
251
  records = item.element('records').elements.to_a
248
- line = line + "\n" + build(records, indent + 1).join("\n") if records.length > 0
252
+
253
+ if records.length > 0 then
254
+ line = line + "\n" + build(records, indent + 1).join("\n")
255
+ end
249
256
  (' ' * indent) + line
250
257
  end
251
258
  end
@@ -378,7 +385,8 @@ EOF
378
385
  summary = ''
379
386
  if @format_masks.length == @recordx.length then
380
387
  root_format_mask = @format_masks.shift
381
- field_names = root_format_mask.to_s.scan(/\[!(\w+)\]/).flatten.map(&:to_sym)
388
+ field_names = root_format_mask.to_s.scan(/\[!(\w+)\]/).\
389
+ flatten.map(&:to_sym)
382
390
  summary = field_names.map {|x| "<%s/>" % x}.join
383
391
  end
384
392
 
@@ -389,27 +397,26 @@ EOF
389
397
  @id_counter = '0'
390
398
 
391
399
  root_name = @recordx.shift
392
- ("<%s><summary>%s</summary><records/></%s>" % [root_name, (summary || '') , root_name])
400
+ ("<%s><summary>%s</summary><records/></%s>" % \
401
+ [root_name, (summary || '') , root_name])
393
402
 
394
403
  end
395
404
 
396
405
  def recordx_map(node)
406
+
397
407
  # get the summary
398
- summary = XPath.first(node, 'summary')
399
-
400
- # get the fields
401
- fields = summary.elements.map do |x|
408
+ fields = node.xpath('summary/*').map do |x|
402
409
  next if %w(schema format_mask recordx_type).include? x.name
403
- r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text.to_s : x.cdatas.join.strip
404
- REXML::Text::unnormalize(r)
410
+ r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text.to_s : \
411
+ x.cdatas.join.strip
412
+ r
405
413
  end
406
414
 
407
415
  # get the records
408
- records = XPath.first(node, 'records')
409
- a = records.elements.map {|x| recordx_map x}
416
+ a = node.xpath('records/*').map {|x| recordx_map x}
410
417
 
411
- [fields, a]
412
- end
418
+ [fields.compact, a]
419
+ end
413
420
 
414
421
  def string_parse(buffer, options={})
415
422
 
@@ -686,7 +693,8 @@ EOF
686
693
  methodx = a.map do |class_name, methods|
687
694
  class_name.downcase!
688
695
  methods.map do |method_name|
689
- xpath = %Q(@doc.root.element("//%s[summary/%s='\#\{val\}']")) % [class_name, method_name]
696
+ xpath = %Q(@doc.root.element("//%s[summary/%s='\#\{val\}']")) % \
697
+ [class_name, method_name]
690
698
  "def find_by_#{class_name}_#{method_name}(val)
691
699
 
692
700
  node = #{xpath}
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.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file