dynarex 1.5.23 → 1.5.24

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: d2a4f8cb51cbe13c21e47f2836b5abdca7f4c673
4
- data.tar.gz: 6e58c34ef2b1897afbd058eafcded7895bc28b20
3
+ metadata.gz: 194a935aaee6a2c66e74eb482928b27bc4ab2a0c
4
+ data.tar.gz: c290ab1afefd0583d2f7f47aea711cc08bf56cde
5
5
  SHA512:
6
- metadata.gz: 4c2e8639d211787319ab3ae4e904f49f2ba92776a3dfd5cc11c8906b8349b637e5b513f8d3522f267a8fee1cf8e12cf1686a739aae403bca51e9ec8056974969
7
- data.tar.gz: 8814cbc039a9eed2775a63ffcfed72fc47e19b2109e3a123c3a8f800a71a8a1cf95efa911645a6f44ba42686774472b96c574eec84bfb643d1fd0cab15b333cc
6
+ metadata.gz: 21c9a98a9dd710e65951f3a2b7a8be4e59621f3685f448d2a3ede9fb380e34d61d27c119895527beb6bb54f8df23fd570a622ad53858acf08e15046554364823
7
+ data.tar.gz: b3d5a5977c23d5113164cd94c877529549817c21612fc2476ae53e5ead867a3a3fc1e8f113d355c5d47ff3cbeda3ae5faa74340d54a6c0469d2fcb44f508e9de
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  class Dynarex
27
27
 
28
- attr_accessor :format_mask, :delimiter, :xslt_schema, :schema,
28
+ attr_accessor :format_mask, :delimiter, :xslt_schema, :schema, :linked,
29
29
  :order, :type, :limit_by, :xslt
30
30
 
31
31
 
@@ -108,6 +108,10 @@ class Dynarex
108
108
  def inspect()
109
109
  "<object #%s>" % [self.object_id]
110
110
  end
111
+
112
+ def linked=(bool)
113
+ @linked = bool == 'true'
114
+ end
111
115
 
112
116
  def order=(value)
113
117
 
@@ -264,7 +268,8 @@ EOF
264
268
  header + "--#\n" + out.text
265
269
  elsif self.delimiter.length > 0 then
266
270
 
267
- tfo = TableFormatter.new border: false, nowrap: true, divider: self.delimiter
271
+ tfo = TableFormatter.new border: false, nowrap: true, \
272
+ divider: self.delimiter
268
273
  tfo.source = self.to_h.map{|x| x.values}
269
274
  header + tfo.display
270
275
 
@@ -349,7 +354,8 @@ EOF
349
354
  # dynarex.create_from_line 'Tracy 37 15-Jun-1972'
350
355
 
351
356
  def create_from_line(line, id=nil, attr: '')
