xqsr3 0.38.1.1 → 0.39.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -6
  3. data/examples/count_word_frequencies.md +13 -13
  4. data/examples/count_word_frequencies.rb +5 -5
  5. data/lib/xqsr3/array_utilities/join_with_or.rb +53 -54
  6. data/lib/xqsr3/array_utilities.rb +2 -2
  7. data/lib/xqsr3/command_line_utilities/map_option_string.rb +66 -67
  8. data/lib/xqsr3/command_line_utilities.rb +2 -2
  9. data/lib/xqsr3/containers/frequency_map.rb +405 -404
  10. data/lib/xqsr3/containers/multi_map.rb +454 -453
  11. data/lib/xqsr3/containers.rb +3 -3
  12. data/lib/xqsr3/conversion/bool_parser.rb +56 -57
  13. data/lib/xqsr3/conversion/integer_parser.rb +92 -93
  14. data/lib/xqsr3/conversion.rb +3 -3
  15. data/lib/xqsr3/diagnostics/exception_utilities.rb +152 -151
  16. data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +99 -95
  17. data/lib/xqsr3/diagnostics/inspect_builder.rb +86 -86
  18. data/lib/xqsr3/diagnostics.rb +3 -3
  19. data/lib/xqsr3/doc_.rb +136 -136
  20. data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
  21. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +18 -17
  22. data/lib/xqsr3/extensions/enumerable/detect_map.rb +41 -41
  23. data/lib/xqsr3/extensions/enumerable/unique.rb +32 -31
  24. data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -1
  25. data/lib/xqsr3/extensions/hash/except.rb +16 -16
  26. data/lib/xqsr3/extensions/hash/has_match.rb +10 -10
  27. data/lib/xqsr3/extensions/hash/match.rb +10 -10
  28. data/lib/xqsr3/extensions/hash/slice.rb +11 -11
  29. data/lib/xqsr3/extensions/hash.rb +1 -1
  30. data/lib/xqsr3/extensions/integer/to_s_grp.rb +118 -0
  31. data/lib/xqsr3/extensions/integer.rb +3 -0
  32. data/lib/xqsr3/extensions/io/writelines.rb +34 -34
  33. data/lib/xqsr3/extensions/kernel/integer.rb +26 -26
  34. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +15 -14
  35. data/lib/xqsr3/extensions/kernel.rb +1 -0
  36. data/lib/xqsr3/extensions/string/ends_with.rb +1 -1
  37. data/lib/xqsr3/extensions/string/map_option_string.rb +4 -5
  38. data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -1
  39. data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -1
  40. data/lib/xqsr3/extensions/string/quote_if.rb +1 -2
  41. data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
  42. data/lib/xqsr3/extensions/string/to_bool.rb +8 -9
  43. data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
  44. data/lib/xqsr3/extensions/string/truncate.rb +1 -2
  45. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +7 -7
  46. data/lib/xqsr3/extensions/test/unit/assert_false.rb +6 -7
  47. data/lib/xqsr3/extensions/test/unit/assert_not.rb +6 -7
  48. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +7 -7
  49. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -62
  50. data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +7 -8
  51. data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +7 -8
  52. data/lib/xqsr3/extensions/test/unit/assert_true.rb +6 -7
  53. data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +36 -38
  54. data/lib/xqsr3/extensions.rb +5 -5
  55. data/lib/xqsr3/hash_utilities/deep_transform.rb +71 -71
  56. data/lib/xqsr3/hash_utilities/key_matching.rb +82 -82
  57. data/lib/xqsr3/hash_utilities.rb +3 -3
  58. data/lib/xqsr3/internal_/test_unit_version_.rb +130 -88
  59. data/lib/xqsr3/io/writelines.rb +125 -125
  60. data/lib/xqsr3/quality/parameter_checking.rb +452 -453
  61. data/lib/xqsr3/quality.rb +2 -2
  62. data/lib/xqsr3/string_utilities/ends_with.rb +64 -64
  63. data/lib/xqsr3/string_utilities/nil_if_empty.rb +33 -34
  64. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +35 -35
  65. data/lib/xqsr3/string_utilities/quote_if.rb +55 -56
  66. data/lib/xqsr3/string_utilities/starts_with.rb +64 -64
  67. data/lib/xqsr3/string_utilities/to_symbol.rb +80 -80
  68. data/lib/xqsr3/string_utilities/truncate.rb +60 -61
  69. data/lib/xqsr3/string_utilities.rb +8 -8
  70. data/lib/xqsr3/version.rb +19 -20
  71. data/test/performance/frequency_map.rb +13 -27
  72. data/test/scratch/test_assert_raise_with_message.rb +12 -13
  73. data/test/unit/array_utilities/tc_join_with_or.rb +140 -142
  74. data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
  75. data/test/unit/containers/tc_frequency_map.rb +607 -554
  76. data/test/unit/containers/tc_multi_map.rb +573 -522
  77. data/test/unit/conversion/tc_integer_parser.rb +73 -73
  78. data/test/unit/conversion/tc_to_bool.rb +26 -26
  79. data/test/unit/diagnostics/exceptions/tc_with_cause.rb +165 -165
  80. data/test/unit/diagnostics/tc_exception_utilities.rb +156 -156
  81. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +14 -14
  82. data/test/unit/extensions/enumerable/tc_detect_map.rb +20 -20
  83. data/test/unit/extensions/enumerable/tc_unique.rb +34 -34
  84. data/test/unit/extensions/hash/tc_deep_transform.rb +22 -22
  85. data/test/unit/extensions/hash/tc_except.rb +28 -28
  86. data/test/unit/extensions/hash/tc_hash.rb +1 -1
  87. data/test/unit/extensions/hash/tc_slice.rb +14 -14
  88. data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
  89. data/test/unit/extensions/integer/ts_all.rb +12 -0
  90. data/test/unit/extensions/io/tc_writelines.rb +77 -77
  91. data/test/unit/extensions/kernel/tc_integer.rb +75 -75
  92. data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
  93. data/test/unit/extensions/object/tc_inspect.rb +51 -51
  94. data/test/unit/extensions/string/tc_bool.tb +24 -24
  95. data/test/unit/extensions/string/tc_ends_with.rb +53 -53
  96. data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
  97. data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
  98. data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
  99. data/test/unit/extensions/string/tc_quote_if.rb +18 -18
  100. data/test/unit/extensions/string/tc_starts_with.rb +53 -53
  101. data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
  102. data/test/unit/extensions/string/tc_truncate.rb +18 -18
  103. data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
  104. data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
  105. data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
  106. data/test/unit/hash_utilities/tc_has_match.rb +70 -70
  107. data/test/unit/hash_utilities/tc_match.rb +83 -83
  108. data/test/unit/io/tc_writelines.rb +106 -108
  109. data/test/unit/quality/tc_parameter_checking.rb +390 -390
  110. data/test/unit/string_utilities/tc_truncate.rb +28 -28
  111. data/test/unit/tc_version.rb +15 -15
  112. metadata +6 -2
