xqsr3 0.32.2 → 0.32.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xqsr3/array_utilities/join_with_or.rb +7 -14
- data/lib/xqsr3/command_line_utilities/map_option_string.rb +19 -7
- data/lib/xqsr3/containers/frequency_map.rb +1 -1
- data/lib/xqsr3/containers/multi_map.rb +28 -0
- data/lib/xqsr3/conversion/bool_parser.rb +11 -14
- data/lib/xqsr3/conversion/integer_parser.rb +7 -14
- data/lib/xqsr3/diagnostics/exception_utilities.rb +2 -2
- data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +15 -7
- data/lib/xqsr3/diagnostics/inspect_builder.rb +11 -15
- data/lib/xqsr3/doc_.rb +138 -9
- data/lib/xqsr3/extensions/array/join_with_or.rb +6 -0
- data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +5 -4
- data/lib/xqsr3/extensions/enumerable/detect_map.rb +6 -7
- data/lib/xqsr3/extensions/hash/has_match.rb +7 -0
- data/lib/xqsr3/extensions/hash/match.rb +7 -0
- data/lib/xqsr3/extensions/kernel/integer.rb +6 -13
- data/lib/xqsr3/extensions/string/to_bool.rb +4 -0
- data/lib/xqsr3/extensions/test/unit/assert_eql.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_false.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_not.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +5 -2
- data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_true.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +3 -12
- data/lib/xqsr3/hash_utilities/deep_transform.rb +2 -2
- data/lib/xqsr3/internal_/test_unit_version_.rb +4 -4
- data/lib/xqsr3/io/writelines.rb +6 -6
- data/lib/xqsr3/quality/parameter_checking.rb +50 -77
- data/lib/xqsr3/string_utilities/ends_with.rb +14 -6
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +6 -3
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +7 -3
- data/lib/xqsr3/string_utilities/quote_if.rb +10 -13
- data/lib/xqsr3/string_utilities/starts_with.rb +22 -5
- data/lib/xqsr3/string_utilities/to_symbol.rb +23 -5
- data/lib/xqsr3/string_utilities/truncate.rb +19 -4
- data/lib/xqsr3/version.rb +1 -1
- metadata +1 -1
@@ -54,12 +54,14 @@
|
|
54
54
|
module Xqsr3
|
55
55
|
module StringUtilities
|
56
56
|
|
57
|
+
# +include+-able module that provides ::string_ends_with? and #ends_with?
|
58
|
+
# methods
|
57
59
|
module EndsWith
|
58
60
|
|
59
61
|
private
|
60
|
-
module EndsWith_Helper_
|
62
|
+
module EndsWith_Helper_ # :nodoc:
|
61
63
|
|
62
|
-
def self.string_ends_with_helper_ s, prefix
|
64
|
+
def self.string_ends_with_helper_ s, prefix # :nodoc:
|
63
65
|
|
64
66
|
if prefix.nil? || prefix.empty?
|
65
67
|
|
@@ -78,7 +80,7 @@ module EndsWith
|
|
78
80
|
nil
|
79
81
|
end
|
80
82
|
|
81
|
-
def self.string_ends_with_array_ s, args
|
83
|
+
def self.string_ends_with_array_ s, args # :nodoc:
|
82
84
|
|
83
85
|
return '' if args.empty?
|
84
86
|
|
@@ -115,14 +117,20 @@ module EndsWith
|
|
115
117
|
# === Signature
|
116
118
|
#
|
117
119
|
# * *Parameters:*
|
118
|
-
#
|
119
|
-
#
|
120
|
-
# - +s+:: [String] The string to be evaluated
|
120
|
+
# - +s+ (String) The string to be evaluated
|
121
|
+
# - +args+ 0+ arguments against which +s+ will be evaluated
|
121
122
|
def self.string_ends_with? s, *args
|
122
123
|
|
123
124
|
EndsWith_Helper_.string_ends_with_array_ s, args
|
124
125
|
end
|
125
126
|
|
127
|
+
# Reports on whether the instance ends with a given prefix or set of
|
128
|
+
# prefixes (+args+)
|
129
|
+
#
|
130
|
+
# === Signature
|
131
|
+
#
|
132
|
+
# * *Parameters:*
|
133
|
+
# - +args+ 0+ arguments against which the instance will be evaluated
|
126
134
|
def ends_with? *args
|
127
135
|
|
128
136
|
EndsWith_Helper_.string_ends_with_array_ self, args
|
@@ -54,12 +54,14 @@
|
|
54
54
|
module Xqsr3
|
55
55
|
module StringUtilities
|
56
56
|
|
57
|
+
# +include+-able module that provides ::string_nil_if_empty and
|
58
|
+
# #nil_if_empty methods
|
57
59
|
module NilIfEmpty
|
58
60
|
|
59
61
|
private
|
60
|
-
module NilIfEmpty_Helper_
|
62
|
+
module NilIfEmpty_Helper_ # :nodoc:
|
61
63
|
|
62
|
-
def self.string_nil_if_empty_array_ s
|
64
|
+
def self.string_nil_if_empty_array_ s # :nodoc:
|
63
65
|
|
64
66
|
return s if s && !s.empty?
|
65
67
|
|
@@ -76,12 +78,13 @@ module NilIfEmpty
|
|
76
78
|
# * *Parameters:*
|
77
79
|
#
|
78
80
|
# * *Required parameters*:
|
79
|
-
# - +s
|
81
|
+
# - +s+ (String) The string to be evaluated
|
80
82
|
def self.string_nil_if_empty s
|
81
83
|
|
82
84
|
NilIfEmpty_Helper_.string_nil_if_empty_array_ s
|
83
85
|
end
|
84
86
|
|
87
|
+
# Returns +nil+ if the instance is empty, otherwise returning self
|
85
88
|
def nil_if_empty
|
86
89
|
|
87
90
|
NilIfEmpty_Helper_.string_nil_if_empty_array_ self
|
@@ -54,12 +54,14 @@
|
|
54
54
|
module Xqsr3
|
55
55
|
module StringUtilities
|
56
56
|
|
57
|
+
# +include+-able module that provides ::string_nil_if_whitespace and
|
58
|
+
# #nil_if_whitespace methods
|
57
59
|
module NilIfWhitespace
|
58
60
|
|
59
61
|
private
|
60
|
-
module NilIfWhitespace_Helper_
|
62
|
+
module NilIfWhitespace_Helper_ # :nodoc:
|
61
63
|
|
62
|
-
def self.string_nil_if_whitespace_array_ s
|
64
|
+
def self.string_nil_if_whitespace_array_ s # :nodoc:
|
63
65
|
|
64
66
|
return nil if s.strip.empty?
|
65
67
|
|
@@ -76,12 +78,14 @@ module NilIfWhitespace
|
|
76
78
|
# * *Parameters:*
|
77
79
|
#
|
78
80
|
# * *Required parameters*:
|
79
|
-
# - +s
|
81
|
+
# - +s+ (String) The string to be evaluated
|
80
82
|
def self.string_nil_if_whitespace s
|
81
83
|
|
82
84
|
NilIfWhitespace_Helper_.string_nil_if_whitespace_array_ s
|
83
85
|
end
|
84
86
|
|
87
|
+
# Returns +nil+ if the instance is empty or contains only whitespace,
|
88
|
+
# otherwise returning self
|
85
89
|
def nil_if_whitespace
|
86
90
|
|
87
91
|
NilIfWhitespace_Helper_.string_nil_if_whitespace_array_ self
|
@@ -54,12 +54,13 @@
|
|
54
54
|
module Xqsr3
|
55
55
|
module StringUtilities
|
56
56
|
|
57
|
+
# +include+-able module that provides ::quote_if and #quote_if methods
|
57
58
|
module QuoteIf
|
58
59
|
|
59
60
|
private
|
60
|
-
module QuoteIf_Helper_
|
61
|
+
module QuoteIf_Helper_ # :nodoc:
|
61
62
|
|
62
|
-
def self.string_quote_if_array_ s, options
|
63
|
+
def self.string_quote_if_array_ s, options # :nodoc:
|
63
64
|
|
64
65
|
s = s.to_s unless String === s
|
65
66
|
|
@@ -95,27 +96,23 @@ module QuoteIf
|
|
95
96
|
# * *Parameters:*
|
96
97
|
#
|
97
98
|
# * *Required parameters*:
|
98
|
-
# - +s
|
99
|
+
# - +s+ (String) The string to be evaluated
|
99
100
|
#
|
100
101
|
# * *Options parameters*:
|
101
|
-
# - +options
|
102
|
-
# method
|
102
|
+
# - +options+ (Hash) Options that control the behaviour of the method
|
103
103
|
#
|
104
104
|
# * *Options:*
|
105
105
|
#
|
106
|
-
# - +:quotes
|
107
|
-
#
|
108
|
-
# used as the opening and closing quotes. Defaults to '"'
|
109
|
-
# - +:quotables+:: [String, Array, Regexp] A string representing the
|
110
|
-
# quotable character, or an array containing the quotable
|
111
|
-
# characters, or a regular expression that determines by match
|
112
|
-
# whether the string should be quoted. Defaults to the regular
|
113
|
-
# expression /\s/
|
106
|
+
# - +:quotes+ (String, Array) A string that is used as the opening and closing quotes, or an array whose first two elements are used as the opening and closing quotes. Defaults to +'"'+
|
107
|
+
# - +:quotables+ (String, Array, Regexp) A string representing the quotable character, or an array containing the quotable characters, or a regular expression that determines by match whether the string should be quoted. Defaults to the regular expression +/\s/+
|
114
108
|
def self.quote_if s, **options
|
115
109
|
|
116
110
|
QuoteIf_Helper_.string_quote_if_array_ s, options
|
117
111
|
end
|
118
112
|
|
113
|
+
# Converts the instance to a quoted form if necessary
|
114
|
+
#
|
115
|
+
# See Xqsr3::StringUtilities::QuoteIf::quite_if() for options
|
119
116
|
def quote_if **options
|
120
117
|
|
121
118
|
QuoteIf_Helper_.string_quote_if_array_ self, options
|
@@ -6,13 +6,13 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 13th April 2016
|
9
|
-
# Updated:
|
9
|
+
# Updated: 12th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
13
13
|
# Author: Matthew Wilson
|
14
14
|
#
|
15
|
-
# Copyright (c) 2016, Matthew Wilson and Synesis Software
|
15
|
+
# Copyright (c) 2016-2019, 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
|
@@ -54,12 +54,14 @@
|
|
54
54
|
module Xqsr3
|
55
55
|
module StringUtilities
|
56
56
|
|
57
|
+
# +include+-able module that provides ::string_starts_with? and #starts_with?
|
58
|
+
# methods
|
57
59
|
module StartsWith
|
58
60
|
|
59
61
|
private
|
60
|
-
module StartsWith_Helper_
|
62
|
+
module StartsWith_Helper_ # :nodoc:
|
61
63
|
|
62
|
-
def self.string_starts_with_helper_ s, prefix
|
64
|
+
def self.string_starts_with_helper_ s, prefix # :nodoc:
|
63
65
|
|
64
66
|
if prefix.nil? || prefix.empty?
|
65
67
|
|
@@ -78,7 +80,7 @@ module StartsWith
|
|
78
80
|
nil
|
79
81
|
end
|
80
82
|
|
81
|
-
def self.string_starts_with_array_ s, args
|
83
|
+
def self.string_starts_with_array_ s, args # :nodoc:
|
82
84
|
|
83
85
|
return '' if args.empty?
|
84
86
|
|
@@ -109,11 +111,26 @@ module StartsWith
|
|
109
111
|
end
|
110
112
|
public
|
111
113
|
|
114
|
+
# Reports on whether a string +s+ starts with a given prefix or set of
|
115
|
+
# prefixes (+args+)
|
116
|
+
#
|
117
|
+
# === Signature
|
118
|
+
#
|
119
|
+
# * *Parameters:*
|
120
|
+
# - +s+ (String) The string to be evaluated
|
121
|
+
# - +args+ 0+ arguments against which +s+ will be evaluated
|
112
122
|
def self.string_starts_with? s, *args
|
113
123
|
|
114
124
|
StartsWith_Helper_.string_starts_with_array_ s, args
|
115
125
|
end
|
116
126
|
|
127
|
+
# Reports on whether the instance starts with a given prefix or set of
|
128
|
+
# prefixes (+args+)
|
129
|
+
#
|
130
|
+
# === Signature
|
131
|
+
#
|
132
|
+
# * *Parameters:*
|
133
|
+
# - +args+ 0+ arguments against which the instance will be evaluated
|
117
134
|
def starts_with? *args
|
118
135
|
|
119
136
|
StartsWith_Helper_.string_starts_with_array_ self, args
|
@@ -6,13 +6,13 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 14th April 2016
|
9
|
-
# Updated:
|
9
|
+
# Updated: 12th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
13
13
|
# Author: Matthew Wilson
|
14
14
|
#
|
15
|
-
# Copyright (c) 2016, Matthew Wilson and Synesis Software
|
15
|
+
# Copyright (c) 2016-2019, 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
|
@@ -59,15 +59,15 @@ module StringUtilities
|
|
59
59
|
module ToSymbol
|
60
60
|
|
61
61
|
private
|
62
|
-
module ToSymbol_Helper_
|
62
|
+
module ToSymbol_Helper_ # :nodoc:
|
63
63
|
|
64
|
-
module Constants
|
64
|
+
module Constants # :nodoc:
|
65
65
|
|
66
66
|
SymbolCharacters0 = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
67
67
|
SymbolCharactersN = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789'
|
68
68
|
end
|
69
69
|
|
70
|
-
def self.string_to_symbol_with_options_ s, options
|
70
|
+
def self.string_to_symbol_with_options_ s, options # :nodoc:
|
71
71
|
|
72
72
|
case s
|
73
73
|
when ::String
|
@@ -127,11 +127,29 @@ module ToSymbol
|
|
127
127
|
end
|
128
128
|
public
|
129
129
|
|
130
|
+
# Converts the given string +s+ to a symbol according to the given
|
131
|
+
# +options+
|
132
|
+
#
|
133
|
+
# === Signature
|
134
|
+
#
|
135
|
+
# * *Parameters:*
|
136
|
+
# - +s+ (String) The string to convert
|
137
|
+
# - +options+ (Hash) Options hash
|
138
|
+
#
|
139
|
+
# * *Options:*
|
140
|
+
# - +:reject_hyphens+ (boolean)
|
141
|
+
# - +:reject_spaces+ (boolean)
|
142
|
+
# - +:reject_tabs+ (boolean)
|
143
|
+
# - +:reject_whitespace+ (boolean)
|
144
|
+
# - +:transform_characters+ (boolean)
|
130
145
|
def self.string_to_symbol s, options = {}
|
131
146
|
|
132
147
|
ToSymbol_Helper_.string_to_symbol_with_options_ s, options
|
133
148
|
end
|
134
149
|
|
150
|
+
# Converts the instance to a symbol, according to the given +options+
|
151
|
+
#
|
152
|
+
# See Xqsr3::StringUtilities::ToSymbol::string_to_symbol for options
|
135
153
|
def to_symbol options = {}
|
136
154
|
|
137
155
|
ToSymbol_Helper_.string_to_symbol_with_options_ self, options
|
@@ -6,13 +6,13 @@
|
|
6
6
|
# module
|
7
7
|
#
|
8
8
|
# Created: 12th April 2018
|
9
|
-
# Updated: 12th April
|
9
|
+
# Updated: 12th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/xqsr3
|
12
12
|
#
|
13
13
|
# Author: Matthew Wilson
|
14
14
|
#
|
15
|
-
# Copyright (c) 2018, Matthew Wilson and Synesis Software
|
15
|
+
# Copyright (c) 2018-2019, 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
|
@@ -59,9 +59,9 @@ module StringUtilities
|
|
59
59
|
module Truncate
|
60
60
|
|
61
61
|
private
|
62
|
-
module Truncate_Helper_
|
62
|
+
module Truncate_Helper_ # :nodoc:
|
63
63
|
|
64
|
-
def self.string_truncate_with_options_ s, width, options
|
64
|
+
def self.string_truncate_with_options_ s, width, options # :nodoc:
|
65
65
|
|
66
66
|
case s
|
67
67
|
when ::String
|
@@ -102,11 +102,26 @@ module Truncate
|
|
102
102
|
end
|
103
103
|
public
|
104
104
|
|
105
|
+
# Truncates the given string +s+ to the given +width+ according to the
|
106
|
+
# given +options+
|
107
|
+
#
|
108
|
+
# === Signature
|
109
|
+
#
|
110
|
+
# * *Parameters:*
|
111
|
+
# - +s+ (String) The string to convert
|
112
|
+
# - +width+ (Integer) The truncation width
|
113
|
+
# - +options+ (Hash) Options hash
|
114
|
+
#
|
115
|
+
# * *Options:*
|
116
|
+
# - +:omission+ (String) Omission string. Defaults to "..."
|
105
117
|
def self.string_truncate s, width, options = {}
|
106
118
|
|
107
119
|
Truncate_Helper_.string_truncate_with_options_ s, width, options
|
108
120
|
end
|
109
121
|
|
122
|
+
# Truncates the instance, according to the given +width+ and +options+
|
123
|
+
#
|
124
|
+
# See Xqsr3::StringUtilities::ToSymbol::string_truncate for options
|
110
125
|
def truncate width, options = {}
|
111
126
|
|
112
127
|
Truncate_Helper_.string_truncate_with_options_ self, width, options
|
data/lib/xqsr3/version.rb
CHANGED