xqsr3 0.14.1 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d2428b61c6d1ffe6859382fac62b8ab460cafb8
4
- data.tar.gz: c8b15079affd7d14f1fc68fa64aa83b14ccc0c3c
3
+ metadata.gz: 910334beb91320d62615b7f02f9464022938e516
4
+ data.tar.gz: df68d9b8d9959735425d6c08b49aafa3df3e0af7
5
5
  SHA512:
6
- metadata.gz: f8e73c19d7d688d02e22a4db0d121d0d1da5b9432d1fe801ee55667f2f90eb8079ff622ae4d924dbb0e71e2d63b2f9d5c149923c979261acfddd768e8c40c711
7
- data.tar.gz: f208ebf0cabcb05ec49064db7478f0f5b37a0de948207cadec78662e66127593c9e08a25b456b816282a9998738860dc83f3919b88bd5ec542f55bbef8230a80
6
+ metadata.gz: 8b9e4d8e41e5d42bff485838be0ac51e74994e0a06e66edd416362ace55fe878021545f2313e531e629274f85b146bab0c5f41df74d12211367097974679ecb8
7
+ data.tar.gz: f8e8e8ff15521a4afa43ebee7b155c9f9a3b2982a990eec0c2bc684b2cb52a656203682cf77696aea4450465e12dc1c59f8f8521acd78e0761a7970e039c10db
@@ -0,0 +1,82 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/extensions/kernel/integer.rb
4
+ #
5
+ # Purpose: Adds a Integer 'overload' to the Kernel module
6
+ #
7
+ # Created: 21st November 2017
8
+ # Updated: 21st November 2017
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2017, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright
22
+ # notice, this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ # ##########################################################
48
+ # ::Kernel
49
+
50
+ =begin
51
+ =end
52
+
53
+ module Kernel
54
+
55
+ alias xqsr3_Integer_original_method Integer
56
+
57
+ def Integer(arg, base = 0, **options)
58
+
59
+ if options.has_key?(:default) || options[:nil]
60
+
61
+ unless arg.nil?
62
+
63
+ begin
64
+
65
+ return xqsr3_Integer_original_method arg, base
66
+ rescue ArgumentError
67
+ end
68
+ end
69
+
70
+ return options[:default] if options.has_key? :default
71
+
72
+ return nil
73
+ else
74
+
75
+ xqsr3_Integer_original_method arg, base
76
+ end
77
+ end
78
+ end # module Kernel
79
+
80
+ # ############################## end of file ############################# #
81
+
82
+
@@ -61,6 +61,8 @@ module QuoteIf
61
61
 
62
62
  def self.string_quote_if_array_ s, options
63
63
 
64
+ #$stderr.puts "#{self}#{__method__}(s (#{s.class})='#{s}', options (#{options.class})='#{options}'"
65
+
64
66
  s = s.to_s unless String === s
65
67
 
66
68
  quotes = options[:quotes] || [ '"', '"' ]
@@ -68,6 +70,8 @@ module QuoteIf
68
70
 
69
71
  quotables = options[:quotables] || /\s/
70
72
 
73
+ #$stderr.puts "quotables (#{quotables.class}): [#{quotables}]"
74
+
71
75
  case quotables
72
76
  when ::String
73
77
 
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: 15th November 2017
8
+ # Updated: 22nd November 2017
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
@@ -50,7 +50,7 @@
50
50
  module Xqsr3
51
51
 
52
52
  # Current version of the Xqsr3 library
53
- VERSION = '0.14.1'
53
+ VERSION = '0.15.1'
54
54
 
55
55
  private
56
56
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -0,0 +1,65 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
+
5
+ require 'xqsr3/extensions/kernel/integer'
6
+
7
+ require 'test/unit'
8
+
9
+ class Test_X_Kernel_Integer < Test::Unit::TestCase
10
+
11
+ def test_Integer_with_valid_values
12
+
13
+ assert_equal 0, Integer(0)
14
+ assert_equal +1, Integer(1)
15
+ assert_equal +1, Integer(+1)
16
+ assert_equal -1, Integer(-1)
17
+
18
+ assert_equal 0, Integer('0')
19
+ assert_equal +1, Integer('1')
20
+ assert_equal +1, Integer('+1')
21
+ assert_equal -1, Integer('-1')
22
+ end
23
+
24
+ def test_Integer_with_invalid_values
25
+
26
+ assert_raise(TypeError) { Integer nil }
27
+ assert_raise(ArgumentError) { Integer '' }
28
+ assert_raise(ArgumentError) { Integer 'abc' }
29
+ assert_raise(ArgumentError) { Integer 'zero' }
30
+ assert_raise(ArgumentError) { Integer 'plus 1' }
31
+ assert_raise(ArgumentError) { Integer '/0' }
32
+ end
33
+
34
+ def test_Integer_with_invalid_values_returning_nil
35
+
36
+ assert_nil Integer(nil, nil: true)
37
+ assert_nil Integer('', nil: true)
38
+ assert_nil Integer('abc', nil: true)
39
+ assert_nil Integer('zero', nil: true)
40
+ assert_nil Integer('plus 1', nil: true)
41
+ assert_nil Integer('/0', nil: true)
42
+ end
43
+
44
+ def test_Integer_with_invalid_values_returning_0
45
+
46
+ assert_equal 0, Integer(nil, default: 0)
47
+ assert_equal 0, Integer('', default: 0)
48
+ assert_equal 0, Integer('abc', default: 0)
49
+ assert_equal 0, Integer('zero', default: 0)
50
+ assert_equal 0, Integer('plus 1', default: 0)
51
+ assert_equal 0, Integer('/0', default: 0)
52
+ end
53
+
54
+ def test_Integer_with_invalid_values_returning_sentinel
55
+
56
+ assert_equal :sentinel, Integer(nil, default: :sentinel)
57
+ assert_equal :sentinel, Integer('', default: :sentinel)
58
+ assert_equal :sentinel, Integer('abc', default: :sentinel)
59
+ assert_equal :sentinel, Integer('zero', default: :sentinel)
60
+ assert_equal :sentinel, Integer('plus 1', default: :sentinel)
61
+ assert_equal :sentinel, Integer('/0', default: :sentinel)
62
+ end
63
+ end
64
+
65
+
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.14.1
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-16 00:00:00.000000000 Z
11
+ date: 2017-11-22 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
@@ -19,41 +19,44 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - LICENSE
23
+ - README.md
22
24
  - lib/xqsr3/command_line_utilities/map_option_string.rb
