xqsr3 0.38.2 → 0.39.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -6
  3. data/examples/count_word_frequencies.md +12 -12
  4. data/examples/count_word_frequencies.rb +4 -4
  5. data/lib/xqsr3/array_utilities/join_with_or.rb +47 -47
  6. data/lib/xqsr3/array_utilities.rb +2 -2
  7. data/lib/xqsr3/command_line_utilities/map_option_string.rb +60 -60
  8. data/lib/xqsr3/command_line_utilities.rb +2 -2
  9. data/lib/xqsr3/containers/frequency_map.rb +399 -399
  10. data/lib/xqsr3/containers/multi_map.rb +448 -448
  11. data/lib/xqsr3/containers.rb +3 -3
  12. data/lib/xqsr3/conversion/bool_parser.rb +51 -51
  13. data/lib/xqsr3/conversion/integer_parser.rb +87 -87
  14. data/lib/xqsr3/conversion.rb +3 -3
  15. data/lib/xqsr3/diagnostics/exception_utilities.rb +145 -145
  16. data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +90 -90
  17. data/lib/xqsr3/diagnostics/inspect_builder.rb +80 -80
  18. data/lib/xqsr3/diagnostics.rb +3 -3
  19. data/lib/xqsr3/doc_.rb +130 -130
  20. data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
  21. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +12 -12
  22. data/lib/xqsr3/extensions/enumerable/detect_map.rb +35 -35
  23. data/lib/xqsr3/extensions/enumerable/unique.rb +29 -28
  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 +28 -28
  33. data/lib/xqsr3/extensions/kernel/integer.rb +20 -20
  34. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +8 -8
  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 -4
  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 -1
  41. data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
  42. data/lib/xqsr3/extensions/string/to_bool.rb +8 -8
  43. data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
  44. data/lib/xqsr3/extensions/string/truncate.rb +1 -1
  45. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +10 -7
  46. data/lib/xqsr3/extensions/test/unit/assert_false.rb +9 -6
  47. data/lib/xqsr3/extensions/test/unit/assert_not.rb +9 -6
  48. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +10 -7
  49. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -61
  50. data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +10 -7
  51. data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +10 -7
  52. data/lib/xqsr3/extensions/test/unit/assert_true.rb +9 -6
  53. data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +39 -36
  54. data/lib/xqsr3/extensions.rb +5 -5
  55. data/lib/xqsr3/hash_utilities/deep_transform.rb +65 -65
  56. data/lib/xqsr3/hash_utilities/key_matching.rb +77 -77
  57. data/lib/xqsr3/hash_utilities.rb +3 -3
  58. data/lib/xqsr3/internal_/test_unit_version_.rb +83 -83
  59. data/lib/xqsr3/io/writelines.rb +122 -120
  60. data/lib/xqsr3/quality/parameter_checking.rb +445 -445
  61. data/lib/xqsr3/quality.rb +2 -2
  62. data/lib/xqsr3/string_utilities/ends_with.rb +59 -59
  63. data/lib/xqsr3/string_utilities/nil_if_empty.rb +28 -28
  64. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +29 -29
  65. data/lib/xqsr3/string_utilities/quote_if.rb +50 -50
  66. data/lib/xqsr3/string_utilities/starts_with.rb +59 -59
  67. data/lib/xqsr3/string_utilities/to_symbol.rb +75 -75
  68. data/lib/xqsr3/string_utilities/truncate.rb +55 -55
  69. data/lib/xqsr3/string_utilities.rb +8 -8
  70. data/lib/xqsr3/version.rb +12 -12
  71. data/test/performance/frequency_map.rb +12 -12
  72. data/test/scratch/test_assert_raise_with_message.rb +11 -11
  73. data/test/unit/array_utilities/tc_join_with_or.rb +140 -140
  74. data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
  75. data/test/unit/containers/tc_frequency_map.rb +591 -591
  76. data/test/unit/containers/tc_multi_map.rb +558 -558
  77. data/test/unit/conversion/tc_integer_parser.rb +72 -72
  78. data/test/unit/conversion/tc_to_bool.rb +25 -25
  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_slice.rb +13 -13
  87. data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
  88. data/test/unit/extensions/integer/ts_all.rb +12 -0
  89. data/test/unit/extensions/io/tc_writelines.rb +149 -77
  90. data/test/unit/extensions/kernel/tc_integer.rb +75 -75
  91. data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
  92. data/test/unit/extensions/object/tc_inspect.rb +50 -50
  93. data/test/unit/extensions/string/tc_bool.tb +24 -24
  94. data/test/unit/extensions/string/tc_ends_with.rb +53 -53
  95. data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
  96. data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
  97. data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
  98. data/test/unit/extensions/string/tc_quote_if.rb +18 -18
  99. data/test/unit/extensions/string/tc_starts_with.rb +53 -53
  100. data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
  101. data/test/unit/extensions/string/tc_truncate.rb +18 -18
  102. data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
  103. data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
  104. data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
  105. data/test/unit/hash_utilities/tc_has_match.rb +70 -70
  106. data/test/unit/hash_utilities/tc_match.rb +83 -83
  107. data/test/unit/io/tc_writelines.rb +166 -106
  108. data/test/unit/quality/tc_parameter_checking.rb +389 -389
  109. data/test/unit/string_utilities/tc_truncate.rb +27 -27
  110. data/test/unit/tc_version.rb +15 -15
  111. metadata +6 -2
