xqsr3 0.32.3 → 0.37.0
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
- data/lib/xqsr3/all_extensions.rb +6 -0
- data/lib/xqsr3/array_utilities.rb +10 -0
- data/lib/xqsr3/command_line_utilities.rb +10 -0
- data/lib/xqsr3/command_line_utilities/map_option_string.rb +3 -2
- data/lib/xqsr3/containers.rb +11 -0
- data/lib/xqsr3/containers/frequency_map.rb +18 -1
- data/lib/xqsr3/containers/multi_map.rb +290 -29
- data/lib/xqsr3/conversion.rb +11 -0
- data/lib/xqsr3/conversion/integer_parser.rb +3 -2
- data/lib/xqsr3/diagnostics.rb +11 -0
- data/lib/xqsr3/diagnostics/inspect_builder.rb +5 -1
- data/lib/xqsr3/extensions.rb +13 -0
- data/lib/xqsr3/extensions/array.rb +3 -0
- data/lib/xqsr3/extensions/hash.rb +6 -0
- data/lib/xqsr3/extensions/hash/except.rb +26 -0
- data/lib/xqsr3/extensions/hash/slice.rb +22 -0
- data/lib/xqsr3/extensions/io/writelines.rb +38 -6
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +22 -2
- data/lib/xqsr3/hash_utilities.rb +11 -0
- data/lib/xqsr3/hash_utilities/key_matching.rb +6 -4
- data/lib/xqsr3/internal_/test_unit_version_.rb +26 -0
- data/lib/xqsr3/io/writelines.rb +49 -13
- data/lib/xqsr3/quality.rb +8 -1
- data/lib/xqsr3/quality/parameter_checking.rb +3 -2
- data/lib/xqsr3/string_utilities.rb +16 -0
- data/lib/xqsr3/string_utilities/ends_with.rb +3 -2
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +3 -2
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +3 -2
- data/lib/xqsr3/string_utilities/quote_if.rb +7 -2
- data/lib/xqsr3/string_utilities/starts_with.rb +3 -2
- data/lib/xqsr3/string_utilities/to_symbol.rb +3 -2
- data/lib/xqsr3/string_utilities/truncate.rb +3 -2
- data/lib/xqsr3/version.rb +3 -2
- data/test/unit/containers/tc_multi_map.rb +174 -16
- data/test/unit/diagnostics/tc_exception_utilities.rb +7 -3
- data/test/unit/extensions/hash/tc_deep_transform.rb +0 -1
- data/test/unit/extensions/hash/tc_except.rb +67 -0
- data/test/unit/extensions/hash/tc_hash.rb +6 -0
- data/test/unit/extensions/hash/tc_slice.rb +31 -0
- data/test/unit/extensions/io/tc_writelines.rb +36 -0
- data/test/unit/extensions/kernel/tc_raise_with_options.rb +6 -3
- data/test/unit/tc_version.rb +1 -1
- metadata +22 -7
data/lib/xqsr3/quality.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Definition of the ParameterChecking module
|
6
6
|
#
|
7
7
|
# Created: 12th February 2015
|
8
|
-
# Updated:
|
8
|
+
# Updated: 15th April 2019
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
@@ -59,7 +59,8 @@ module Quality
|
|
59
59
|
module ParameterChecking
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module Util_ # :nodoc: all
|
63
64
|
|
64
65
|
def self.join_with_or a
|
65
66
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 13th April 2016
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -59,7 +59,8 @@ module StringUtilities
|
|
59
59
|
module EndsWith
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module EndsWith_Helper_ # :nodoc: all
|
63
64
|
|
64
65
|
def self.string_ends_with_helper_ s, prefix # :nodoc:
|
65
66
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 25th January 2018
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -59,7 +59,8 @@ module StringUtilities
|
|
59
59
|
module NilIfEmpty
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module NilIfEmpty_Helper_ # :nodoc: all
|
63
64
|
|
64
65
|
def self.string_nil_if_empty_array_ s # :nodoc:
|
65
66
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 25th January 2018
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -59,7 +59,8 @@ module StringUtilities
|
|
59
59
|
module NilIfWhitespace
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module NilIfWhitespace_Helper_ # :nodoc: all
|
63
64
|
|
64
65
|
def self.string_nil_if_whitespace_array_ s # :nodoc:
|
65
66
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 3rd June 2017
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -58,10 +58,13 @@ module StringUtilities
|
|
58
58
|
module QuoteIf
|
59
59
|
|
60
60
|
private
|
61
|
-
|
61
|
+
# @!visibility private
|
62
|
+
module QuoteIf_Helper_ # :nodoc: all
|
62
63
|
|
63
64
|
def self.string_quote_if_array_ s, options # :nodoc:
|
64
65
|
|
66
|
+
#$stderr.puts "#{self}#{__method__}(s (#{s.class})='#{s}', options (#{options.class})='#{options}'"
|
67
|
+
|
65
68
|
s = s.to_s unless String === s
|
66
69
|
|
67
70
|
quotes = options[:quotes] || [ '"', '"' ]
|
@@ -69,6 +72,8 @@ module QuoteIf
|
|
69
72
|
|
70
73
|
quotables = options[:quotables] || /\s/
|
71
74
|
|
75
|
+
#$stderr.puts "quotables (#{quotables.class}): [#{quotables}]"
|
76
|
+
|
72
77
|
case quotables
|
73
78
|
when ::String
|
74
79
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 13th April 2016
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -59,7 +59,8 @@ module StringUtilities
|
|
59
59
|
module StartsWith
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module StartsWith_Helper_ # :nodoc: all
|
63
64
|
|
64
65
|
def self.string_starts_with_helper_ s, prefix # :nodoc:
|
65
66
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 14th April 2016
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -59,7 +59,8 @@ module StringUtilities
|
|
59
59
|
module ToSymbol
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module ToSymbol_Helper_ # :nodoc: all
|
63
64
|
|
64
65
|
module Constants # :nodoc:
|
65
66
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 12th April 2018
|
9
|
-
# Updated:
|
9
|
+
# Updated: 15th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
@@ -59,7 +59,8 @@ module StringUtilities
|
|
59
59
|
module Truncate
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
# @!visibility private
|
63
|
+
module Truncate_Helper_ # :nodoc: all
|
63
64
|
|
64
65
|
def self.string_truncate_with_options_ s, width, options # :nodoc:
|
65
66
|
|
data/lib/xqsr3/version.rb
CHANGED
@@ -5,12 +5,13 @@
|
|
5
5
|
# Purpose: Version for Xqsr3 library
|
6
6
|
#
|
7
7
|
# Created: 3rd April 2016
|
8
|
-
# Updated:
|
8
|
+
# Updated: 20th April 2021
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
12
|
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
+
# Copyright (c) 2019-2021, Matthew Wilson and Synesis Information Systems
|
14
15
|
# Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
|
15
16
|
# All rights reserved.
|
16
17
|
#
|
@@ -50,7 +51,7 @@
|
|
50
51
|
module Xqsr3
|
51
52
|
|
52
53
|
# Current version of the Xqsr3 library
|
53
|
-
VERSION = '0.
|
54
|
+
VERSION = '0.37.0'
|
54
55
|
|
55
56
|
private
|
56
57
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
@@ -481,7 +481,7 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
481
481
|
|
482
482
|
assert_not mm.has_key? :abc
|
483
483
|
|
484
|
-
mm.push :abc
|
484
|
+
mm.push :abc, *[ :v1, :v2 ]
|
485
485
|
|
486
486
|
assert mm.has_key? :abc
|
487
487
|
|
@@ -494,15 +494,37 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
494
494
|
|
495
495
|
mm = MultiMap.new
|
496
496
|
|
497
|
-
assert_not mm.has_value?
|
497
|
+
assert_not mm.has_value? :abc
|
498
|
+
|
499
|
+
mm.push :abc, *[ :v1, :v2 ]
|
500
|
+
|
501
|
+
assert mm.has_value? :v1
|
502
|
+
assert mm.has_value? :v2
|
503
|
+
assert_not mm.has_value? :v3
|
504
|
+
|
505
|
+
mm.delete :abc
|
506
|
+
|
507
|
+
assert_not mm.has_value? :abc
|
508
|
+
end
|
509
|
+
|
510
|
+
def test_has_values?
|
511
|
+
|
512
|
+
mm = MultiMap.new
|
513
|
+
|
514
|
+
assert_not mm.has_values? []
|
498
515
|
|
499
516
|
mm.push :abc
|
500
517
|
|
501
|
-
assert mm.
|
518
|
+
assert mm.has_values? []
|
519
|
+
|
520
|
+
mm.push :abc, * [ :v1, :v2 ]
|
521
|
+
|
522
|
+
assert_not mm.has_values? []
|
523
|
+
assert mm.has_values? [ :v1, :v2 ]
|
502
524
|
|
503
525
|
mm.delete :abc
|
504
526
|
|
505
|
-
assert_not mm.
|
527
|
+
assert_not mm.has_values? []
|
506
528
|
end
|
507
529
|
|
508
530
|
def test_key
|
@@ -512,13 +534,43 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
512
534
|
assert_nil mm.key []
|
513
535
|
assert_nil mm.key :not_defined
|
514
536
|
|
515
|
-
mm.push :abc
|
537
|
+
mm.push :abc, :v1
|
516
538
|
|
517
|
-
assert_equal :abc, mm.key(
|
539
|
+
assert_equal :abc, mm.key(:v1)
|
540
|
+
assert_nil mm.key(:v2)
|
518
541
|
|
519
|
-
mm.push :abc,
|
542
|
+
mm.push :abc, :v2
|
543
|
+
|
544
|
+
assert_equal :abc, mm.key(:v1)
|
545
|
+
assert_equal :abc, mm.key(:v2)
|
546
|
+
assert_equal :abc, mm.key(:v1, :v2)
|
547
|
+
assert_nil mm.key(:v2, :v1)
|
548
|
+
assert_nil mm.key([:v1, :v2])
|
549
|
+
|
550
|
+
mm.delete :abc
|
551
|
+
|
552
|
+
mm.push :def, :v2, :v1
|
553
|
+
|
554
|
+
assert_equal :def, mm.key(:v2, :v1)
|
555
|
+
assert_nil mm.key(:v1, :v2)
|
556
|
+
assert_equal :def, mm.key(:v1)
|
557
|
+
assert_equal :def, mm.key(:v2)
|
558
|
+
|
559
|
+
mm.delete :def
|
560
|
+
|
561
|
+
mm.push :ghi, [ :v2, :v1 ]
|
562
|
+
|
563
|
+
assert_equal :ghi, mm.key([:v2, :v1])
|
564
|
+
assert_nil mm.key([:v1, :v2])
|
565
|
+
assert_nil mm.key(:v1)
|
566
|
+
assert_nil mm.key(:v2)
|
567
|
+
|
568
|
+
mm.push :ghi, :v1
|
520
569
|
|
521
|
-
assert_equal :
|
570
|
+
assert_equal :ghi, mm.key([:v2, :v1])
|
571
|
+
assert_nil mm.key([:v1, :v2])
|
572
|
+
assert_equal :ghi, mm.key(:v1)
|
573
|
+
assert_nil mm.key(:v2)
|
522
574
|
end
|
523
575
|
|
524
576
|
def test_length_and_size
|
@@ -549,7 +601,7 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
549
601
|
test_length_and_size
|
550
602
|
end
|
551
603
|
|
552
|
-
def
|
604
|
+
def test_multi_merge
|
553
605
|
|
554
606
|
mm1 = MultiMap.new
|
555
607
|
|
@@ -562,12 +614,42 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
562
614
|
mm2.push :abc, 4, 5
|
563
615
|
mm2.push :def, 'a'
|
564
616
|
|
565
|
-
mm3 = mm1.
|
617
|
+
mm3 = mm1.multi_merge mm2
|
566
618
|
|
567
|
-
|
619
|
+
h = Hash.new
|
620
|
+
|
621
|
+
h.store :ghi, 'x'
|
622
|
+
|
623
|
+
mm4 = mm3.multi_merge h
|
624
|
+
|
625
|
+
assert_equal [ :abc, 1, :abc, 2, :abc, 3, :abc, 4, :abc, 5, :def, 'a', :ghi, 'x' ], mm4.flatten
|
626
|
+
end
|
627
|
+
|
628
|
+
def test_multi_merge!
|
629
|
+
|
630
|
+
mm1 = MultiMap.new
|
631
|
+
|
632
|
+
mm1.push :abc, 1, 2, 3
|
633
|
+
|
634
|
+
assert_equal [ :abc, 1, :abc, 2, :abc, 3 ], mm1.flatten
|
635
|
+
|
636
|
+
mm2 = MultiMap.new
|
637
|
+
|
638
|
+
mm2.push :abc, 4, 5
|
639
|
+
mm2.push :def, 'a'
|
640
|
+
|
641
|
+
mm1.multi_merge! mm2
|
642
|
+
|
643
|
+
h = Hash.new
|
644
|
+
|
645
|
+
h.store :ghi, 'x'
|
646
|
+
|
647
|
+
mm1.multi_merge! h
|
648
|
+
|
649
|
+
assert_equal [ :abc, 1, :abc, 2, :abc, 3, :abc, 4, :abc, 5, :def, 'a', :ghi, 'x' ], mm1.flatten
|
568
650
|
end
|
569
651
|
|
570
|
-
def
|
652
|
+
def test_strict_merge
|
571
653
|
|
572
654
|
mm1 = MultiMap.new
|
573
655
|
|
@@ -580,9 +662,39 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
580
662
|
mm2.push :abc, 4, 5
|
581
663
|
mm2.push :def, 'a'
|
582
664
|
|
583
|
-
mm1.
|
665
|
+
mm3 = mm1.strict_merge mm2
|
666
|
+
|
667
|
+
h = Hash.new
|
668
|
+
|
669
|
+
h.store :ghi, 'x'
|
670
|
+
|
671
|
+
mm4 = mm3.strict_merge h
|
584
672
|
|
585
|
-
assert_equal [ :abc,
|
673
|
+
assert_equal [ :abc, 4, :abc, 5, :def, 'a', :ghi, 'x' ], mm4.flatten
|
674
|
+
end
|
675
|
+
|
676
|
+
def test_strict_merge!
|
677
|
+
|
678
|
+
mm1 = MultiMap.new
|
679
|
+
|
680
|
+
mm1.push :abc, 1, 2, 3
|
681
|
+
|
682
|
+
assert_equal [ :abc, 1, :abc, 2, :abc, 3 ], mm1.flatten
|
683
|
+
|
684
|
+
mm2 = MultiMap.new
|
685
|
+
|
686
|
+
mm2.push :abc, 4, 5
|
687
|
+
mm2.push :def, 'a'
|
688
|
+
|
689
|
+
mm1.strict_merge! mm2
|
690
|
+
|
691
|
+
h = Hash.new
|
692
|
+
|
693
|
+
h.store :ghi, 'x'
|
694
|
+
|
695
|
+
mm1.strict_merge! h
|
696
|
+
|
697
|
+
assert_equal [ :abc, 4, :abc, 5, :def, 'a', :ghi, 'x' ], mm1.flatten
|
586
698
|
end
|
587
699
|
|
588
700
|
def test_push
|
@@ -698,6 +810,25 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
698
810
|
assert_equal ({ abc: [ 1, 2, 3, 4, 5 ], def: [] }), mm.to_h
|
699
811
|
end
|
700
812
|
|
813
|
+
def test_values_unflattened
|
814
|
+
|
815
|
+
mm = MultiMap.new
|
816
|
+
|
817
|
+
assert_equal [], mm.values_unflattened
|
818
|
+
|
819
|
+
mm.store :abc
|
820
|
+
|
821
|
+
assert_equal [ [] ], mm.values_unflattened
|
822
|
+
|
823
|
+
mm.store :abc, 1, 2, '3', nil, false
|
824
|
+
|
825
|
+
assert_equal [ [ 1, 2, '3', nil, false ] ], mm.values_unflattened
|
826
|
+
|
827
|
+
mm.store :def, true
|
828
|
+
|
829
|
+
assert_equal [ [ 1, 2, '3', nil, false ], [ true ] ], mm.values_unflattened
|
830
|
+
end
|
831
|
+
|
701
832
|
def test_values
|
702
833
|
|
703
834
|
mm = MultiMap.new
|
@@ -706,11 +837,38 @@ class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
|
706
837
|
|
707
838
|
mm.store :abc
|
708
839
|
|
709
|
-
assert_equal [
|
840
|
+
assert_equal [], mm.values
|
710
841
|
|
711
842
|
mm.store :abc, 1, 2, '3', nil, false
|
712
843
|
|
713
|
-
assert_equal [
|
844
|
+
assert_equal [ 1, 2, '3', nil, false ], mm.values
|
845
|
+
|
846
|
+
mm.store :def, true
|
847
|
+
|
848
|
+
assert_equal [ 1, 2, '3', nil, false, true ], mm.values
|
849
|
+
end
|
850
|
+
|
851
|
+
def test_to_s
|
852
|
+
|
853
|
+
mm = MultiMap[]
|
854
|
+
|
855
|
+
assert_equal "{}", mm.to_s
|
856
|
+
|
857
|
+
mm.store :abc
|
858
|
+
|
859
|
+
assert_equal "{:abc=>[]}", mm.to_s
|
860
|
+
|
861
|
+
mm.store :abc, 1
|
862
|
+
|
863
|
+
assert_equal "{:abc=>[1]}", mm.to_s
|
864
|
+
|
865
|
+
mm.store :abc, 1, 23
|
866
|
+
|
867
|
+
assert_equal "{:abc=>[1, 23]}", mm.to_s
|
868
|
+
|
869
|
+
mm.store :def, *(0...10).to_a
|
870
|
+
|
871
|
+
assert_equal "{:abc=>[1, 23], :def=>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}", mm.to_s
|
714
872
|
end
|
715
873
|
end
|
716
874
|
|