23
25
  - lib/xqsr3/containers/frequency_map.rb
24
26
  - lib/xqsr3/containers/multi_map.rb
25
27
  - lib/xqsr3/conversion/bool_parser.rb
26
28
  - lib/xqsr3/diagnostics/exception_utilities.rb
27
29
  - lib/xqsr3/doc_.rb
30
+ - lib/xqsr3/extensions/enumerable.rb
28
31
  - lib/xqsr3/extensions/enumerable/collect_with_index.rb
29
32
  - lib/xqsr3/extensions/enumerable/unique.rb
30
- - lib/xqsr3/extensions/enumerable.rb
33
+ - lib/xqsr3/extensions/hash.rb
31
34
  - lib/xqsr3/extensions/hash/deep_transform.rb
32
35
  - lib/xqsr3/extensions/hash/has_match.rb
33
36
  - lib/xqsr3/extensions/hash/match.rb
34
- - lib/xqsr3/extensions/hash.rb
35
- - lib/xqsr3/extensions/io/writelines.rb
36
37
  - lib/xqsr3/extensions/io.rb
37
- - lib/xqsr3/extensions/kernel/raise_with_options.rb
38
+ - lib/xqsr3/extensions/io/writelines.rb
38
39
  - lib/xqsr3/extensions/kernel.rb
40
+ - lib/xqsr3/extensions/kernel/integer.rb
41
+ - lib/xqsr3/extensions/kernel/raise_with_options.rb
42
+ - lib/xqsr3/extensions/string.rb
39
43
  - lib/xqsr3/extensions/string/ends_with.rb
40
44
  - lib/xqsr3/extensions/string/map_option_string.rb
41
45
  - lib/xqsr3/extensions/string/quote_if.rb
42
46
  - lib/xqsr3/extensions/string/starts_with.rb
43
47
  - lib/xqsr3/extensions/string/to_bool.rb
44
48
  - lib/xqsr3/extensions/string/to_symbol.rb
45
- - lib/xqsr3/extensions/string.rb
49
+ - lib/xqsr3/extensions/test/unit.rb
46
50
  - lib/xqsr3/extensions/test/unit/assert_eql.rb
47
51
  - lib/xqsr3/extensions/test/unit/assert_false.rb
48
52
  - lib/xqsr3/extensions/test/unit/assert_not.rb
49
53
  - lib/xqsr3/extensions/test/unit/assert_not_eql.rb
50
54
  - lib/xqsr3/extensions/test/unit/assert_true.rb
51
- - lib/xqsr3/extensions/test/unit.rb
52
55
  - lib/xqsr3/hash_utilities/deep_transform.rb
53
56
  - lib/xqsr3/hash_utilities/key_matching.rb
54
57
  - lib/xqsr3/io/writelines.rb
55
- - lib/xqsr3/quality/parameter_checking.rb
56
58
  - lib/xqsr3/quality.rb
59
+ - lib/xqsr3/quality/parameter_checking.rb
57
60
  - lib/xqsr3/string_utilities/ends_with.rb
58
61
  - lib/xqsr3/string_utilities/quote_if.rb
59
62
  - lib/xqsr3/string_utilities/starts_with.rb
@@ -76,6 +79,7 @@ files:
76
79
  - test/unit/extensions/hash/ts_all.rb
77
80
  - test/unit/extensions/io/tc_writelines.rb
78
81
  - test/unit/extensions/io/ts_all.rb
82
+ - test/unit/extensions/kernel/tc_integer.rb
79
83
  - test/unit/extensions/kernel/tc_raise_with_options.rb
80
84
  - test/unit/extensions/kernel/ts_all.rb
81
85
  - test/unit/extensions/string/tc_bool.tb
@@ -98,8 +102,6 @@ files:
98
102
  - test/unit/xml/ts_all.rb
99
103
  - test/unit/xml/utilities/tc_compare.rb
100
104
  - test/unit/xml/utilities/ts_all.rb
101
- - README.md
102
- - LICENSE
103
105
  homepage: http://github.com/synesissoftware/xqsr3
104
106
  licenses:
105
107
  - 3-clause BSD
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  version: '0'
121
123
  requirements: []
122
124
  rubyforge_project:
123
- rubygems_version: 2.0.14.1
125
+ rubygems_version: 2.4.2
124
126
  signing_key:
125
127
  specification_version: 4
126
128
  summary: xqsr3