@@ -1,17 +1,18 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/diagnostics/exception_utilities.rb
3
+ # File: lib/xqsr3/diagnostics/exception_utilities.rb
4
4
  #
5
- # Purpose: Definition of the ExceptionUtilities module
5
+ # Purpose: Definition of the ExceptionUtilities module
6
6
  #
7
- # Created: 12th February 2015
8
- # Updated: 2nd August 2017
7
+ # Created: 12th February 2015
8
+ # Updated: 29th March 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/xqsr3
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2015-2017, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
+ # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
17
18
  # Redistribution and use in source and binary forms, with or without
@@ -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 holder nor the names of its
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
  #
@@ -55,161 +56,161 @@ module Diagnostics
55
56
 
56
57
  module ExceptionUtilities
57
58
 
58
- # Raises an instance of a named exception that takes options in its
59
- # constructor, as in:
60
- #
61
- # class ArgumentErrorWithOptions < ArgumentError
62
- #
63
- # def initialize(message = nil, **options)
64
- #
65
- # . . .
66
- # end
67
- #
68
- # attr_reader :options
69
- # end
70
- #
71
- # begin
72
- #
73
- # raise_with_options ArgumentErrorWithOptions, "message-1", opt1: :val1, opt2: 'val2'
74
- # rescue => x
75
- #
76
- # $stderr.puts x.options # => {:opt1=>:val1, :opt2=>"val2"}
77
- # end
78
- #
79
- # It can also be used with full compatibility with <tt>Kernel#raise</tt>, as in:
80
- #
81
- # begin
82
- #
83
- # raise_with_options ArgumentError, "message-2"
84
- # rescue => x
85
- #
86
- # $stderr.puts x.class # => ArgumenError
87
- # $stderr.puts x.message # => "message-2"
88
- # end
89
- #
90
- # and:
91
- #
92
- # begin
93
- #
94
- # raise_with_options "message-3"
95
- # rescue => x
96
- #
97
- # $stderr.puts x.class # => RuntimeError
98
- # $stderr.puts x.message # => "message-3"
99
- # end
100
- #
101
- # === Parameters
102
- #
103
- # * +args+ 0 or more arguments
104
- # * +options+ An options hash
105
- #
106
- # === Parameter Interpretation
107
- #
108
- # If the first argument is a class, it is assumed to be the exception
109
- # type that will be raised; if not, RuntimeError is raised as is normal
110
- # with Kernel#raise. The remaining arguments are passed - via the
111
- # <tt>*</tt> operator - to the class's constructor.
112
- #
113
- # All options passed to this method are respread - by the
114
- # <tt>**</tt> operator - and passed to the underlying
115
- # <tt>Kernel#raise</tt> call.
116
- #
117
- # === Exceptions
118
- #
119
- # - An instance of <tt>arg[0]</tt> if <tt>args[0].is_a?(::Class)</tt>; or
120
- # - An instance of +RuntimeError+
121
- def self.raise_with_options *args, **options
122
-
123
- # special handling in case called indirectly
124
-
125
- called_indirectly = options[:called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96]
126
-
127
- case called_indirectly
128
- when nil, false
129
-
130
- called_indirectly = 0
131
- when true
132
-
133
- called_indirectly = 1
134
- when ::Integer
135
-
136
- ;
137
- else
138
-
139
- abort "indirect-call option (#{called_indirectly}) has invalid type (#{called_indirectly.class})"
140
- end
141
-
142
- options.delete :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 if called_indirectly
143
-
144
-
145
- # Use cases:
146
- #
147
- # 1. No options
148
- # 2. Non-class and options
149
- # 3. Class and options
150
- # 3.a Class and options
151
- # 3.b Class and options and message
152
- # 3.c Class and options and message and call-stack
153
-
154
- class_given = args.size > 0 && args[0].is_a?(::Class)
155
-
156
- if class_given && !options.empty?
157
-
158
- exception_class_or_instance_or_message_string = args.shift
159
-
160
- # 3. Class and options
161
-
162
- # 3.a Class and options
163
- # 3.b Class and options and message
164
- # 3.c Class and options and message and call-stack
165
-
166
-
167
- xargs = []
168
-
169
- xargs << args.shift unless args.empty?
170
-
171
- x = exception_class_or_instance_or_message_string.new(*xargs, **options)
172
-
173
- rargs = []
174
- rargs << x
175
- rargs += [ nil, args.shift ] unless args.empty?
176
-
177
- # now need to trim backtrace
59
+ # Raises an instance of a named exception that takes options in its
60
+ # constructor, as in:
61
+ #
62
+ # class ArgumentErrorWithOptions < ArgumentError
63
+ #
64
+ # def initialize(message = nil, **options)
65
+ #
66
+ # . . .
67
+ # end
68
+ #
69
+ # attr_reader :options
70
+ # end
71
+ #
72
+ # begin
73
+ #
74
+ # raise_with_options ArgumentErrorWithOptions, "message-1", opt1: :val1, opt2: 'val2'
75
+ # rescue => x
76
+ #
77
+ # $stderr.puts x.options # => {:opt1=>:val1, :opt2=>"val2"}
78
+ # end
79
+ #
80
+ # It can also be used with full compatibility with <tt>Kernel#raise</tt>, as in:
81
+ #
82
+ # begin
83
+ #
84
+ # raise_with_options ArgumentError, "message-2"
85
+ # rescue => x
86
+ #
87
+ # $stderr.puts x.class # => ArgumenError
88
+ # $stderr.puts x.message # => "message-2"
89
+ # end
90
+ #
91
+ # and:
92
+ #
93
+ # begin
94
+ #
95
+ # raise_with_options "message-3"
96
+ # rescue => x
97
+ #
98
+ # $stderr.puts x.class # => RuntimeError
99
+ # $stderr.puts x.message # => "message-3"
100
+ # end
101
+ #
102
+ # === Parameters
103
+ #
104
+ # * +args+ 0 or more arguments
105
+ # * +options+ An options hash
106
+ #
107
+ # === Parameter Interpretation
108
+ #
109
+ # If the first argument is a class, it is assumed to be the exception
110
+ # type that will be raised; if not, RuntimeError is raised as is normal
111
+ # with Kernel#raise. The remaining arguments are passed - via the
112
+ # <tt>*</tt> operator - to the class's constructor.
113
+ #
114
+ # All options passed to this method are respread - by the
115
+ # <tt>**</tt> operator - and passed to the underlying
116
+ # <tt>Kernel#raise</tt> call.
117
+ #
118
+ # === Exceptions
119
+ #
120
+ # - An instance of <tt>arg[0]</tt> if <tt>args[0].is_a?(::Class)</tt>; or
121
+ # - An instance of +RuntimeError+
122
+ def self.raise_with_options *args, **options
123
+
124
+ # special handling in case called indirectly
125
+
126
+ called_indirectly = options[:called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96]
127
+
128
+ case called_indirectly
129
+ when nil, false
130
+
131
+ called_indirectly = 0
132
+ when true
133
+
134
+ called_indirectly = 1
135
+ when ::Integer
136
+
137
+ ;
138
+ else
139
+
140
+ abort "indirect-call option (#{called_indirectly}) has invalid type (#{called_indirectly.class})"
141
+ end
142
+
143
+ options.delete :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 if called_indirectly
144
+
145
+
146
+ # Use cases:
147
+ #
148
+ # 1. No options
149
+ # 2. Non-class and options
150
+ # 3. Class and options
151
+ # 3.a Class and options
152
+ # 3.b Class and options and message
153
+ # 3.c Class and options and message and call-stack
154
+
155
+ class_given = args.size > 0 && args[0].is_a?(::Class)
156
+
157
+ if class_given && !options.empty?
158
+
159
+ exception_class_or_instance_or_message_string = args.shift
160
+
161
+ # 3. Class and options
162
+
163
+ # 3.a Class and options
164
+ # 3.b Class and options and message
165
+ # 3.c Class and options and message and call-stack
166
+
167
+
168
+ xargs = []
169
+
170
+ xargs << args.shift unless args.empty?
171
+
172
+ x = exception_class_or_instance_or_message_string.new(*xargs, **options)
173
+
174
+ rargs = []
175
+ rargs << x
176
+ rargs += [ nil, args.shift ] unless args.empty?
177
+
178
+ # now need to trim backtrace
178
179
 
