xqsr3 0.37.3 → 0.38.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e140803e312c0a06fa78a8a99c170faf11cdc2ec
4
- data.tar.gz: 639bbc9ea46908b0de04fc7eb011e112285258d7
3
+ metadata.gz: 3e4daad1c3c67fdf61c583a51ba736ff81e75b80
4
+ data.tar.gz: d6d61c42b272907440cd1050b24d86be9cada0b9
5
5
  SHA512:
6
- metadata.gz: 91fe23e62c70ae6a91f000617572f058f4639c28d928c4e437167928eea835a8223b1f4fbb12d434719594942301acac70df54eafc9fdf99fd163bf15ea2183e
7
- data.tar.gz: 62cb7f51f9233708a10c0d058bd982fad508b7e065c81baa3a88622bd7097141ba93839f024a47ff114a54e2e8590e10e6834e61d31a20f193d06f39a73a23a2
6
+ metadata.gz: 3a5986a93e709f33a02cfc1c90343b0f520ab4960c8b42b97df96fc71a34debfd41932a2012e98afcd6392e5d37b2b694bc7f6fc4fcefbd9c25b6a3587c8d5dc
7
+ data.tar.gz: 0d7d35382e452b1f104d04da69c7113e9f59e157357ff78efbaa0c9cb9f3a92c181122792b8fafcbb9ac5c6c6cb9c7da2e2ca432d02b1e55c5e4c93616baaa5e
@@ -5,13 +5,14 @@
5
5
  # Purpose: Definition of the ParameterChecking module
6
6
  #
7
7
  # Created: 12th February 2015
8
- # Updated: 15th April 2019
8
+ # Updated: 22nd July 2022
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2019-2022, Matthew Wilson and Synesis Information Systems
15
+ # Copyright (c) 2016-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
@@ -199,6 +200,22 @@ module ParameterChecking
199
200
  Util_.check_parameter value, name, options, &block
200
201
  end
201
202
 
203
+ # Specific form of the +check_parameter()+ that is used to check
204
+ # options, taking instead the hash and the key
205
+ #
206
+ # === Signature
207
+ #
208
+ # * *Parameters:*
209
+ # - +h+ (::Hash) The options hash from which the named element is to be tested. May not be +nil+
210
+ # - +name+ (::String, ::Symbol, [ ::String, ::Symbol ]) The options key name, or an array of names. May not be +nil+
211
+ # - +options+ (::Hash) options that moderate the behaviour in the same way as for +check_parameter()+ except that the +:treat_as_option+ option (with the value +true+) is merged in before calling +check_parameter()+
212
+ #
213
+ # * *Options:*
214
+ def self.check_option h, name, options = {}, &block
215
+
216
+ Util_.check_option h, name, options, &block
217
+ end
218
+
202
219
  private
203
220
  def Util_.check_option h, names, options = {}, &block
204
221
 
@@ -381,6 +398,7 @@ module ParameterChecking
381
398
  # messages
382
399
 
383
400
  messages = options[:responds_to] || []
401
+ messages = [ messages ] unless messages.respond_to? :each
384
402
 
385
403
  warn "#{self}::check_parameter: options[:responds_to] of type #{messages.class} - should be #{::Array}" unless messages.is_a?(Array)
386
404
  warn "#{self}::check_parameter: options[:responds_to] should contain only symbols or strings" if messages.is_a?(::Array) && !messages.all? { |m| ::Symbol === m || ::String === m }
data/lib/xqsr3/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # Purpose: Version for Xqsr3 library
6
6
  #
7
7
  # Created: 3rd April 2016
8
- # Updated: 19th July 2022
8
+ # Updated: 25th July 2022
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
@@ -51,7 +51,7 @@
51
51
  module Xqsr3
52
52
 
53
53
  # Current version of the Xqsr3 library
54
- VERSION = '0.37.3'
54
+ VERSION = '0.38.0'
55
55
 
56
56
  private
57
57
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -7,13 +7,39 @@ require 'xqsr3/quality/parameter_checking'
7
7
  require 'xqsr3/extensions/test/unit'
8
8
  require 'test/unit'
9
9
 
10
+
11
+ class Test_check_option_multiple_option_names < Test::Unit::TestCase
12
+
13
+ include ::Xqsr3::Quality::ParameterChecking
14
+
15
+ def check_method_stringise_stringize **options
16
+
17
+ check_option options, [ :stringise, :stringize ], nil: true
18
+ end
19
+
20
+ def test_1
21
+
22
+ assert_nil check_method_stringise_stringize()
23
+
24
+ assert_nil check_method_stringise_stringize(abc: :abc)
25
+
26
+ assert_equal :stringize, check_method_stringise_stringize(stringize: :stringize)
27
+ assert_equal :stringise, check_method_stringise_stringize(stringise: :stringise)
28
+ assert_equal :stringise, check_method_stringise_stringize(stringize: :stringize, stringise: :stringise)
29
+ assert_equal :stringise, check_method_stringise_stringize(stringise: :stringise, stringize: :stringize)
30
+ end
31
+ end
32
+
10
33
  class Test_parameter_checks_as_separate_module < Test::Unit::TestCase
11
34
 
12
35
  PC = ::Xqsr3::Quality::ParameterChecking
13
36
 
14
37
  # test 1
15
38
 
16
- def check_method_1 a
39
+ def check_method_1 a, **options
40
+
41
+ PC.check_option options, :o1, nil: true
42
+ PC.check_option options, :o2, nil: false
17
43
 
18
44
  PC.check_param a, 'a'
19
45
  end
@@ -25,10 +51,10 @@ class Test_parameter_checks_as_separate_module < Test::Unit::TestCase
25
51
  check_method_1(nil)
26
52
  end
27
53
 
28
- assert_equal true, check_method_1(true)
29
- assert_equal '', check_method_1('')
30
- assert_equal [], check_method_1([])
31
- assert_equal Hash.new, check_method_1(Hash.new)
54
+ assert_equal true, check_method_1(true, o1: true, o2: false)
55
+ assert_equal '', check_method_1('', o1: true, o2: false)
56
+ assert_equal [], check_method_1([], o1: true, o2: false)
57
+ assert_equal Hash.new, check_method_1(Hash.new, o1: true, o2: false)
32
58
  end
33
59
 
34
60
 
@@ -328,6 +354,11 @@ end
328
354
 
329
355
  check_responds_to Hash.new, [ :this_is_not_a_Hash_method ]
330
356
  end
357
+
358
+ # check can pass single types
359
+ assert check_responds_to Hash.new, :[]
360
+ assert check_responds_to Hash.new, :map
361
+ assert check_responds_to Hash.new, :to_s
331
362
  end
332
363
 
333
364
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xqsr3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.37.3
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-19 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  eXtensions by fine Quantum for Standard Ruby and 3rd-party libraries is a