@@ -5,13 +5,13 @@
5
5
  # Purpose: Definition of the ExceptionUtilities module
6
6
  #
7
7
  # Created: 12th February 2015
8
- # Updated: 11th December 2023
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-2023, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -56,161 +56,161 @@ module Diagnostics
56
56
 
57
57
  module ExceptionUtilities
58
58
 
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
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
179
179
 
180
- begin
180
+ begin
181
181
 
182
- Kernel.raise(*rargs)
183
- rescue => x
182
+ Kernel.raise(*rargs)
183
+ rescue => x
184
184
 
185
- bt = x.backtrace
186
- (0..called_indirectly).each { bt.shift }
187
- Kernel.raise x, x.message, bt
188
- end
189
- end
185
+ bt = x.backtrace
186
+ (0..called_indirectly).each { bt.shift }
187
+ Kernel.raise x, x.message, bt
188
+ end
189
+ end
190
190
 
191
- unless options.empty?
191
+ unless options.empty?
192
192
 
193
- # 2. Non-class and options
193
+ # 2. Non-class and options
194
194
 
195
- warn "cannot utilise options in raise_with_options when first argument is non-class"
196
- else
195
+ warn "cannot utilise options in raise_with_options when first argument is non-class"
196
+ else
197
197
 
198
- # 1. No options
199
- end
198
+ # 1. No options
199
+ end
200
200
 
201
201
 
202
- # now need to trim backtrace
202
+ # now need to trim backtrace
203
203
 
204
- begin
204
+ begin
205
205
 
206
- Kernel.raise(*args)
207
- rescue => x
206
+ Kernel.raise(*args)
207
+ rescue => x
208
208
 
209
- bt = x.backtrace
210
- (0..called_indirectly).each { bt.shift }
211
- Kernel.raise x, x.message, bt
212
- end
213
- end
209
+ bt = x.backtrace
210
+ (0..called_indirectly).each { bt.shift }
211
+ Kernel.raise x, x.message, bt
212
+ end
213
+ end
214
214
  end # module ExceptionUtilities
215
215
 
216
216
  end # module Diagnostics
@@ -5,13 +5,13 @@
5
5
  # Purpose: Definition of the WithCause inclusion module
6
6
  #
7
7
  # Created: 16th December 2017
8
- # Updated: 11th December 2023
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-2023, Matthew Wilson and Synesis Information Systems
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
  #
@@ -67,137 +67,137 @@ module Exceptions
67
67
  #
68
68
  module WithCause
69
69
 
70
- # Array of hidden fields
71
- INSPECT_HIDDEN_FIELDS = [ 'has_implicit_message', 'uses_cause_message' ]
70
+ # Array of hidden fields
71
+ INSPECT_HIDDEN_FIELDS = [ 'has_implicit_message', 'uses_cause_message' ]
72
72
 
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)
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)
86
86
 
87
- @uses_cause_message = false
87
+ @uses_cause_message = false
88
88
 
89
- cz = options[:cause]
89
+ cz = options[:cause]
90
90
 
91
- if cz
91
+ if cz
92
92
 
93
- options = options.reject { |k, v| k == :cause }
93
+ options = options.reject { |k, v| k == :cause }
94
94
 
95
- @has_implicit_message = args.empty?
95
+ @has_implicit_message = args.empty?
96
96
 