179
- begin
180
+ begin
180
181
 
181
- Kernel.raise(*rargs)
182
- rescue => x
182
+ Kernel.raise(*rargs)
183
+ rescue => x
183
184
 
184
- bt = x.backtrace
185
- (0..called_indirectly).each { bt.shift }
186
- Kernel.raise x, x.message, bt
187
- end
188
- end
185
+ bt = x.backtrace
186
+ (0..called_indirectly).each { bt.shift }
187
+ Kernel.raise x, x.message, bt
188
+ end
189
+ end
189
190
 
190
- unless options.empty?
191
+ unless options.empty?
191
192
 
192
- # 2. Non-class and options
193
+ # 2. Non-class and options
193
194
 
194
- warn "cannot utilise options in raise_with_options when first argument is non-class"
195
- else
195
+ warn "cannot utilise options in raise_with_options when first argument is non-class"
196
+ else
196
197
 
197
- # 1. No options
198
- end
198
+ # 1. No options
199
+ end
199
200
 
200
201
 
201
- # now need to trim backtrace
202
+ # now need to trim backtrace
202
203
 
203
- begin
204
+ begin
204
205
 
205
- Kernel.raise(*args)
206
- rescue => x
206
+ Kernel.raise(*args)
207
+ rescue => x
207
208
 
