xqsr3 0.38.1 → 0.38.2
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 +5 -5
- data/examples/count_word_frequencies.md +1 -1
- data/examples/count_word_frequencies.rb +1 -1
- data/lib/xqsr3/array_utilities/join_with_or.rb +9 -10
- data/lib/xqsr3/command_line_utilities/map_option_string.rb +9 -10
- data/lib/xqsr3/containers/frequency_map.rb +8 -7
- data/lib/xqsr3/containers/multi_map.rb +8 -7
- data/lib/xqsr3/conversion/bool_parser.rb +8 -9
- data/lib/xqsr3/conversion/integer_parser.rb +8 -9
- data/lib/xqsr3/diagnostics/exception_utilities.rb +9 -8
- data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +11 -7
- data/lib/xqsr3/diagnostics/inspect_builder.rb +8 -8
- data/lib/xqsr3/doc_.rb +8 -8
- data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +8 -7
- data/lib/xqsr3/extensions/enumerable/detect_map.rb +8 -8
- data/lib/xqsr3/extensions/enumerable/unique.rb +3 -3
- data/lib/xqsr3/extensions/io/writelines.rb +8 -8
- data/lib/xqsr3/extensions/kernel/integer.rb +8 -8
- data/lib/xqsr3/extensions/kernel/raise_with_options.rb +9 -8
- data/lib/xqsr3/extensions/string/map_option_string.rb +0 -1
- data/lib/xqsr3/extensions/string/quote_if.rb +0 -1
- data/lib/xqsr3/extensions/string/to_bool.rb +0 -1
- data/lib/xqsr3/extensions/string/truncate.rb +0 -1
- data/lib/xqsr3/extensions/test/unit/assert_eql.rb +2 -2
- data/lib/xqsr3/extensions/test/unit/assert_false.rb +1 -2
- data/lib/xqsr3/extensions/test/unit/assert_not.rb +0 -1
- data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +2 -2
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +0 -1
- data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +0 -1
- data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +0 -1
- data/lib/xqsr3/extensions/test/unit/assert_true.rb +1 -2
- data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +0 -2
- data/lib/xqsr3/hash_utilities/deep_transform.rb +11 -11
- data/lib/xqsr3/hash_utilities/key_matching.rb +8 -8
- data/lib/xqsr3/internal_/test_unit_version_.rb +45 -3
- data/lib/xqsr3/io/writelines.rb +8 -8
- data/lib/xqsr3/quality/parameter_checking.rb +105 -105
- data/lib/xqsr3/string_utilities/ends_with.rb +8 -8
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +8 -9
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +9 -9
- data/lib/xqsr3/string_utilities/quote_if.rb +8 -9
- data/lib/xqsr3/string_utilities/starts_with.rb +8 -8
- data/lib/xqsr3/string_utilities/to_symbol.rb +8 -8
- data/lib/xqsr3/string_utilities/truncate.rb +8 -9
- data/lib/xqsr3/version.rb +9 -10
- data/test/performance/frequency_map.rb +1 -15
- data/test/scratch/test_assert_raise_with_message.rb +1 -2
- data/test/unit/array_utilities/tc_join_with_or.rb +0 -2
- data/test/unit/containers/tc_frequency_map.rb +56 -3
- data/test/unit/containers/tc_multi_map.rb +56 -5
- data/test/unit/conversion/tc_integer_parser.rb +1 -1
- data/test/unit/conversion/tc_to_bool.rb +1 -1
- data/test/unit/extensions/hash/tc_hash.rb +1 -1
- data/test/unit/extensions/hash/tc_slice.rb +1 -1
- data/test/unit/extensions/object/tc_inspect.rb +1 -1
- data/test/unit/io/tc_writelines.rb +0 -2
- data/test/unit/quality/tc_parameter_checking.rb +1 -1
- data/test/unit/string_utilities/tc_truncate.rb +1 -1
- metadata +6 -7
|
@@ -6,7 +6,7 @@ module Assertions
|
|
|
6
6
|
|
|
7
7
|
unless respond_to? :assert_false
|
|
8
8
|
|
|
9
|
-
# Assert that +expression+ is +false+
|
|
9
|
+
# Assert that +expression+ is +false+ (and not merely _falsey_)
|
|
10
10
|
def assert_false(expression, failure_message = '')
|
|
11
11
|
|
|
12
12
|
assert ::FalseClass === (expression), failure_message
|
|
@@ -17,4 +17,3 @@ end # class Assertions
|
|
|
17
17
|
end # module Unit
|
|
18
18
|
end # module Test
|
|
19
19
|
|
|
20
|
-
|
|
@@ -6,7 +6,8 @@ module Assertions
|
|
|
6
6
|
|
|
7
7
|
unless respond_to? :assert_not_eql
|
|
8
8
|
|
|
9
|
-
# Assert that +expected+ and +actual+ have different hash keys
|
|
9
|
+
# Assert that +expected+ and +actual+ have different hash keys, as
|
|
10
|
+
# evaluated by the instance method +eq?+
|
|
10
11
|
def assert_not_eql(expected, actual, failure_message = '')
|
|
11
12
|
|
|
12
13
|
assert !(expected.eql?(actual)), failure_message
|
|
@@ -17,4 +18,3 @@ end # class Assertions
|
|
|
17
18
|
end # module Unit
|
|
18
19
|
end # module Test
|
|
19
20
|
|
|
20
|
-
|
|
@@ -6,7 +6,7 @@ module Assertions
|
|
|
6
6
|
|
|
7
7
|
unless respond_to? :assert_true
|
|
8
8
|
|
|
9
|
-
# Assert that +expression+ is +true+
|
|
9
|
+
# Assert that +expression+ is +true+ (and not merely _truey_)
|
|
10
10
|
def assert_true(expression, failure_message = '')
|
|
11
11
|
|
|
12
12
|
assert ::TrueClass === (expression), failure_message
|
|
@@ -17,4 +17,3 @@ end # class Assertions
|
|
|
17
17
|
end # module Unit
|
|
18
18
|
end # module Test
|
|
19
19
|
|
|
20
|
-
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/hash_utilities/deep_transform.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
6
|
-
# module
|
|
5
|
+
# Purpose: Definition of the Xqsr3::HashUtilities::DeepTransform module
|
|
7
6
|
#
|
|
8
|
-
# Created:
|
|
9
|
-
# Updated:
|
|
7
|
+
# Created: 3rd June 2017
|
|
8
|
+
# Updated: 11th December 2023
|
|
10
9
|
#
|
|
11
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
11
|
#
|
|
13
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
14
13
|
#
|
|
15
|
-
# Copyright (c)
|
|
14
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
15
|
+
# Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
18
18
|
# Redistribution and use in source and binary forms, with or without
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
27
|
# documentation and/or other materials provided with the distribution.
|
|
28
28
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
30
|
# contributors may be used to endorse or promote products derived from
|
|
31
31
|
# this software without specific prior written permission.
|
|
32
32
|
#
|
|
@@ -66,7 +66,7 @@ module DeepTransform
|
|
|
66
66
|
case block.arity
|
|
67
67
|
when 1
|
|
68
68
|
|
|
69
|
-
h =
|
|
69
|
+
h =
|
|
70
70
|
Hash[h.map do |k, v|
|
|
71
71
|
|
|
72
72
|
k = k.deep_transform(&block) if ::Hash === k
|
|
@@ -76,7 +76,7 @@ module DeepTransform
|
|
|
76
76
|
end]
|
|
77
77
|
when 2
|
|
78
78
|
|
|
79
|
-
h =
|
|
79
|
+
h =
|
|
80
80
|
Hash[h.map do |k, v|
|
|
81
81
|
|
|
82
82
|
k = k.deep_transform(&block) if ::Hash === k
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/hash_utilities/key_matching.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
6
|
-
# module
|
|
5
|
+
# Purpose: Definition of the Xqsr3::HashUtilities::KeyMatching module
|
|
7
6
|
#
|
|
8
|
-
# Created:
|
|
9
|
-
# Updated:
|
|
7
|
+
# Created: 15th November 2017
|
|
8
|
+
# Updated: 11th December 2023
|
|
10
9
|
#
|
|
11
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
11
|
#
|
|
13
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
14
13
|
#
|
|
14
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
27
|
# documentation and/or other materials provided with the distribution.
|
|
28
28
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
30
|
# contributors may be used to endorse or promote products derived from
|
|
31
31
|
# this software without specific prior written permission.
|
|
32
32
|
#
|
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# ######################################################################## #
|
|
3
|
+
# File: lib/xqsr3/internal_/test_unit_version_.rb
|
|
4
|
+
#
|
|
5
|
+
# Purpose: Provides reliable mechanism for checking the version of the
|
|
6
|
+
# Test::Unit module
|
|
7
|
+
#
|
|
8
|
+
# Created: March 2nd 2019
|
|
9
|
+
# Updated: 11th December 2023
|
|
10
|
+
#
|
|
11
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
|
+
#
|
|
13
|
+
# Author: Matthew Wilson
|
|
14
|
+
#
|
|
15
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
16
|
+
# All rights reserved.
|
|
17
|
+
#
|
|
18
|
+
# Redistribution and use in source and binary forms, with or without
|
|
19
|
+
# modification, are permitted provided that the following conditions are
|
|
20
|
+
# met:
|
|
21
|
+
#
|
|
22
|
+
# * Redistributions of source code must retain the above copyright notice,
|
|
23
|
+
# this list of conditions and the following disclaimer.
|
|
24
|
+
#
|
|
25
|
+
# * Redistributions in binary form must reproduce the above copyright
|
|
26
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
27
|
+
# documentation and/or other materials provided with the distribution.
|
|
28
|
+
#
|
|
29
|
+
# * Neither the name of the copyright holder nor the names of its
|
|
30
|
+
# contributors may be used to endorse or promote products derived from
|
|
31
|
+
# this software without specific prior written permission.
|
|
32
|
+
#
|
|
33
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
34
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
35
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
36
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
37
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
38
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
39
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
40
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
41
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
42
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
43
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
44
|
+
#
|
|
45
|
+
# ######################################################################## #
|
|
46
|
+
|
|
4
47
|
|
|
5
48
|
require 'test/unit'
|
|
6
49
|
|
|
@@ -137,4 +180,3 @@ end # module Xqsr3
|
|
|
137
180
|
|
|
138
181
|
# ############################## end of file ############################# #
|
|
139
182
|
|
|
140
|
-
|
data/lib/xqsr3/io/writelines.rb
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/io/writelines.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
5
|
+
# Purpose: Adds a writelines() method to the IO module
|
|
6
6
|
#
|
|
7
|
-
# Created:
|
|
8
|
-
# Updated:
|
|
7
|
+
# Created: 13th April 2007
|
|
8
|
+
# Updated: 11th December 2023
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
11
11
|
#
|
|
12
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
13
13
|
#
|
|
14
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
14
15
|
# Copyright (c) 2007-2019, Matthew Wilson and Synesis Software
|
|
15
16
|
# All rights reserved.
|
|
16
17
|
#
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
26
27
|
# documentation and/or other materials provided with the distribution.
|
|
27
28
|
#
|
|
28
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
29
30
|
# contributors may be used to endorse or promote products derived from
|
|
30
31
|
# this software without specific prior written permission.
|
|
31
32
|
#
|
|
@@ -228,4 +229,3 @@ end # module Xqsr3
|
|
|
228
229
|
|
|
229
230
|
# ############################## end of file ############################# #
|
|
230
231
|
|
|
231
|
-
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/quality/parameter_checking.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
5
|
+
# Purpose: Definition of the ParameterChecking module
|
|
6
6
|
#
|
|
7
|
-
# Created:
|
|
8
|
-
# Updated:
|
|
7
|
+
# Created: 12th February 2015
|
|
8
|
+
# Updated: 1st January 2024
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
11
11
|
#
|
|
12
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
13
13
|
#
|
|
14
|
-
# Copyright (c) 2019-
|
|
14
|
+
# Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
27
|
# documentation and/or other materials provided with the distribution.
|
|
28
28
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
30
|
# contributors may be used to endorse or promote products derived from
|
|
31
31
|
# this software without specific prior written permission.
|
|
32
32
|
#
|
|
@@ -54,8 +54,9 @@
|
|
|
54
54
|
module Xqsr3
|
|
55
55
|
module Quality
|
|
56
56
|
|
|
57
|
-
# Inclusion module that creates class and instance methods +
|
|
58
|
-
# that may be used to check parameter values
|
|
57
|
+
# Inclusion module that creates class and instance methods +check_option()+
|
|
58
|
+
# and +check_parameter()+ that may be used to check option/parameter values
|
|
59
|
+
# and types.
|
|
59
60
|
#
|
|
60
61
|
module ParameterChecking
|
|
61
62
|
|
|
@@ -282,7 +283,6 @@ module ParameterChecking
|
|
|
282
283
|
options ||= {}
|
|
283
284
|
message = options[:message]
|
|
284
285
|
treat_as_option = options[:treat_as_option]
|
|
285
|
-
return_value = value
|
|
286
286
|
param_s = treat_as_option ? 'option' : 'parameter'
|
|
287
287
|
allow_nil = options[:allow_nil] || options[:nil]
|
|
288
288
|
|
|
@@ -463,6 +463,94 @@ module ParameterChecking
|
|
|
463
463
|
end
|
|
464
464
|
end
|
|
465
465
|
|
|
466
|
+
# run block
|
|
467
|
+
|
|
468
|
+
if value and block
|
|
469
|
+
|
|
470
|
+
warn "#{self}::check_parameter: block arity must be 1 or 2" unless (1..2).include? block.arity
|
|
471
|
+
|
|
472
|
+
r = nil
|
|
473
|
+
|
|
474
|
+
begin
|
|
475
|
+
|
|
476
|
+
if 1 == block.arity
|
|
477
|
+
|
|
478
|
+
r = block.call(value)
|
|
479
|
+
else
|
|
480
|
+
|
|
481
|
+
r = block.call(value, options)
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
rescue StandardError => x
|
|
485
|
+
|
|
486
|
+
xmsg = x.message || ''
|
|
487
|
+
|
|
488
|
+
if xmsg.empty?
|
|
489
|
+
|
|
490
|
+
xmsg ||= message
|
|
491
|
+
|
|
492
|
+
if xmsg.empty?
|
|
493
|
+
|
|
494
|
+
s_name = name.is_a?(String) ? "'#{name}' " : ''
|
|
495
|
+
xmsg = "#{param_s} #{s_name}failed validation against caller-supplied block"
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
raise $!, xmsg, $!.backtrace
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
raise
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
if r.is_a?(::Exception)
|
|
505
|
+
|
|
506
|
+
# An exception returned from the block, so raise it, with
|
|
507
|
+
# its message or a custom message
|
|
508
|
+
|
|
509
|
+
x = r
|
|
510
|
+
xmsg = x.message || ''
|
|
511
|
+
|
|
512
|
+
if xmsg.empty?
|
|
513
|
+
|
|
514
|
+
xmsg ||= message
|
|
515
|
+
|
|
516
|
+
if xmsg.empty?
|
|
517
|
+
|
|
518
|
+
s_name = name.is_a?(String) ? "'#{name}' " : ''
|
|
519
|
+
xmsg = "#{param_s} #{s_name}failed validation against caller-supplied block"
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
raise x, xmsg
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
raise x
|
|
526
|
+
|
|
527
|
+
elsif !r
|
|
528
|
+
|
|
529
|
+
failed_check = true
|
|
530
|
+
|
|
531
|
+
unless options[:nothrow]
|
|
532
|
+
|
|
533
|
+
s_name = name.is_a?(String) ? "'#{name}' " : ''
|
|
534
|
+
xmsg = "#{param_s} #{s_name}failed validation against caller-supplied block"
|
|
535
|
+
|
|
536
|
+
if value.is_a?(::Numeric)
|
|
537
|
+
|
|
538
|
+
raise RangeError, xmsg
|
|
539
|
+
else
|
|
540
|
+
|
|
541
|
+
raise ArgumentError, xmsg
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
elsif r.is_a?(::TrueClass)
|
|
546
|
+
|
|
547
|
+
;
|
|
548
|
+
else
|
|
549
|
+
|
|
550
|
+
value = r
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
|
|
466
554
|
# check value(s)
|
|
467
555
|
|
|
468
556
|
unless value.nil? || !(values = options[:values])
|
|
@@ -478,13 +566,14 @@ module ParameterChecking
|
|
|
478
566
|
case v
|
|
479
567
|
when ::String
|
|
480
568
|
|
|
481
|
-
|
|
569
|
+
:string
|
|
482
570
|
when ::Array
|
|
483
571
|
|
|
484
|
-
|
|
485
|
-
|
|
572
|
+
:array_of_strings if v.all? { |s| ::String === s }
|
|
573
|
+
else
|
|
486
574
|
|
|
487
|
-
|
|
575
|
+
nil
|
|
576
|
+
end
|
|
488
577
|
end : lambda { |v| nil }
|
|
489
578
|
|
|
490
579
|
value_ic = do_case.call(value)
|
|
@@ -590,95 +679,7 @@ module ParameterChecking
|
|
|
590
679
|
end
|
|
591
680
|
end
|
|
592
681
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if value and block
|
|
596
|
-
|
|
597
|
-
warn "#{self}::check_parameter: block arity must be 1 or 2" unless (1..2).include? block.arity
|
|
598
|
-
|
|
599
|
-
r = nil
|
|
600
|
-
|
|
601
|
-
begin
|
|
602
|
-
|
|
603
|
-
if 1 == block.arity
|
|
604
|
-
|
|
605
|
-
r = block.call(value)
|
|
606
|
-
else
|
|
607
|
-
|
|
608
|
-
r = block.call(value, options)
|
|
609
|
-
end
|
|
610
|
-
|
|
611
|
-
rescue StandardError => x
|
|
612
|
-
|
|
613
|
-
xmsg = x.message || ''
|
|
614
|
-
|
|
615
|
-
if xmsg.empty?
|
|
616
|
-
|
|
617
|
-
xmsg ||= message
|
|
618
|
-
|
|
619
|
-
if xmsg.empty?
|
|
620
|
-
|
|
621
|
-
s_name = name.is_a?(String) ? "'#{name}' " : ''
|
|
622
|
-
xmsg = "#{param_s} #{s_name}failed validation against caller-supplied block"
|
|
623
|
-
end
|
|
624
|
-
|
|
625
|
-
raise $!, xmsg, $!.backtrace
|
|
626
|
-
end
|
|
627
|
-
|
|
628
|
-
raise
|
|
629
|
-
end
|
|
630
|
-
|
|
631
|
-
if r.is_a?(::Exception)
|
|
632
|
-
|
|
633
|
-
# An exception returned from the block, so raise it, with
|
|
634
|
-
# its message or a custom message
|
|
635
|
-
|
|
636
|
-
x = r
|
|
637
|
-
xmsg = x.message || ''
|
|
638
|
-
|
|
639
|
-
if xmsg.empty?
|
|
640
|
-
|
|
641
|
-
xmsg ||= message
|
|
642
|
-
|
|
643
|
-
if xmsg.empty?
|
|
644
|
-
|
|
645
|
-
s_name = name.is_a?(String) ? "'#{name}' " : ''
|
|
646
|
-
xmsg = "#{param_s} #{s_name}failed validation against caller-supplied block"
|
|
647
|
-
end
|
|
648
|
-
|
|
649
|
-
raise x, xmsg
|
|
650
|
-
end
|
|
651
|
-
|
|
652
|
-
raise x
|
|
653
|
-
|
|
654
|
-
elsif !r
|
|
655
|
-
|
|
656
|
-
failed_check = true
|
|
657
|
-
|
|
658
|
-
unless options[:nothrow]
|
|
659
|
-
|
|
660
|
-
s_name = name.is_a?(String) ? "'#{name}' " : ''
|
|
661
|
-
xmsg = "#{param_s} #{s_name}failed validation against caller-supplied block"
|
|
662
|
-
|
|
663
|
-
if value.is_a?(::Numeric)
|
|
664
|
-
|
|
665
|
-
raise RangeError, xmsg
|
|
666
|
-
else
|
|
667
|
-
|
|
668
|
-
raise ArgumentError, xmsg
|
|
669
|
-
end
|
|
670
|
-
end
|
|
671
|
-
|
|
672
|
-
elsif r.is_a?(::TrueClass)
|
|
673
|
-
|
|
674
|
-
;
|
|
675
|
-
else
|
|
676
|
-
|
|
677
|
-
return_value = r
|
|
678
|
-
end
|
|
679
|
-
end
|
|
680
|
-
|
|
681
|
-
failed_check ? nil : return_value
|
|
682
|
+
failed_check ? nil : value
|
|
682
683
|
end
|
|
683
684
|
|
|
684
685
|
end # module ParameterChecking
|
|
@@ -688,4 +689,3 @@ end # module Xqsr3
|
|
|
688
689
|
|
|
689
690
|
# ############################## end of file ############################# #
|
|
690
691
|
|
|
691
|
-
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/string_utilities/ends_with.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
6
|
-
# module
|
|
5
|
+
# Purpose: Definition of the Xqsr3::StringUtilities::EndsWith module
|
|
7
6
|
#
|
|
8
|
-
# Created:
|
|
9
|
-
# Updated:
|
|
7
|
+
# Created: 13th April 2016
|
|
8
|
+
# Updated: 11th December 2023
|
|
10
9
|
#
|
|
11
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
11
|
#
|
|
13
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
14
13
|
#
|
|
14
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
27
|
# documentation and/or other materials provided with the distribution.
|
|
28
28
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
30
|
# contributors may be used to endorse or promote products derived from
|
|
31
31
|
# this software without specific prior written permission.
|
|
32
32
|
#
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/string_utilities/nil_if_empty.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
6
|
-
# module
|
|
5
|
+
# Purpose: Definition of the Xqsr3::StringUtilities::NilIfEmpty module
|
|
7
6
|
#
|
|
8
|
-
# Created:
|
|
9
|
-
# Updated:
|
|
7
|
+
# Created: 25th January 2018
|
|
8
|
+
# Updated: 11th December 2023
|
|
10
9
|
#
|
|
11
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
11
|
#
|
|
13
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
14
13
|
#
|
|
14
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2018-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
27
|
# documentation and/or other materials provided with the distribution.
|
|
28
28
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
30
|
# contributors may be used to endorse or promote products derived from
|
|
31
31
|
# this software without specific prior written permission.
|
|
32
32
|
#
|
|
@@ -97,4 +97,3 @@ end # module Xqsr3
|
|
|
97
97
|
|
|
98
98
|
# ############################## end of file ############################# #
|
|
99
99
|
|
|
100
|
-
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/string_utilities/nil_if_whitespace.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
6
|
-
#
|
|
5
|
+
# Purpose: Definition of the Xqsr3::StringUtilities::NilIfWhitespace
|
|
6
|
+
# module
|
|
7
7
|
#
|
|
8
|
-
# Created:
|
|
9
|
-
# Updated:
|
|
8
|
+
# Created: 25th January 2018
|
|
9
|
+
# Updated: 11th December 2023
|
|
10
10
|
#
|
|
11
|
-
# Home:
|
|
11
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
12
|
#
|
|
13
|
-
# Author:
|
|
13
|
+
# Author: Matthew Wilson
|
|
14
14
|
#
|
|
15
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
15
16
|
# Copyright (c) 2018-2019, Matthew Wilson and Synesis Software
|
|
16
17
|
# All rights reserved.
|
|
17
18
|
#
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
28
|
# documentation and/or other materials provided with the distribution.
|
|
28
29
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
30
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
31
|
# contributors may be used to endorse or promote products derived from
|
|
31
32
|
# this software without specific prior written permission.
|
|
32
33
|
#
|
|
@@ -98,4 +99,3 @@ end # module Xqsr3
|
|
|
98
99
|
|
|
99
100
|
# ############################## end of file ############################# #
|
|
100
101
|
|
|
101
|
-
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# ######################################################################## #
|
|
3
|
-
# File:
|
|
3
|
+
# File: lib/xqsr3/string_utilities/quote_if.rb
|
|
4
4
|
#
|
|
5
|
-
# Purpose:
|
|
6
|
-
# module
|
|
5
|
+
# Purpose: Definition of the Xqsr3::StringUtilities::QuoteIf module
|
|
7
6
|
#
|
|
8
|
-
# Created:
|
|
9
|
-
# Updated:
|
|
7
|
+
# Created: 3rd June 2017
|
|
8
|
+
# Updated: 11th December 2023
|
|
10
9
|
#
|
|
11
|
-
# Home:
|
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
|
12
11
|
#
|
|
13
|
-
# Author:
|
|
12
|
+
# Author: Matthew Wilson
|
|
14
13
|
#
|
|
14
|
+
# Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
# notice, this list of conditions and the following disclaimer in the
|
|
27
27
|
# documentation and/or other materials provided with the distribution.
|
|
28
28
|
#
|
|
29
|
-
# * Neither the names of the copyright
|
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
|
30
30
|
# contributors may be used to endorse or promote products derived from
|
|
31
31
|
# this software without specific prior written permission.
|
|
32
32
|
#
|
|
@@ -125,4 +125,3 @@ end # module Xqsr3
|
|
|
125
125
|
|
|
126
126
|
# ############################## end of file ############################# #
|
|
127
127
|
|
|
128
|
-
|