libclimate-ruby 0.17.0.2 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libclimate/climate.rb +5 -4
- data/lib/libclimate/version.rb +1 -1
- data/test/unit/tc_parse_and_verify.rb +80 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1014739a5918db9efeb5135cf15f993bdd7ef3e09192661b9ea204ff56162f0
|
|
4
|
+
data.tar.gz: 74d345f4b3bb769d416b0a13adf6483810855426b7fcc38a78fc62086b391b9e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 622c85547fcf19727ee1fda68455440791001652d4d29d323f051061ac426b493aecab3cd7be8bb89b53403aa53a397b83139d5228b854eff577443597a5a463
|
|
7
|
+
data.tar.gz: c55439ac1104533836c03f9a786d1a2ab80677a4a8b3947ea46ffb103ac81686906ddcc910a8c80bd43247b974a672ce8dd8219614a7098d7786bc012c0c869c
|
data/lib/libclimate/climate.rb
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
# Purpose: Definition of the ::LibCLImate::Climate class
|
|
6
6
|
#
|
|
7
7
|
# Created: 13th July 2015
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 30th July 2026
|
|
9
9
|
#
|
|
10
10
|
# Home: http://github.com/synesissoftware/libCLImate.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
|
14
|
-
# Copyright (c) 2019-
|
|
14
|
+
# Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -264,7 +264,7 @@ class Climate
|
|
|
264
264
|
end
|
|
265
265
|
else
|
|
266
266
|
|
|
267
|
-
message = make_abort_message_("unrecognised flag '#{
|
|
267
|
+
message = climate.make_abort_message_("unrecognised flag '#{flag}'")
|
|
268
268
|
|
|
269
269
|
if false
|
|
270
270
|
|
|
@@ -312,7 +312,7 @@ class Climate
|
|
|
312
312
|
end
|
|
313
313
|
else
|
|
314
314
|
|
|
315
|
-
message = make_abort_message_("unrecognised option '#{
|
|
315
|
+
message = climate.make_abort_message_("unrecognised option '#{option}'")
|
|
316
316
|
|
|
317
317
|
if false
|
|
318
318
|
|
|
@@ -378,6 +378,7 @@ class Climate
|
|
|
378
378
|
GIVEN_SPECS_ = "_Given_Specs_01B59422_8407_4c89_9432_8160C52BD5AD"
|
|
379
379
|
end # module Climate_Constants_
|
|
380
380
|
|
|
381
|
+
public
|
|
381
382
|
def make_abort_message_(msg)
|
|
382
383
|
|
|
383
384
|
if 0 != (usage_help_suffix || 0).size
|
data/lib/libclimate/version.rb
CHANGED
|
@@ -156,5 +156,85 @@ class Test_Climate_parse_and_verify < Test::Unit::TestCase
|
|
|
156
156
|
climate.parse_and_verify argv, raise_on_required: MissingRequiredException
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
|
+
|
|
160
|
+
def test_unrecognized_flag_raises_unrecognised_argument_exception
|
|
161
|
+
|
|
162
|
+
stdout = StringIO.new
|
|
163
|
+
stderr = StringIO.new
|
|
164
|
+
|
|
165
|
+
climate = LibCLImate::Climate.new do |cl|
|
|
166
|
+
|
|
167
|
+
cl.stdout = $stdout
|
|
168
|
+
cl.stderr = $stderr
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
assert $stdout.equal? climate.stdout
|
|
172
|
+
assert $stderr.equal? climate.stderr
|
|
173
|
+
|
|
174
|
+
argv = [
|
|
175
|
+
|
|
176
|
+
'--unrecognised-flag',
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
assert_raise_with_message(UnrecognisedArgumentException, /unrecognised flag '--unrecognised-flag'/) do
|
|
180
|
+
|
|
181
|
+
climate.parse_and_verify argv, raise_on_unrecognised: UnrecognisedArgumentException
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_unrecognized_option_raises_unrecognised_argument_exception
|
|
186
|
+
|
|
187
|
+
stdout = StringIO.new
|
|
188
|
+
stderr = StringIO.new
|
|
189
|
+
|
|
190
|
+
climate = LibCLImate::Climate.new do |cl|
|
|
191
|
+
|
|
192
|
+
cl.stdout = $stdout
|
|
193
|
+
cl.stderr = $stderr
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
assert $stdout.equal? climate.stdout
|
|
197
|
+
assert $stderr.equal? climate.stderr
|
|
198
|
+
|
|
199
|
+
argv = [
|
|
200
|
+
|
|
201
|
+
'--unrecognised-option=some_value',
|
|
202
|
+
]
|
|
203
|
+
|
|
204
|
+
assert_raise_with_message(UnrecognisedArgumentException, /unrecognised option '--unrecognised-option=some_value'/) do
|
|
205
|
+
|
|
206
|
+
climate.parse_and_verify argv, raise_on_unrecognised: UnrecognisedArgumentException
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_add_flag_method_exists_and_is_callable
|
|
211
|
+
|
|
212
|
+
climate = LibCLImate::Climate.new {}
|
|
213
|
+
|
|
214
|
+
# Assert that calling add_flag does not raise an exception
|
|
215
|
+
assert_nothing_raised do
|
|
216
|
+
|
|
217
|
+
climate.add_flag('--test-flag')
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Verify that the flag is added to specifications
|
|
221
|
+
assert_equal 3, climate.specifications.size
|
|
222
|
+
assert_equal '--test-flag', climate.specifications[2].name
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def test_add_option_method_exists_and_is_callable
|
|
226
|
+
|
|
227
|
+
climate = LibCLImate::Climate.new {}
|
|
228
|
+
|
|
229
|
+
# Assert that calling add_option does not raise an exception
|
|
230
|
+
assert_nothing_raised do
|
|
231
|
+
|
|
232
|
+
climate.add_option('--test-option')
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Verify that the option is added to specifications
|
|
236
|
+
assert_equal 3, climate.specifications.size
|
|
237
|
+
assert_equal '--test-option', climate.specifications[2].name
|
|
238
|
+
end
|
|
159
239
|
end
|
|
160
240
|
|