208
- bt = x.backtrace
209
- (0..called_indirectly).each { bt.shift }
210
- Kernel.raise x, x.message, bt
211
- end
212
- end
209
+ bt = x.backtrace
210
+ (0..called_indirectly).each { bt.shift }
211
+ Kernel.raise x, x.message, bt
212
+ end
213
+ end
213
214
  end # module ExceptionUtilities
214
215
 
215
216
  end # module Diagnostics
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/diagnostics/exceptions/with_cause.rb
3
+ # File: lib/xqsr3/diagnostics/exceptions/with_cause.rb
4
4
  #
5
- # Purpose: Definition of the WithCause inclusion module
5
+ # Purpose: Definition of the WithCause inclusion module
6
6
  #
7
- # Created: 16th December 2017
8
- # Updated: 12th April 2019
7
+ # Created: 16th December 2017
8
+ # Updated: 29th March 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/xqsr3
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2017-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 holder nor the names of its
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
  #
@@ -66,139 +67,142 @@ module Exceptions
66
67
  #
67
68
  module WithCause
68
69
 
69
- # Array of hidden fields
70
- INSPECT_HIDDEN_FIELDS = [ 'has_implicit_message', 'uses_cause_message' ]
70
+ # Array of hidden fields
71
+ INSPECT_HIDDEN_FIELDS = [ 'has_implicit_message', 'uses_cause_message' ]
71
72
 