97
- super(*args)
97
+ super(*args)
98
98
 
99
- 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
100
100
 
101
- @cause = cz
102
- else
101
+ @cause = cz
102
+ else
103
103
 
104
- cz_ix = args.index { |arg| ::Exception === arg }
104
+ cz_ix = args.index { |arg| ::Exception === arg }
105
105
 
106
- if cz_ix
106
+ if cz_ix
107
107
 
108
- args = args.dup
108
+ args = args.dup
109
109
 
110
- cz = args.delete_at cz_ix
110
+ cz = args.delete_at cz_ix
111
111
 
112
- if args.empty?
112
+ if args.empty?
113
113
 
114
- if !(cz.message || '').empty? && cz.class.to_s != cz.message
114
+ if !(cz.message || '').empty? && cz.class.to_s != cz.message
115
115
 
116
- @uses_cause_message = true
116
+ @uses_cause_message = true
117
117
 
118
- args = [ cz.message ]
119
- end
120
- end
121
- else
118
+ args = [ cz.message ]
119
+ end
120
+ end
121
+ else
122
122
 
123
- cz = $!
124
- end
123
+ cz = $!
124
+ end
125
125
 
126
- @has_implicit_message = args.empty?
126
+ @has_implicit_message = args.empty?
127
127
 
128
- super(*args)
128
+ super(*args)
129
129
 
130
- 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
131
131
 
132
- @cause = cz
133
- end
132
+ @cause = cz
133
+ end
134
134
 
135
- @options = options
136
- end
135
+ @options = options
136
+ end
137
137
 
138
- # The cause / inner-exception, if any, specified to the instance
139
- # initialiser
140
- attr_reader :cause
138
+ # The cause / inner-exception, if any, specified to the instance
139
+ # initialiser
140
+ attr_reader :cause
141
141
 
142
- # The options passed to the initialiser, with +:cause+ removed, if
143
- # present
144
- attr_reader :options
142
+ # The options passed to the initialiser, with +:cause+ removed, if
143
+ # present
144
+ attr_reader :options
145
145
 
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
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
156
156
 
157
- return message unless cause
158
- return message if @uses_cause_message
157
+ return message unless cause
158
+ return message if @uses_cause_message
159
159
 
160
- m = message
161
- c = cause
162
- 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
163
163
 
164
- return m if (cm || '').empty?
165
- return cm if (m || '').empty?
164
+ return m if (cm || '').empty?
165
+ return cm if (m || '').empty?
166
166
 
167
- sep = options[:separator] || ': '
167
+ sep = options[:separator] || ': '
168
168
 
169
- "#{m}#{sep}#{cm}"
170
- end
169
+ "#{m}#{sep}#{cm}"
170
+ end
171
171
 
172
- # An array of exceptions in the chain, excluding +self+
173
- def chainees
172
+ # An array of exceptions in the chain, excluding +self+
173
+ def chainees
174
174
 
175
- return [] unless cause
175
+ return [] unless cause
176
176
 
177
- r = [ cause ]
177
+ r = [ cause ]
178
178
 
179
- r += cause.chainees if cause.respond_to? :chainees
179
+ r += cause.chainees if cause.respond_to? :chainees
180
180
 
181
- r
182
- end
181
+ r
182
+ end
183
183
 
184
- # An array of exceptions in the chain, including +self+
185
- def exceptions
184
+ # An array of exceptions in the chain, including +self+
185
+ def exceptions
186
186
 
187
- [ self ] + chainees
188
- end
187
+ [ self ] + chainees
188
+ end
189
189
 
190
- # A combination of the backtrace(s) of all chained exception(s)
191
- def chained_backtrace
190
+ # A combination of the backtrace(s) of all chained exception(s)
191
+ def chained_backtrace
192
192
 
193
- b = backtrace
193
+ b = backtrace
194
194
 
195
- return b unless cause
195
+ return b unless cause
196
196
 
197
- cb = cause.respond_to?(:chained_backtrace) ? cause.chained_backtrace : cause.backtrace
197
+ cb = cause.respond_to?(:chained_backtrace) ? cause.chained_backtrace : cause.backtrace
198
198
 
199
- (cb - b) + b
200
- end
199
+ (cb - b) + b
200
+ end
201
201
  end
202
202
 
203
203
  end # module Exceptions