xqsr3 0.21.3 → 0.22.2
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/xqsr3/extensions/string/nil_if_empty.rb +8 -0
- data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +8 -0
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +94 -0
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +94 -0
- data/lib/xqsr3/version.rb +2 -2
- data/lib/xqsr3/xml/utilities/compare.rb +9 -2
- data/test/unit/extensions/string/tc_nil_if_empty.rb +27 -0
- data/test/unit/extensions/string/tc_nil_if_whitespace.rb +27 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91fb18a7f4ffac6b0ad761c9d41dc29b325f172c
|
4
|
+
data.tar.gz: 06db1f1fb19d9afed8e77e65c1c4f543af6fdee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 265250202da381835bb2a4d8fdde5197293dffc01f0fdf4da89fb51672883ec31ba1f6e1bfe01c2745e5b92dfaff417a50163be63e098bc328f1d82a2189a7d2
|
7
|
+
data.tar.gz: 85318de93eeb417cee8b49fe45455b19ad8a7d3a5c8d2467edb68b22ac7196c52c79c84a06435ec6ccda5a226e43001cc0594a9540e6f4ea05cb592743330a2a
|
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
# ######################################################################## #
|
3
|
+
# File: lib/xqsr3/string_utilities/nil_if_empty.rb
|
4
|
+
#
|
5
|
+
# Purpose: Definition of the ::Xqsr3::StringUtilities::NilIfEmpty
|
6
|
+
# module
|
7
|
+
#
|
8
|
+
# Created: 25th January 2018
|
9
|
+
# Updated: 25th January 2018
|
10
|
+
#
|
11
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
12
|
+
#
|
13
|
+
# Author: Matthew Wilson
|
14
|
+
#
|
15
|
+
# Copyright (c) 2018, Matthew Wilson and Synesis Software
|
16
|
+
# All rights reserved.
|
17
|
+
#
|
18
|
+
# Redistribution and use in source and binary forms, with or without
|
19
|
+
# modification, are permitted provided that the following conditions are
|
20
|
+
# met:
|
21
|
+
#
|
22
|
+
# * Redistributions of source code must retain the above copyright notice,
|
23
|
+
# this list of conditions and the following disclaimer.
|
24
|
+
#
|
25
|
+
# * Redistributions in binary form must reproduce the above copyright
|
26
|
+
# notice, this list of conditions and the following disclaimer in the
|
27
|
+
# documentation and/or other materials provided with the distribution.
|
28
|
+
#
|
29
|
+
# * Neither the names of the copyright holder nor the names of its
|
30
|
+
# contributors may be used to endorse or promote products derived from
|
31
|
+
# this software without specific prior written permission.
|
32
|
+
#
|
33
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
34
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
35
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
36
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
37
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
38
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
39
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
40
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
41
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
42
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
43
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
44
|
+
#
|
45
|
+
# ######################################################################## #
|
46
|
+
|
47
|
+
|
48
|
+
# ##########################################################
|
49
|
+
# ::Xqsr3::StringUtilities::NilIfEmpty
|
50
|
+
|
51
|
+
=begin
|
52
|
+
=end
|
53
|
+
|
54
|
+
module Xqsr3
|
55
|
+
module StringUtilities
|
56
|
+
|
57
|
+
module NilIfEmpty
|
58
|
+
|
59
|
+
private
|
60
|
+
module NilIfEmpty_Helper_ #:nodoc:
|
61
|
+
|
62
|
+
def self.string_nil_if_empty_array_ s
|
63
|
+
|
64
|
+
return s if s && !s.empty?
|
65
|
+
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
public
|
70
|
+
|
71
|
+
# Returns +nil+ if the given string is empty, otherwise returning the
|
72
|
+
# given string
|
73
|
+
#
|
74
|
+
# === *Parameters*
|
75
|
+
#
|
76
|
+
# * *Required parameters*:
|
77
|
+
# - +s+:: [String] The string to be evaluated
|
78
|
+
def self.string_nil_if_empty s
|
79
|
+
|
80
|
+
NilIfEmpty_Helper_.string_nil_if_empty_array_ s
|
81
|
+
end
|
82
|
+
|
83
|
+
def nil_if_empty
|
84
|
+
|
85
|
+
NilIfEmpty_Helper_.string_nil_if_empty_array_ self
|
86
|
+
end
|
87
|
+
end # module NilIfEmpty
|
88
|
+
|
89
|
+
end # module StringUtilities
|
90
|
+
end # module Xqsr3
|
91
|
+
|
92
|
+
# ############################## end of file ############################# #
|
93
|
+
|
94
|
+
|
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
# ######################################################################## #
|
3
|
+
# File: lib/xqsr3/string_utilities/nil_if_whitespace.rb
|
4
|
+
#
|
5
|
+
# Purpose: Definition of the ::Xqsr3::StringUtilities::NilIfWhitespace
|
6
|
+
# module
|
7
|
+
#
|
8
|
+
# Created: 25th January 2018
|
9
|
+
# Updated: 25th January 2018
|
10
|
+
#
|
11
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
12
|
+
#
|
13
|
+
# Author: Matthew Wilson
|
14
|
+
#
|
15
|
+
# Copyright (c) 2018, Matthew Wilson and Synesis Software
|
16
|
+
# All rights reserved.
|
17
|
+
#
|
18
|
+
# Redistribution and use in source and binary forms, with or without
|
19
|
+
# modification, are permitted provided that the following conditions are
|
20
|
+
# met:
|
21
|
+
#
|
22
|
+
# * Redistributions of source code must retain the above copyright notice,
|
23
|
+
# this list of conditions and the following disclaimer.
|
24
|
+
#
|
25
|
+
# * Redistributions in binary form must reproduce the above copyright
|
26
|
+
# notice, this list of conditions and the following disclaimer in the
|
27
|
+
# documentation and/or other materials provided with the distribution.
|
28
|
+
#
|
29
|
+
# * Neither the names of the copyright holder nor the names of its
|
30
|
+
# contributors may be used to endorse or promote products derived from
|
31
|
+
# this software without specific prior written permission.
|
32
|
+
#
|
33
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
34
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
35
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
36
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
37
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
38
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
39
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
40
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
41
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
42
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
43
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
44
|
+
#
|
45
|
+
# ######################################################################## #
|
46
|
+
|
47
|
+
|
48
|
+
# ##########################################################
|
49
|
+
# ::Xqsr3::StringUtilities::NilIfWhitespace
|
50
|
+
|
51
|
+
=begin
|
52
|
+
=end
|
53
|
+
|
54
|
+
module Xqsr3
|
55
|
+
module StringUtilities
|
56
|
+
|
57
|
+
module NilIfWhitespace
|
58
|
+
|
59
|
+
private
|
60
|
+
module NilIfWhitespace_Helper_ #:nodoc:
|
61
|
+
|
62
|
+
def self.string_nil_if_whitespace_array_ s
|
63
|
+
|
64
|
+
return nil if s.strip.empty?
|
65
|
+
|
66
|
+
s
|
67
|
+
end
|
68
|
+
end
|
69
|
+
public
|
70
|
+
|
71
|
+
# Returns +nil+ if the given string is empty or contains only whitespace,
|
72
|
+
# otherwise returning the given string
|
73
|
+
#
|
74
|
+
# === *Parameters*
|
75
|
+
#
|
76
|
+
# * *Required parameters*:
|
77
|
+
# - +s+:: [String] The string to be evaluated
|
78
|
+
def self.string_nil_if_whitespace s
|
79
|
+
|
80
|
+
NilIfWhitespace_Helper_.string_nil_if_whitespace_array_ s
|
81
|
+
end
|
82
|
+
|
83
|
+
def nil_if_whitespace
|
84
|
+
|
85
|
+
NilIfWhitespace_Helper_.string_nil_if_whitespace_array_ self
|
86
|
+
end
|
87
|
+
end # module NilIfWhitespace
|
88
|
+
|
89
|
+
end # module StringUtilities
|
90
|
+
end # module Xqsr3
|
91
|
+
|
92
|
+
# ############################## end of file ############################# #
|
93
|
+
|
94
|
+
|
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:
|
8
|
+
# Updated: 1st February 2018
|
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.
|
53
|
+
VERSION = '0.22.2'
|
54
54
|
|
55
55
|
private
|
56
56
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
@@ -6,13 +6,13 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 30th July 2017
|
9
|
-
# Updated: 1st
|
9
|
+
# Updated: 1st February 2018
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
13
13
|
# Author: Matthew Wilson
|
14
14
|
#
|
15
|
-
# Copyright (c) 2017, Matthew Wilson and Synesis Software
|
15
|
+
# Copyright (c) 2017-2018, Matthew Wilson and Synesis Software
|
16
16
|
# All rights reserved.
|
17
17
|
#
|
18
18
|
# Redistribution and use in source and binary forms, with or without
|
@@ -149,6 +149,13 @@ module Compare
|
|
149
149
|
|
150
150
|
r
|
151
151
|
end
|
152
|
+
|
153
|
+
def to_s
|
154
|
+
|
155
|
+
return 'same' if same?
|
156
|
+
|
157
|
+
"different, because: #{details}"
|
158
|
+
end
|
152
159
|
end
|
153
160
|
|
154
161
|
module Internal_Compare_
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
|
4
|
+
|
5
|
+
require 'xqsr3/extensions/string/nil_if_empty'
|
6
|
+
|
7
|
+
require 'xqsr3/extensions/test/unit'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
require 'stringio'
|
11
|
+
|
12
|
+
class Test_String_nil_if_empty < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def test_String_has_method
|
15
|
+
|
16
|
+
assert ''.respond_to? :nil_if_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_nil_if_empty
|
20
|
+
|
21
|
+
assert_nil ''.nil_if_empty
|
22
|
+
assert_equal ' ', ' '.nil_if_empty
|
23
|
+
assert_equal 'a', 'a'.nil_if_empty
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
|
4
|
+
|
5
|
+
require 'xqsr3/extensions/string/nil_if_whitespace'
|
6
|
+
|
7
|
+
require 'xqsr3/extensions/test/unit'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
require 'stringio'
|
11
|
+
|
12
|
+
class Test_String_nil_if_whitespace < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def test_String_has_method
|
15
|
+
|
16
|
+
assert ''.respond_to? :nil_if_whitespace
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_nil_if_whitespace
|
20
|
+
|
21
|
+
assert_nil ''.nil_if_whitespace
|
22
|
+
assert_nil ' '.nil_if_whitespace
|
23
|
+
assert_equal 'a', 'a'.nil_if_whitespace
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
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.
|
4
|
+
version: 0.22.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-05 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
|
@@ -46,6 +46,8 @@ files:
|
|
46
46
|
- lib/xqsr3/extensions/string.rb
|
47
47
|
- lib/xqsr3/extensions/string/ends_with.rb
|
48
48
|
- lib/xqsr3/extensions/string/map_option_string.rb
|
49
|
+
- lib/xqsr3/extensions/string/nil_if_empty.rb
|
50
|
+
- lib/xqsr3/extensions/string/nil_if_whitespace.rb
|
49
51
|
- lib/xqsr3/extensions/string/quote_if.rb
|
50
52
|
- lib/xqsr3/extensions/string/starts_with.rb
|
51
53
|
- lib/xqsr3/extensions/string/to_bool.rb
|
@@ -66,6 +68,8 @@ files:
|
|
66
68
|
- lib/xqsr3/quality.rb
|
67
69
|
- lib/xqsr3/quality/parameter_checking.rb
|
68
70
|
- lib/xqsr3/string_utilities/ends_with.rb
|
71
|
+
- lib/xqsr3/string_utilities/nil_if_empty.rb
|
72
|
+
- lib/xqsr3/string_utilities/nil_if_whitespace.rb
|
69
73
|
- lib/xqsr3/string_utilities/quote_if.rb
|
70
74
|
- lib/xqsr3/string_utilities/starts_with.rb
|
71
75
|
- lib/xqsr3/string_utilities/to_symbol.rb
|
@@ -98,6 +102,8 @@ files:
|
|
98
102
|
- test/unit/extensions/string/tc_bool.tb
|
99
103
|
- test/unit/extensions/string/tc_ends_with.rb
|
100
104
|
- test/unit/extensions/string/tc_map_option_string.rb
|
105
|
+
- test/unit/extensions/string/tc_nil_if_empty.rb
|
106
|
+
- test/unit/extensions/string/tc_nil_if_whitespace.rb
|
101
107
|
- test/unit/extensions/string/tc_quote_if.rb
|
102
108
|
- test/unit/extensions/string/tc_starts_with.rb
|
103
109
|
- test/unit/extensions/string/tc_to_symbol.rb
|