72
- # Defines an initializer for an exception class that allows a cause (aka
73
- # an inner exception) to be specified, either as the first or last
74
- # argument or as a +:cause+ option
75
- #
76
- # === Signature
77
- #
78
- # * *Parameters:*
79
- # - +args+ 0+ arguments passed through to the +include+-ing class' initialiser
80
- # - +options+ Options hash
81
- #
82
- # * *Options:*
83
- # - +:cause+ - The exception to be used as a cause, and ensures that that is not inferred from the arguments. May be +nil+ to ensure that no cause is inferred
84
- def initialize(*args, **options)
73
+ # Defines an initializer for an exception class that allows a cause (aka
74
+ # an inner exception) to be specified, either as the first or last
75
+ # argument or as a +:cause+ option
76
+ #
77
+ # === Signature
78
+ #
79
+ # * *Parameters:*
80
+ # - +args+ 0+ arguments passed through to the +include+-ing class' initialiser
81
+ # - +options+ Options hash
82
+ #
83
+ # * *Options:*
84
+ # - +:cause+ - The exception to be used as a cause, and ensures that that is not inferred from the arguments. May be +nil+ to ensure that no cause is inferred
85
+ def initialize(*args, **options)
85
86
 
86
- @uses_cause_message = false
87
+ @uses_cause_message = false
87
88
 
88
- cz = options[:cause]
89
+ cz = options[:cause]
89
90
 
90
- if cz
91
+ if cz
91
92
 
92
- options = options.reject { |k, v| k == :cause }
93
+ options = options.reject { |k, v| k == :cause }
93
94
 
94
- @has_implicit_message = args.empty?
95
+ @has_implicit_message = args.empty?
95
96
 
96
- super(*args)
97
+ super(*args)
97
98
 
98
- warn 'unexpected implicit message' if @has_implicit_message && self.message != self.class.to_s
99
+ warn 'unexpected implicit message' if @has_implicit_message && self.message != self.class.to_s
99
100
 
100
- @cause = cz
101
- else
101
+ @cause = cz
102
+ else
102
103
 
103
- cz_ix = args.index { |arg| ::Exception === arg }
104
+ cz_ix = args.index { |arg| ::Exception === arg }
104
105
 
105
- if cz_ix
106
+ if cz_ix
106
107
 
107
- args = args.dup
108
+ args = args.dup
108
109
 
109
- cz = args.delete_at cz_ix
110
+ cz = args.delete_at cz_ix
110
111
 
111
- if args.empty?
112
+ if args.empty?
112
113
 
113
- if !(cz.message || '').empty? && cz.class.to_s != cz.message
114
+ if !(cz.message || '').empty? && cz.class.to_s != cz.message
114
115
 
115
- @uses_cause_message = true
116
+ @uses_cause_message = true
116
117
 
117
- args = [ cz.message ]
118
- end
119
- end
120
- else
118
+ args = [ cz.message ]
119
+ end
120
+ end
121
+ else
121
122
 
122
- cz = $!
123
- end
123
+ cz = $!
124
+ end
124
125
 
125
- @has_implicit_message = args.empty?
126
+ @has_implicit_message = args.empty?
126
127
 