352
- t = @format_mask.to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[').sub(/\]/,'\]')
357
+ t = @format_mask.to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[')\
358
+ .sub(/\]/,'\]')
353
359
  line.match(/#{t}/).captures
354
360
 
355
361
  a = line.match(/#{t}/).captures
@@ -435,7 +441,8 @@ EOF
435
441
 
436
442
  v = value.gsub('>','&gt;')\
437
443
  .gsub('<','&lt;')\
438
- .gsub(/(&\s|&[a-zA-Z\.]+;?)/) {|x| x[-1] == ';' ? x : x.sub('&','&amp;')}
444
+ .gsub(/(&\s|&[a-zA-Z\.]+;?)/) {|x| x[-1] == ';' ? x \
445
+ : x.sub('&','&amp;')}
439
446
 
440
447
  xml.send key, v
441
448
 
@@ -461,8 +468,11 @@ EOF
461
468
  xml.send(@record_name, attributes) do
462
469
  item[:body].each do |name,value|
463
470
 
464
- name = ('._' + name.to_s).to_sym if reserved_keywords.include? name
465
- val = value.send(value.is_a?(String) ? :to_s : :to_yaml)
471
+ if reserved_keywords.include? name then
472
+ name = ('._' + name.to_s).to_sym
473
+ end
474
+
475
+ val = value.send(value.is_a?(String) ? :to_s : :to_yaml)
466
476
  xml.send(name, val.gsub('>','&gt;')\
467
477
  .gsub('<','&lt;')\
468
478
  .gsub(/(&\s|&[a-zA-Z\.]+;?)/) do |x|
@@ -605,14 +615,15 @@ EOF
605
615
  end
606
616
 
607
617
  def findx_all_by(field, value)
608
- @doc.root.xpath("records/*[#{field}=\"#{value}\"]").map {|x| recordx_to_record x}
618
+ @doc.root.xpath("records/*[#{field}=\"#{value}\"]")\
619
+ .map {|x| recordx_to_record x}
609
620
  end
610
621
 
611
622
  def recordx_to_record(recordx)
612
623
 
613
624
  h = recordx.attributes
614
- RecordX.new(Hash[*@fields.zip(recordx.xpath("*/text()")).flatten], self, \
615
- h[:id], h[:created], h[:last_modified])
625
+ hash = Hash[*@fields.zip(recordx.xpath("*/text()")).flatten]
626
+ RecordX.new(hash, self, h[:id], h[:created], h[:last_modified])
616
627
  end
617
628
 
618
629
  def hash_create(raw_params={}, id=nil, attr: {})
@@ -625,7 +636,7 @@ EOF
625
636
 
626
637
  def capture_fields(params)
627
638
  fields = Hash[@fields.map {|x| [x,nil]}]
628
- fields.keys.each {|key| fields[key] = params[key.to_sym] if params.has_key? key.to_sym}
639
+ fields.keys.each {|key| fields[key] = params[key.to_sym] if params.has_key? key.to_sym}
629
640
  fields
630
641
  end
631
642
 
@@ -665,6 +676,26 @@ EOF
665
676
 
666
677
  alias refresh_doc display_xml
667
678
 
679
+ def parse_links(raw_lines)
680
+ puts 'raw_lines : ' + raw_lines.inspect
681
+ raw_lines.map do |line|
682
+
683
+ buffer = RXFHelper.read(line.chomp).first
684
+
685
+ doc = Rexle.new buffer
686
+
687
+ if doc.root.name == 'kvx' then
688
+
689
+ kvx = Kvx.new doc
690
+ h = kvx.to_h[:body]
691
+ @fields.inject([]){|r,x| r << h[x]}
692
+
693
+ end
694
+
695
+ end
696
+
697
+ end
698
+
668
699
  def string_parse(buffer)
669
700
 
670
701
  buffer.gsub!("\r",'')
@@ -792,25 +823,32 @@ EOF
792
823
 
793
824
  else
794
825
 
795
- raw_lines = raw_lines.join("\n").gsub(/^\s*#[^\n]+/,'').lines.to_a
796
- a2 = raw_lines.map.with_index do |x,i|
826
+ raw_lines = raw_lines.join("\n").gsub(/^(\s*#[^\n]+|\n)/,'').lines.to_a
827
+
828
+ if @linked then
797
829
 
798
- next if x[/^\s+$|\n\s*#/]
799
-
800
- begin
830
+ parse_links(raw_lines)
831
+
832
+ else
833
+ a2 = raw_lines.map.with_index do |x,i|
834
+
835
+ next if x[/^\s+$|\n\s*#/]
801
836
 
802
- field_names, field_values = RXRawLineParser.new(@format_mask).parse(x)
803
- rescue
804
- raise "input file parser error at line " + (i + 1).to_s + ' --> ' + x
837
+ begin
838
+
839
+ field_names, field_values = RXRawLineParser.new(@format_mask).parse(x)
840
+ rescue
841
+ raise "input file parser error at line " + (i + 1).to_s + ' --> ' + x
842
+ end
843
+ field_values
805
844
  end
806
- field_values
807
- end
808
845
 
809
- a2.compact!
810
- a3 = a2.compact.map(&:first)
811
- add_id(a2) if a3 != a3.uniq
846
+ a2.compact!
847
+ a3 = a2.compact.map(&:first)
848
+ add_id(a2) if a3 != a3.uniq
849
+ a2
850
+ end
812
851
 
813
- a2
814
852
  end
815
853
 
816
854
  a = lines.map.with_index do |x,i|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.23
4
+ version: 1.5.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  zafTuKRozNy5wCw7Z32VaDGcJ+yTPq73CrcPrNyaoxqGfU0qNsh6oGvwrq4Q1k4j
32
32
  Pz2GWE7KigXTBg==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-05-24 00:00:00.000000000 Z
34
+ date: 2015-06-19 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dynarex-import
metadata.gz.sig CHANGED
Binary file