dynarex 1.5.23 → 1.5.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dynarex.rb +62 -24
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 194a935aaee6a2c66e74eb482928b27bc4ab2a0c
|
4
|
+
data.tar.gz: c290ab1afefd0583d2f7f47aea711cc08bf56cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c9a98a9dd710e65951f3a2b7a8be4e59621f3685f448d2a3ede9fb380e34d61d27c119895527beb6bb54f8df23fd570a622ad53858acf08e15046554364823
|
7
|
+
data.tar.gz: b3d5a5977c23d5113164cd94c877529549817c21612fc2476ae53e5ead867a3a3fc1e8f113d355c5d47ff3cbeda3ae5faa74340d54a6c0469d2fcb44f508e9de
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dynarex.rb
CHANGED
@@ -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,
|
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(/\[/,'\[')
|
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('>','>')\
|
437
443
|
.gsub('<','<')\
|
438
|
-
.gsub(/(&\s|&[a-zA-Z\.]+;?)/) {|x| x[-1] == ';' ? x
|
444
|
+
.gsub(/(&\s|&[a-zA-Z\.]+;?)/) {|x| x[-1] == ';' ? x \
|
445
|
+
: x.sub('&','&')}
|
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
|
-
|
465
|
-
|
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('>','>')\
|
467
477
|
.gsub('<','<')\
|
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}\"]")
|
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
|
-
|
615
|
-
|
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(
|
796
|
-
|
826
|
+
raw_lines = raw_lines.join("\n").gsub(/^(\s*#[^\n]+|\n)/,'').lines.to_a
|
827
|
+
|
828
|
+
if @linked then
|
797
829
|
|
798
|
-
|
799
|
-
|
800
|
-
|
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
|
-
|
803
|
-
|
804
|
-
|
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
|
-
|
810
|
-
|
811
|
-
|
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.
|
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-
|
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
|