127
- super(*args)
128
+ super(*args)
128
129
 
129
- warn 'unexpected implicit message' if @has_implicit_message && self.message != self.class.to_s
130
+ warn 'unexpected implicit message' if @has_implicit_message && self.message != self.class.to_s
130
131
 
131
- @cause = cz
132
- end
132
+ @cause = cz
133
+ end
133
134
 
134
- @options = options
135
- end
135
+ @options = options
136
+ end
136
137
 
137
- # The cause / inner-exception, if any, specified to the instance
138
- # initialiser
139
- attr_reader :cause
138
+ # The cause / inner-exception, if any, specified to the instance
139
+ # initialiser
140
+ attr_reader :cause
140
141
 
141
- # The options passed to the initialiser, with +:cause+ removed, if
142
- # present
143
- attr_reader :options
142
+ # The options passed to the initialiser, with +:cause+ removed, if
143
+ # present
144
+ attr_reader :options
144
145
 
145
- # Message obtained by concatenation of all chained exceptions' messages
146
- #
147
- # === Signature
148
- #
149
- # * *Parameters:*
150
- # - +options+ Options hash
151
- #
152
- # * *Options:*
153
- # - +:separator+ (String) A string used to separate each chained exception message. Defaults to ": "
154
- def chained_message **options
146
+ # Message obtained by concatenation of all chained exceptions' messages
147
+ #
148
+ # === Signature
149
+ #
150
+ # * *Parameters:*
151
+ # - +options+ Options hash
152
+ #
153
+ # * *Options:*
154
+ # - +:separator+ (String) A string used to separate each chained exception message. Defaults to ": "
155
+ def chained_message **options
155
156
 
156
- return message unless cause
157
- return message if @uses_cause_message
157
+ return message unless cause
158
+ return message if @uses_cause_message
158
159
 
159
- m = message
160
- c = cause
161
- cm = c.respond_to?(:chained_message) ? c.chained_message(**options) : c.message
160
+ m = message
161
+ c = cause
162
+ cm = c.respond_to?(:chained_message) ? c.chained_message(**options) : c.message
162
163
 
163
- return m if (cm || '').empty?
164
- return cm if (m || '').empty?
164
+ return m if (cm || '').empty?
165
+ return cm if (m || '').empty?
165
166
 
166
- sep = options[:separator] || ': '
167
+ sep = options[:separator] || ': '
167
168
 
168
- "#{m}#{sep}#{cm}"
169
- end
169
+ "#{m}#{sep}#{cm}"
170
+ end
170
171
 
171
- # An array of exceptions in the chain, excluding +self+
172
- def chainees
172
+ # An array of exceptions in the chain, excluding +self+
173
+ def chainees
173
174
 
174
- return [] unless cause
175
+ return [] unless cause
175
176
 
176
- r = [ cause ]
177
+ r = [ cause ]
177
178
 
178
- r += cause.chainees if cause.respond_to? :chainees
179
+ r += cause.chainees if cause.respond_to? :chainees
179
180
 
180
- r
181
- end
181
+ r
182
+ end
182
183
 
183
- # An array of exceptions in the chain, including +self+
184
- def exceptions
184
+ # An array of exceptions in the chain, including +self+
185
+ def exceptions
185
186
 
186
- [ self ] + chainees
187
- end
187
+ [ self ] + chainees
188
+ end
188
189
 
189
- # A combination of the backtrace(s) of all chained exception(s)
190
- def chained_backtrace
190
+ # A combination of the backtrace(s) of all chained exception(s)
191
+ def chained_backtrace
191
192
 
192
- b = backtrace
193
+ b = backtrace
193
194
 
194
- return b unless cause
195
+ return b unless cause
195
196
 
196
- cb = cause.respond_to?(:chained_backtrace) ? cause.chained_backtrace : cause.backtrace
197
+ cb = cause.respond_to?(:chained_backtrace) ? cause.chained_backtrace : cause.backtrace
197
198
 
198
- (cb - b) + b
199
- end
199
+ (cb - b) + b
200
+ end
200
201
  end
201
202
 
202
203
  end # module Exceptions
203
204
  end # module Diagnostics
204
205
  end # module Xqsr3
206
+
207
+ # ############################## end of file ############################# #
208
+