xqsr3 0.38.2 → 0.39.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -6
- data/examples/count_word_frequencies.md +12 -12
- data/examples/count_word_frequencies.rb +4 -4
- data/lib/xqsr3/array_utilities/join_with_or.rb +47 -47
- data/lib/xqsr3/array_utilities.rb +2 -2
- data/lib/xqsr3/command_line_utilities/map_option_string.rb +60 -60
- data/lib/xqsr3/command_line_utilities.rb +2 -2
- data/lib/xqsr3/containers/frequency_map.rb +399 -399
- data/lib/xqsr3/containers/multi_map.rb +448 -448
- data/lib/xqsr3/containers.rb +3 -3
- data/lib/xqsr3/conversion/bool_parser.rb +51 -51
- data/lib/xqsr3/conversion/integer_parser.rb +87 -87
- data/lib/xqsr3/conversion.rb +3 -3
- data/lib/xqsr3/diagnostics/exception_utilities.rb +145 -145
- data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +90 -90
- data/lib/xqsr3/diagnostics/inspect_builder.rb +80 -80
- data/lib/xqsr3/diagnostics.rb +3 -3
- data/lib/xqsr3/doc_.rb +130 -130
- data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
- data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +12 -12
- data/lib/xqsr3/extensions/enumerable/detect_map.rb +35 -35
- data/lib/xqsr3/extensions/enumerable/unique.rb +29 -28
- data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -1
- data/lib/xqsr3/extensions/hash/except.rb +16 -16
- data/lib/xqsr3/extensions/hash/has_match.rb +10 -10
- data/lib/xqsr3/extensions/hash/match.rb +10 -10
- data/lib/xqsr3/extensions/hash/slice.rb +11 -11
- data/lib/xqsr3/extensions/hash.rb +1 -1
- data/lib/xqsr3/extensions/integer/to_s_grp.rb +118 -0
- data/lib/xqsr3/extensions/integer.rb +3 -0
- data/lib/xqsr3/extensions/io/writelines.rb +28 -28
- data/lib/xqsr3/extensions/kernel/integer.rb +20 -20
- data/lib/xqsr3/extensions/kernel/raise_with_options.rb +8 -8
- data/lib/xqsr3/extensions/kernel.rb +1 -0
- data/lib/xqsr3/extensions/string/ends_with.rb +1 -1
- data/lib/xqsr3/extensions/string/map_option_string.rb +4 -4
- data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -1
- data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -1
- data/lib/xqsr3/extensions/string/quote_if.rb +1 -1
- data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
- data/lib/xqsr3/extensions/string/to_bool.rb +8 -8
- data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
- data/lib/xqsr3/extensions/string/truncate.rb +1 -1
- data/lib/xqsr3/extensions/test/unit/assert_eql.rb +7 -7
- data/lib/xqsr3/extensions/test/unit/assert_false.rb +6 -6
- data/lib/xqsr3/extensions/test/unit/assert_not.rb +6 -6
- data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +7 -7
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -61
- data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +7 -7
- data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +7 -7
- data/lib/xqsr3/extensions/test/unit/assert_true.rb +6 -6
- data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +36 -36
- data/lib/xqsr3/extensions.rb +5 -5
- data/lib/xqsr3/hash_utilities/deep_transform.rb +65 -65
- data/lib/xqsr3/hash_utilities/key_matching.rb +77 -77
- data/lib/xqsr3/hash_utilities.rb +3 -3
- data/lib/xqsr3/internal_/test_unit_version_.rb +85 -85
- data/lib/xqsr3/io/writelines.rb +119 -119
- data/lib/xqsr3/quality/parameter_checking.rb +445 -445
- data/lib/xqsr3/quality.rb +2 -2
- data/lib/xqsr3/string_utilities/ends_with.rb +59 -59
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +28 -28
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +29 -29
- data/lib/xqsr3/string_utilities/quote_if.rb +50 -50
- data/lib/xqsr3/string_utilities/starts_with.rb +59 -59
- data/lib/xqsr3/string_utilities/to_symbol.rb +75 -75
- data/lib/xqsr3/string_utilities/truncate.rb +55 -55
- data/lib/xqsr3/string_utilities.rb +8 -8
- data/lib/xqsr3/version.rb +12 -12
- data/test/performance/frequency_map.rb +12 -12
- data/test/scratch/test_assert_raise_with_message.rb +11 -11
- data/test/unit/array_utilities/tc_join_with_or.rb +140 -140
- data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
- data/test/unit/containers/tc_frequency_map.rb +591 -591
- data/test/unit/containers/tc_multi_map.rb +558 -558
- data/test/unit/conversion/tc_integer_parser.rb +72 -72
- data/test/unit/conversion/tc_to_bool.rb +25 -25
- data/test/unit/diagnostics/exceptions/tc_with_cause.rb +165 -165
- data/test/unit/diagnostics/tc_exception_utilities.rb +156 -156
- data/test/unit/extensions/enumerable/tc_collect_with_index.rb +14 -14
- data/test/unit/extensions/enumerable/tc_detect_map.rb +20 -20
- data/test/unit/extensions/enumerable/tc_unique.rb +34 -34
- data/test/unit/extensions/hash/tc_deep_transform.rb +22 -22
- data/test/unit/extensions/hash/tc_except.rb +28 -28
- data/test/unit/extensions/hash/tc_slice.rb +13 -13
- data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
- data/test/unit/extensions/integer/ts_all.rb +12 -0
- data/test/unit/extensions/io/tc_writelines.rb +77 -77
- data/test/unit/extensions/kernel/tc_integer.rb +75 -75
- data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
- data/test/unit/extensions/object/tc_inspect.rb +50 -50
- data/test/unit/extensions/string/tc_bool.tb +24 -24
- data/test/unit/extensions/string/tc_ends_with.rb +53 -53
- data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
- data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
- data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
- data/test/unit/extensions/string/tc_quote_if.rb +18 -18
- data/test/unit/extensions/string/tc_starts_with.rb +53 -53
- data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
- data/test/unit/extensions/string/tc_truncate.rb +18 -18
- data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
- data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
- data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
- data/test/unit/hash_utilities/tc_has_match.rb +70 -70
- data/test/unit/hash_utilities/tc_match.rb +83 -83
- data/test/unit/io/tc_writelines.rb +106 -106
- data/test/unit/quality/tc_parameter_checking.rb +389 -389
- data/test/unit/string_utilities/tc_truncate.rb +27 -27
- data/test/unit/tc_version.rb +15 -15
- metadata +6 -2
@@ -2,16 +2,16 @@
|
|
2
2
|
# ######################################################################## #
|
3
3
|
# File: lib/xqsr3/hash_utilities/deep_transform.rb
|
4
4
|
#
|
5
|
-
# Purpose: Definition of the Xqsr3::HashUtilities::DeepTransform module
|
5
|
+
# Purpose: Definition of the ::Xqsr3::HashUtilities::DeepTransform module
|
6
6
|
#
|
7
7
|
# Created: 3rd June 2017
|
8
|
-
# Updated:
|
8
|
+
# Updated: 29th March 2024
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
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) 2017-2019, Matthew Wilson and Synesis Software
|
16
16
|
# All rights reserved.
|
17
17
|
#
|
@@ -58,94 +58,94 @@ module HashUtilities
|
|
58
58
|
|
59
59
|
module DeepTransform
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
private
|
62
|
+
def self.do_deep_transform_on_hashlike_ h, &block # :nodoc:
|
63
63
|
|
64
|
-
|
64
|
+
::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :map ]
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
case block.arity
|
67
|
+
when 1
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
h =
|
70
|
+
Hash[h.map do |k, v|
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
k = k.deep_transform(&block) if ::Hash === k
|
73
|
+
v = v.deep_transform(&block) if ::Hash === v
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
[yield(k), v]
|
76
|
+
end]
|
77
|
+
when 2
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
h =
|
80
|
+
Hash[h.map do |k, v|
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
k = k.deep_transform(&block) if ::Hash === k
|
83
|
+
v = v.deep_transform(&block) if ::Hash === v
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
yield(k, v)
|
86
|
+
end]
|
87
|
+
else
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
raise ArgumentError, "block arity must be 1 or 2"
|
90
|
+
end
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
h
|
93
|
+
end
|
94
94
|
|
95
|
-
|
95
|
+
def do_deep_transform_on_self_ &block # :nodoc:
|
96
96
|
|
97
|
-
|
97
|
+
::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[]=, :delete, :keys ]
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
case block.arity
|
100
|
+
when 1
|
101
101
|
|
102
|
-
|
102
|
+
self.keys.each do |k|
|
103
103
|
|
104
|
-
|
104
|
+
v = self.delete k
|
105
105
|
|
106
|
-
|
107
|
-
|
106
|
+
k = k.deep_transform(&block) if ::Hash === k
|
107
|
+
v = v.deep_transform(&block) if ::Hash === v
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
self[yield(k)] = v
|
110
|
+
end
|
111
|
+
when 2
|
112
112
|
|
113
|
-
|
113
|
+
self.keys.each do |k|
|
114
114
|
|
115
|
-
|
115
|
+
v = self.delete k
|
116
116
|
|
117
|
-
|
118
|
-
|
117
|
+
k = k.deep_transform(&block) if ::Hash === k
|
118
|
+
v = v.deep_transform(&block) if ::Hash === v
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
k, v = yield(k, v)
|
121
|
+
end
|
122
|
+
else
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
raise ArgumentError, "block arity must be 1 or 2"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
public
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
129
|
+
# Executes the given mandatory 1- or 2-parameter block on the receiving
|
130
|
+
# instance, which must be a Hash or a type that responds to the +map+
|
131
|
+
# message, returning a copy of the instance in which keys (1-parameter
|
132
|
+
# block) or keys and values (2-parameter block) are transformed.
|
133
|
+
def deep_transform &block
|
134
134
|
|
135
|
-
|
136
|
-
|
135
|
+
DeepTransform.do_deep_transform_on_hashlike_(self, &block)
|
136
|
+
end
|
137
137
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
138
|
+
# Executes the given mandatory 1- or 2-parameter block on the receiving
|
139
|
+
# instance, whihc must be a Hash or a type that responds to +[]+,
|
140
|
+
# +delete+, and +keys+ messages, changing the keys (1-parameter block)
|
141
|
+
# or keys and values (2-parameter block).
|
142
|
+
#
|
143
|
+
# @note This method is not strongly exception-safe - failure during
|
144
|
+
# transformation can result in a partially transformed instance
|
145
|
+
def deep_transform! &block
|
146
146
|
|
147
|
-
|
148
|
-
|
147
|
+
do_deep_transform_on_self_(&block)
|
148
|
+
end
|
149
149
|
|
150
150
|
end # module DeepTransform
|
151
151
|
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# ######################################################################## #
|
3
3
|
# File: lib/xqsr3/hash_utilities/key_matching.rb
|
4
4
|
#
|
5
|
-
# Purpose: Definition of the Xqsr3::HashUtilities::KeyMatching module
|
5
|
+
# Purpose: Definition of the ::Xqsr3::HashUtilities::KeyMatching module
|
6
6
|
#
|
7
7
|
# Created: 15th November 2017
|
8
|
-
# Updated:
|
8
|
+
# Updated: 29th March 2024
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
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) 2017-2019, Matthew Wilson and Synesis Software
|
16
16
|
# All rights reserved.
|
17
17
|
#
|
@@ -60,113 +60,113 @@ module HashUtilities
|
|
60
60
|
# and #match methods
|
61
61
|
module KeyMatching
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
private
|
64
|
+
def self.do_match_ h, re, **options # :nodoc:
|
65
65
|
|
66
|
-
|
66
|
+
::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[], :has_key?, :each ]
|
67
67
|
|
68
|
-
|
68
|
+
return h[re] if h.has_key? re
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
case re
|
71
|
+
when ::Regexp
|
72
72
|
|
73
|
-
|
73
|
+
h.each do |k, v|
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
case k
|
76
|
+
when ::Regexp
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
next
|
79
|
+
else
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
return v if k.to_s =~ re
|
82
|
+
end
|
83
|
+
end
|
84
|
+
else
|
85
85
|
|
86
|
-
|
86
|
+
h.each do |k, v|
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
case k
|
89
|
+
when ::Regexp
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
return v if re.to_s =~ k
|
92
|
+
else
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
next
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
nil
|
100
|
+
end
|
101
101
|
|
102
|
-
|
102
|
+
def self.do_has_match_ h, re, **options # :nodoc:
|
103
103
|
|
104
|
-
|
104
|
+
::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[], :has_key?, :each ]
|
105
105
|
|
106
|
-
|
106
|
+
return true if h.has_key? re
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
case re
|
109
|
+
when ::Regexp
|
110
110
|
|
111
|
-
|
111
|
+
h.each do |k, v|
|
112
112
|
|
113
|
-
|
114
|
-
|
113
|
+
case k
|
114
|
+
when ::Regexp
|
115
115
|
|
116
|
-
|
117
|
-
|
116
|
+
next
|
117
|
+
else
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
return true if k.to_s =~ re
|
120
|
+
end
|
121
|
+
end
|
122
|
+
else
|
123
123
|
|
124
|
-
|
124
|
+
h.each do |k, v|
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
case k
|
127
|
+
when ::Regexp
|
128
128
|
|
129
|
-
|
130
|
-
|
129
|
+
return true if re.to_s =~ k
|
130
|
+
else
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
132
|
+
next
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
false
|
138
|
+
end
|
139
|
+
public
|
140
140
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
# Retrieves the value object corresponding to the first key object that
|
142
|
+
# matches the given +re+, in the hash +h+, according to the given
|
143
|
+
# options.
|
144
|
+
def self.match h, re, **options
|
145
145
|
|
146
|
-
|
147
|
-
|
146
|
+
Xqsr3::HashUtilities::KeyMatching.do_match_ h, re, **options
|
147
|
+
end
|
148
148
|
|
149
|
-
|
150
|
-
|
151
|
-
|
149
|
+
# Returns true if the hash +h+ contains a key object that matches the
|
150
|
+
# given +re+, according to the given options
|
151
|
+
def self.has_match? h, re, **options
|
152
152
|
|
153
|
-
|
154
|
-
|
153
|
+
Xqsr3::HashUtilities::KeyMatching.do_has_match_ h, re, **options
|
154
|
+
end
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
# Retrieves the value object corresponding to the first key object that
|
157
|
+
# matches the given +re+, in the hash +h+, according to the given
|
158
|
+
# options.
|
159
|
+
def match h, re, **options
|
160
160
|
|
161
|
-
|
162
|
-
|
161
|
+
Xqsr3::HashUtilities::KeyMatching.do_match_ h, re, **options
|
162
|
+
end
|
163
163
|
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
# Returns true if the hash +h+ contains a key object that matches the
|
165
|
+
# given +re+, according to the given options
|
166
|
+
def has_match? h, re, **options
|
167
167
|
|
168
|
-
|
169
|
-
|
168
|
+
Xqsr3::HashUtilities::KeyMatching.do_has_match_ h, re, **options
|
169
|
+
end
|
170
170
|
|
171
171
|
end # module KeyMatching
|
172
172
|
|
data/lib/xqsr3/hash_utilities.rb
CHANGED
@@ -49,128 +49,128 @@ require 'test/unit'
|
|
49
49
|
|
50
50
|
begin
|
51
51
|
|
52
|
-
|
52
|
+
require 'test/unit/version'
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
# :stopdoc:
|
55
|
+
# @!visibility private
|
56
|
+
module Xqsr3
|
57
|
+
# @!visibility private
|
58
|
+
module Internal_ # :nodoc:
|
59
|
+
# @!visibility private
|
60
|
+
module TestUnitVersion_ # :nodoc:
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
# @!visibility private
|
63
|
+
TEST_UNIT_VERSION_ = Test::Unit::VERSION # :nodoc:
|
64
|
+
end # module TestUnitVersion_
|
65
|
+
end # module Internal_
|
66
|
+
end # module Xqsr3
|
67
67
|
|
68
|
-
|
69
|
-
rescue LoadError
|
68
|
+
# :startdoc:
|
69
|
+
rescue LoadError
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
# :stopdoc:
|
72
|
+
# @!visibility private
|
73
|
+
module Xqsr3
|
74
|
+
# @!visibility private
|
75
|
+
module Internal_ # :nodoc:
|
76
|
+
# @!visibility private
|
77
|
+
module TestUnitVersion_ # :nodoc:
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
# @!visibility private
|
80
|
+
TEST_UNIT_VERSION_ = :not_found # :nodoc:
|
81
|
+
end # module TestUnitVersion_
|
82
|
+
end # module Internal_
|
83
|
+
end # module Xqsr3
|
84
84
|
|
85
|
-
|
86
|
-
end
|
85
|
+
# :startdoc:
|
86
|
+
end
|
87
87
|
|
88
|
-
# :stopdoc:
|
88
|
+
# :stopdoc:
|
89
89
|
|
90
|
-
module Xqsr3
|
91
|
-
module Internal_ # :nodoc:
|
92
|
-
module TestUnitVersion_ # :nodoc:
|
90
|
+
module Xqsr3
|
91
|
+
module Internal_ # :nodoc:
|
92
|
+
module TestUnitVersion_ # :nodoc:
|
93
93
|
|
94
|
-
|
94
|
+
if TEST_UNIT_VERSION_ == :not_found
|
95
95
|
|
96
|
-
|
96
|
+
TEST_UNIT_VERSION_PARTS_ = []
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
TEST_UNIT_VERSION_MAJOR_ = nil # :nodoc:
|
99
|
+
TEST_UNIT_VERSION_MINOR_ = nil # :nodoc:
|
100
|
+
TEST_UNIT_VERSION_PATCH_ = nil # :nodoc:
|
101
|
+
else
|
102
102
|
|
103
|
-
|
103
|
+
TEST_UNIT_VERSION_PARTS_ = TEST_UNIT_VERSION_.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
TEST_UNIT_VERSION_MAJOR_ = TEST_UNIT_VERSION_PARTS_[0] # :nodoc:
|
106
|
+
TEST_UNIT_VERSION_MINOR_ = TEST_UNIT_VERSION_PARTS_[1] # :nodoc:
|
107
|
+
TEST_UNIT_VERSION_PATCH_ = TEST_UNIT_VERSION_PARTS_[2] # :nodoc:
|
108
|
+
end
|
109
109
|
|
110
|
-
|
111
|
-
|
110
|
+
# @!visibility private
|
111
|
+
def self.less_ a1, a2 # :nodoc:
|
112
112
|
|
113
|
-
|
113
|
+
n_common = a1.size < a2.size ? a1.size : a2.size
|
114
114
|
|
115
|
-
|
115
|
+
(0...n_common).each do |ix|
|
116
116
|
|
117
|
-
|
118
|
-
|
117
|
+
v1 = a1[ix]
|
118
|
+
v2 = a2[ix]
|
119
119
|
|
120
|
-
|
120
|
+
if v1 == v2
|
121
121
|
|
122
|
-
|
123
|
-
|
122
|
+
next
|
123
|
+
end
|
124
124
|
|
125
|
-
|
125
|
+
if v1 < v2
|
126
126
|
|
127
|
-
|
128
|
-
|
127
|
+
return true
|
128
|
+
else
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
return false
|
131
|
+
end
|
132
|
+
end
|
133
133
|
|
134
|
-
|
134
|
+
if n_common != a2.size
|
135
135
|
|
136
|
-
|
137
|
-
|
136
|
+
return true
|
137
|
+
else
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
139
|
+
return false
|
140
|
+
end
|
141
|
+
end
|
142
142
|
|
143
|
-
|
144
|
-
|
143
|
+
# @!visibility private
|
144
|
+
def self.is_major_at_least? j # :nodoc:
|
145
145
|
|
146
|
-
|
146
|
+
return unless TEST_UNIT_VERSION_MAJOR_
|
147
147
|
|
148
|
-
|
149
|
-
|
148
|
+
return j >= TEST_UNIT_VERSION_MAJOR_
|
149
|
+
end
|
150
150
|
|
151
|
-
|
152
|
-
|
151
|
+
# @!visibility private
|
152
|
+
def self.is_minor_at_least? n # :nodoc:
|
153
153
|
|
154
|
-
|
154
|
+
return unless TEST_UNIT_VERSION_MINOR_
|
155
155
|
|
156
|
-
|
157
|
-
|
156
|
+
return n >= TEST_UNIT_VERSION_MINOR_
|
157
|
+
end
|
158
158
|
|
159
|
-
|
160
|
-
|
159
|
+
# @!visibility private
|
160
|
+
def self.is_at_least? v # :nodoc:
|
161
161
|
|
162
|
-
|
162
|
+
v = v.split(/\./).collect { |n| n.to_i } if String === v
|
163
163
|
|
164
|
-
|
165
|
-
|
164
|
+
return !less_(TEST_UNIT_VERSION_PARTS_, v)
|
165
|
+
end
|
166
166
|
|
167
|
-
|
168
|
-
|
167
|
+
# @!visibility private
|
168
|
+
def self.is_less? v # :nodoc:
|
169
169
|
|
170
|
-
|
170
|
+
v = v.split(/\./).collect { |n| n.to_i } if String === v
|
171
171
|
|
172
|
-
|
173
|
-
|
172
|
+
return less_(TEST_UNIT_VERSION_PARTS_, v)
|
173
|
+
end
|
174
174
|
|
175
175
|
end # module TestUnitVersion_
|
176
176
|
end # module Internal_
|