dynarex 1.6.0 → 1.6.1
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 +101 -87
- metadata +1 -1
- 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: d56acd1bf4c6610a466ce814862ad922bddc9089
|
4
|
+
data.tar.gz: c7c244fdeb6d457ab69e660b615351dcb51e3178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10570bb1492398195085b3b5e17e5245f9d36a3c1ac8db614a3b5dca51c8a39cf016d69b543cb758450dadcb3037f5c2223dfbab832d4b04544ed82f90d55587
|
7
|
+
data.tar.gz: 5061e3cef44d759108c09fac1434f15f9254aacef197aae2dbd25254dc9e6c08289d31bda29f9bc28c2ef17353e35f3201a9c0783ac1c2125fef0a74152a5532
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dynarex.rb
CHANGED
@@ -458,96 +458,13 @@ EOF
|
|
458
458
|
end
|
459
459
|
|
460
460
|
def sort_by!(&element_blk)
|
461
|
-
refresh_doc
|
462
|
-
a = @doc.root.xpath('records/*').sort_by &element_blk
|
463
|
-
@doc.root.delete('records')
|
464
|
-
|
465
|
-
records = Rexle::Element.new 'records'
|
466
|
-
|
467
|
-
a.each {|record| records.add record}
|
468
461
|
|
469
|
-
|
462
|
+
r = sort_records_by! &element_blk
|
463
|
+
@dirty_flag = true
|
464
|
+
r
|
470
465
|
|
471
|
-
load_records if @dirty_flag
|
472
|
-
self
|
473
466
|
end
|
474
467
|
|
475
|
-
def rebuild_doc(state=:internal)
|
476
|
-
|
477
|
-
reserved_keywords = (
|
478
|
-
Object.public_methods | \
|
479
|
-
Kernel.public_methods | \
|
480
|
-
public_methods + [:method_missing]
|
481
|
-
)
|
482
|
-
|
483
|
-
xml = RexleBuilder.new
|
484
|
-
|
485
|
-
a = xml.send @root_name do
|
486
|
-
|
487
|
-
xml.summary do
|
488
|
-
|
489
|
-
@summary.each do |key,value|
|
490
|
-
|
491
|
-
v = value.gsub('>','>')\
|
492
|
-
.gsub('<','<')\
|
493
|
-
.gsub(/(&\s|&[a-zA-Z\.]+;?)/) {|x| x[-1] == ';' ? x \
|
494
|
-
: x.sub('&','&')}
|
495
|
-
|
496
|
-
xml.send key, v
|
497
|
-
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
|
-
records = @records.to_a
|
502
|
-
|
503
|
-
if records then
|
504
|
-
|
505
|
-
#jr160315records.reverse! if @order == 'descending' and state == :external
|
506
|
-
|
507
|
-
xml.records do
|
508
|
-
|
509
|
-
records.each do |k, item|
|
510
|
-
|
511
|
-
attributes = {}
|
512
|
-
|
513
|
-
item.keys.each do |key|
|
514
|
-
attributes[key] = item[key] || '' unless key == :body
|
515
|
-
end
|
516
|
-
|
517
|
-
xml.send(@record_name, attributes) do
|
518
|
-
item[:body].each do |name,value|
|
519
|
-
|
520
|
-
if reserved_keywords.include? name then
|
521
|
-
name = ('._' + name.to_s).to_sym
|
522
|
-
end
|
523
|
-
|
524
|
-
val = value.send(value.is_a?(String) ? :to_s : :to_yaml)
|
525
|
-
xml.send(name, val.gsub('>','>')\
|
526
|
-
.gsub('<','<')\
|
527
|
-
.gsub(/(&\s|&[a-zA-Z\.]+;?)/) do |x|
|
528
|
-
x[-1] == ';' ? x : x.sub('&','&')
|
529
|
-
end
|
530
|
-
)
|
531
|
-
end
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
end
|
536
|
-
else
|
537
|
-
xml.records
|
538
|
-
end # end of if @records
|
539
|
-
end
|
540
|
-
|
541
|
-
doc = Rexle.new(a)
|
542
|
-
|
543
|
-
if @xslt then
|
544
|
-
doc.instructions = [['xml-stylesheet',
|
545
|
-
"title='XSL_formatting' type='text/xsl' href='#{@xslt}'"]]
|
546
|
-
end
|
547
|
-
|
548
|
-
return doc if state != :internal
|
549
|
-
@doc = doc
|
550
|
-
end
|
551
468
|
|
552
469
|
def record(id)
|
553
470
|
e = @doc.root.element("records/*[@id='#{id}']")
|
@@ -753,6 +670,83 @@ EOF
|
|
753
670
|
|
754
671
|
end
|
755
672
|
|
673
|
+
def rebuild_doc(state=:internal)
|
674
|
+
|
675
|
+
reserved_keywords = (
|
676
|
+
Object.public_methods | \
|
677
|
+
Kernel.public_methods | \
|
678
|
+
public_methods + [:method_missing]
|
679
|
+
)
|
680
|
+
|
681
|
+
xml = RexleBuilder.new
|
682
|
+
|
683
|
+
a = xml.send @root_name do
|
684
|
+
|
685
|
+
xml.summary do
|
686
|
+
|
687
|
+
@summary.each do |key,value|
|
688
|
+
|
689
|
+
v = value.gsub('>','>')\
|
690
|
+
.gsub('<','<')\
|
691
|
+
.gsub(/(&\s|&[a-zA-Z\.]+;?)/) {|x| x[-1] == ';' ? x \
|
692
|
+
: x.sub('&','&')}
|
693
|
+
|
694
|
+
xml.send key, v
|
695
|
+
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
records = @records.to_a
|
700
|
+
|
701
|
+
if records then
|
702
|
+
|
703
|
+
#jr160315records.reverse! if @order == 'descending' and state == :external
|
704
|
+
|
705
|
+
xml.records do
|
706
|
+
|
707
|
+
records.each do |k, item|
|
708
|
+
|
709
|
+
attributes = {}
|
710
|
+
|
711
|
+
item.keys.each do |key|
|
712
|
+
attributes[key] = item[key] || '' unless key == :body
|
713
|
+
end
|
714
|
+
|
715
|
+
xml.send(@record_name, attributes) do
|
716
|
+
item[:body].each do |name,value|
|
717
|
+
|
718
|
+
if reserved_keywords.include? name then
|
719
|
+
name = ('._' + name.to_s).to_sym
|
720
|
+
end
|
721
|
+
|
722
|
+
val = value.send(value.is_a?(String) ? :to_s : :to_yaml)
|
723
|
+
xml.send(name, val.gsub('>','>')\
|
724
|
+
.gsub('<','<')\
|
725
|
+
.gsub(/(&\s|&[a-zA-Z\.]+;?)/) do |x|
|
726
|
+
x[-1] == ';' ? x : x.sub('&','&')
|
727
|
+
end
|
728
|
+
)
|
729
|
+
end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
end
|
734
|
+
else
|
735
|
+
xml.records
|
736
|
+
end # end of if @records
|
737
|
+
end
|
738
|
+
|
739
|
+
doc = Rexle.new(a)
|
740
|
+
|
741
|
+
if @xslt then
|
742
|
+
doc.instructions = [['xml-stylesheet',
|
743
|
+
"title='XSL_formatting' type='text/xsl' href='#{@xslt}'"]]
|
744
|
+
end
|
745
|
+
|
746
|
+
return doc if state != :internal
|
747
|
+
@doc = doc
|
748
|
+
end
|
749
|
+
|
756
750
|
def string_parse(buffer)
|
757
751
|
|
758
752
|
if @spaces_delimited then
|
@@ -926,6 +920,22 @@ EOF
|
|
926
920
|
rebuild_doc
|
927
921
|
self
|
928
922
|
end
|
923
|
+
|
924
|
+
def sort_records_by!(&element_blk)
|
925
|
+
|
926
|
+
refresh_doc
|
927
|
+
a = @doc.root.xpath('records/*').sort_by &element_blk
|
928
|
+
@doc.root.delete('records')
|
929
|
+
|
930
|
+
records = Rexle::Element.new 'records'
|
931
|
+
|
932
|
+
a.each {|record| records.add record}
|
933
|
+
|
934
|
+
@doc.root.add records
|
935
|
+
|
936
|
+
load_records if @dirty_flag
|
937
|
+
self
|
938
|
+
end
|
929
939
|
|
930
940
|
def unescape(s)
|
931
941
|
s.gsub('<', '<').gsub('>','>')
|
@@ -1071,7 +1081,11 @@ EOF
|
|
1071
1081
|
def load_records
|
1072
1082
|
|
1073
1083
|
@dirty_flag = false
|
1074
|
-
|
1084
|
+
|
1085
|
+
if @summary[:order] then
|
1086
|
+
orderfield = @summary[:order][/(\w+)\s+(?:ascending|descending)/,1]
|
1087
|
+
self.sort_records_by! {|x| x.element(orderfield).text } if orderfield
|
1088
|
+
end
|
1075
1089
|
|
1076
1090
|
@records = records_to_h
|
1077
1091
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|