xqsr3 0.37.0 → 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: '048dfbb7beeff5b7e90df73f59be96e686611f91'
4
- data.tar.gz: 815facf131a846b49eec30be5e45bf369383d52d
3
+ metadata.gz: 3e4daad1c3c67fdf61c583a51ba736ff81e75b80
4
+ data.tar.gz: d6d61c42b272907440cd1050b24d86be9cada0b9
5
5
  SHA512:
6
- metadata.gz: e77733d055c75114bcd38811e5af5f89726c563976d49b8d197246309ac6a2c92ade6cf66e812f81a02b17f682f530b870441fc9f8436b499179dee2165d539c
7
- data.tar.gz: 38743b47b07c1b1876d680a759e6c9ec3e9aac7ef6482305a2dbe452fa5d1f28e0bb3b5921653778feb94b76a8f884f90eb03dbae7bad9dd6d5815fad9902308
6
+ metadata.gz: 3a5986a93e709f33a02cfc1c90343b0f520ab4960c8b42b97df96fc71a34debfd41932a2012e98afcd6392e5d37b2b694bc7f6fc4fcefbd9c25b6a3587c8d5dc
7
+ data.tar.gz: 0d7d35382e452b1f104d04da69c7113e9f59e157357ff78efbaa0c9cb9f3a92c181122792b8fafcbb9ac5c6c6cb9c7da2e2ca432d02b1e55c5e4c93616baaa5e
data/README.md CHANGED
@@ -23,7 +23,7 @@ It may be pronounced (lamely) as "excusers".
23
23
  Install via **gem** as in:
24
24
 
25
25
  ```
26
- gem install libclimate-ruby
26
+ gem install libclimate-ruby
27
27
  ```
28
28
 
29
29
  or add it to your `Gemfile`.
@@ -6,12 +6,13 @@
6
6
  # ::Xqsr3::CommandLineUtilities::MapOptionString module
7
7
  #
8
8
  # Created: 15th April 2016
9
- # Updated: 15th April 2019
9
+ # Updated: 19th July 2022
10
10
  #
11
11
  # Home: http://github.com/synesissoftware/xqsr3
12
12
  #
13
13
  # Author: Matthew Wilson
14
14
  #
15
+ # Copyright (c) 2019-2022, Matthew Wilson and Synesis Information Systems
15
16
  # Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
16
17
  # All rights reserved.
17
18
  #
@@ -1,5 +1,5 @@
1
1
 
2
- unless Hash.instance_methods.include? :except
2
+ unless Hash.instance_methods.include? :except!
3
3
 
4
4
  class Hash
5
5
 
@@ -14,6 +14,12 @@ unless Hash.instance_methods.include? :except
14
14
 
15
15
  self
16
16
  end
17
+ end
18
+ end
19
+
20
+ unless Hash.instance_methods.include? :except
21
+
22
+ class Hash
17
23
 
18
24
  # Obtains a copy of the instance wherein any key-value pairs
19
25
  # matching the keys specified in +keys_to_delete+ are removed
@@ -6,3 +6,12 @@ class String
6
6
  include ::Xqsr3::CommandLineUtilities::MapOptionString
7
7
  end # class String
8
8
 
9
+ class NilClass
10
+
11
+ def map_option_string *args
12
+
13
+ nil
14
+ end
15
+ end
16
+
17
+
@@ -11,11 +11,9 @@ module X_assert_raise_with_message_ # :nodoc: all
11
11
 
12
12
  if TestUnitVersion_.is_at_least? [ 3, 0, 8 ]
13
13
 
14
- # @!visibility private
15
14
  AssertionFailedError_ = Test::Unit::AssertionFailedError # :nodoc:
16
15
  else
17
16
 
18
- # @!visibility private
19
17
  class AssertionFailedError_ < ArgumentError; end # :nodoc:
20
18
  end
21
19
 
@@ -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 }
@@ -63,8 +63,6 @@ module QuoteIf
63
63
 
64
64
  def self.string_quote_if_array_ s, options # :nodoc:
65
65
 
66
- #$stderr.puts "#{self}#{__method__}(s (#{s.class})='#{s}', options (#{options.class})='#{options}'"
67
-
68
66
  s = s.to_s unless String === s
69
67
 
70
68
  quotes = options[:quotes] || [ '"', '"' ]
@@ -72,8 +70,6 @@ module QuoteIf
72
70
 
73
71
  quotables = options[:quotables] || /\s/
74
72
 
75
- #$stderr.puts "quotables (#{quotables.class}): [#{quotables}]"
76
-
77
73
  case quotables
78
74
  when ::String
79
75
 
data/lib/xqsr3/version.rb CHANGED
@@ -5,13 +5,13 @@
5
5
  # Purpose: Version for Xqsr3 library
6
6
  #
7
7
  # Created: 3rd April 2016
8
- # Updated: 20th April 2021
8
+ # Updated: 25th July 2022
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2021, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2022, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -51,7 +51,7 @@
51
51
  module Xqsr3
52
52
 
53
53
  # Current version of the Xqsr3 library
54
- VERSION = '0.37.0'
54
+ VERSION = '0.38.0'
55
55
 
56
56
  private
57
57
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -35,5 +35,10 @@ class Test_Xqsr3_CommandLineUtilities_map_option_string < Test::Unit::TestCase
35
35
  assert_nil MapOptionString.map_option_string_from_string(shortcut, option_strings)
36
36
  end
37
37
  end
38
+
39
+ def test_nil
40
+
41
+ assert_nil nil.map_option_string []
42
+ end
38
43
  end
39
44
 
@@ -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.0
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: 2021-04-20 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
@@ -162,9 +162,12 @@ require_paths:
162
162
  - lib
163
163
  required_ruby_version: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - "~>"
165
+ - - ">="
166
166
  - !ruby/object:Gem::Version
167
167
  version: '2.0'
168
+ - - "<"
169
+ - !ruby/object:Gem::Version
170
+ version: '4'
168
171
  required_rubygems_version: !ruby/object:Gem::Requirement
169
172
  requirements:
170
173
  - - ">="