xqsr3 0.36.0 → 0.37.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 4e3f5e422b5b6d6f88ee0c0eb620f38ce468ef54e1cf9d55ab41f24e909c897b
4
- data.tar.gz: 80f3675582a96f52a108687c4a77911691972dd0a2167138ffa0c9992c13e3ed
2
+ SHA1:
3
+ metadata.gz: '048dfbb7beeff5b7e90df73f59be96e686611f91'
4
+ data.tar.gz: 815facf131a846b49eec30be5e45bf369383d52d
5
5
  SHA512:
6
- metadata.gz: 41b2ac34f613f74b684223073ff61c3350b8433bda18520bb0af25db2464a22ed1be8fe53859eaf37f60d366d7053d8cab77d653b45b33a57ebd1a619b6186c6
7
- data.tar.gz: 28d271b3501677420540ec6a55b1bf69bedf398dc422362ff7ca5e50e1d827d4f4fccc45c73eece170949bab755a47472d78f207a0b7c992cb942b13d368be76
6
+ metadata.gz: e77733d055c75114bcd38811e5af5f89726c563976d49b8d197246309ac6a2c92ade6cf66e812f81a02b17f682f530b870441fc9f8436b499179dee2165d539c
7
+ data.tar.gz: 38743b47b07c1b1876d680a759e6c9ec3e9aac7ef6482305a2dbe452fa5d1f28e0bb3b5921653778feb94b76a8f884f90eb03dbae7bad9dd6d5815fad9902308
@@ -1,5 +1,6 @@
1
1
 
2
2
  require 'xqsr3/extensions/hash/deep_transform'
3
+ require 'xqsr3/extensions/hash/except'
3
4
  require 'xqsr3/extensions/hash/has_match'
4
5
  require 'xqsr3/extensions/hash/match'
5
6
 
@@ -0,0 +1,26 @@
1
+
2
+ unless Hash.instance_methods.include? :except
3
+
4
+ class Hash
5
+
6
+ # Removes from the instance any key-value pairs matching the
7
+ # keys specified in +keys_to_delete+
8
+ def except!(*keys_to_delete)
9
+
10
+ keys_to_delete.each do |key|
11
+
12
+ self.delete key
13
+ end
14
+
15
+ self
16
+ end
17
+
18
+ # Obtains a copy of the instance wherein any key-value pairs
19
+ # matching the keys specified in +keys_to_delete+ are removed
20
+ def except(*keys_to_delete)
21
+
22
+ self.dup.except!(*keys_to_delete)
23
+ end
24
+ end
25
+ end
26
+
@@ -11,9 +11,11 @@ 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
14
15
  AssertionFailedError_ = Test::Unit::AssertionFailedError # :nodoc:
15
16
  else
16
17
 
18
+ # @!visibility private
17
19
  class AssertionFailedError_ < ArgumentError; end # :nodoc:
18
20
  end
19
21
 
@@ -63,6 +63,8 @@ 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
+
66
68
  s = s.to_s unless String === s
67
69
 
68
70
  quotes = options[:quotes] || [ '"', '"' ]
@@ -70,6 +72,8 @@ module QuoteIf
70
72
 
71
73
  quotables = options[:quotables] || /\s/
72
74
 
75
+ #$stderr.puts "quotables (#{quotables.class}): [#{quotables}]"
76
+
73
77
  case quotables
74
78
  when ::String
75
79
 
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: 26th May 2020
8
+ # Updated: 20th April 2021
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2020, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2021, 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.36.0'
54
+ VERSION = '0.37.0'
55
55
 
56
56
  private
57
57
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -10,6 +10,9 @@ class Test_ExceptionUtilities_raise_with_options < Test::Unit::TestCase
10
10
 
11
11
  include ::Xqsr3::Diagnostics
12
12
 
13
+ OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i) ? true : false
14
+ LINE_NUM_RE = OS_IS_WINDOWS ? /.+:(\d+):/ : /^[^:]+:(\d+)/
15
+
13
16
  class ArgumentErrorWithOptions < ArgumentError
14
17
  def initialize(message = nil, **options)
15
18
  super(message)
@@ -25,7 +28,7 @@ class Test_ExceptionUtilities_raise_with_options < Test::Unit::TestCase
25
28
 
26
29
  msg ||= self.message
27
30
  options ||= {}
28
- r = self.class.new msg, self.options.merge(options)
31
+ r = self.class.new msg, **self.options.merge(options)
29
32
  r
30
33
  end
31
34
  end
@@ -192,7 +195,8 @@ class Test_ExceptionUtilities_raise_with_options < Test::Unit::TestCase
192
195
  assert_kind_of(ArgumentError, x)
193
196
  assert_equal "abc", x.message
194
197
 
195
- assert $@[0] =~ /^[^:]+:(\d+)/
198
+
199
+ assert $@[0] =~ LINE_NUM_RE
196
200
  assert_equal line_number.to_s, $1.to_s
197
201
  end
198
202
 
@@ -213,7 +217,7 @@ class Test_ExceptionUtilities_raise_with_options < Test::Unit::TestCase
213
217
  assert_equal "abc", x.message
214
218
  assert_equal ({ :blah => :blech, :id => 23 }), x.options
215
219
 
216
- assert $@[0] =~ /^[^:]+:(\d+)/
220
+ assert $@[0] =~ LINE_NUM_RE
217
221
  assert_equal line_number.to_s, $1.to_s
218
222
  end
219
223
  end
@@ -46,4 +46,3 @@ class Test_Hash_deep_transform < Test::Unit::TestCase
46
46
  end
47
47
 
48
48
 
49
-
@@ -0,0 +1,67 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
+
5
+ require 'xqsr3/extensions/hash/except'
6
+
7
+ require 'xqsr3/extensions/test/unit'
8
+ require 'test/unit'
9
+
10
+ require 'stringio'
11
+
12
+ class Test_Hash_except < Test::Unit::TestCase
13
+
14
+ def test_no_pairs_empty_keys
15
+
16
+ h = {}
17
+
18
+ assert_equal h, h.except([])
19
+
20
+ i = {}
21
+
22
+ i.except! *[]
23
+
24
+ assert_equal h, i
25
+ end
26
+
27
+ def test_no_pairs_some_keys
28
+
29
+ h = {}
30
+
31
+ assert_equal h, h.except('a', :b)
32
+
33
+ i = {}
34
+
35
+ i.except! 'a', :b
36
+
37
+ assert_equal h, i
38
+ end
39
+
40
+ def test_no_pairs_some_non_matching_keys
41
+
42
+ h = { a: 'a', 'b' => :b }
43
+
44
+ assert_equal h, h.except('a', :b)
45
+
46
+ i = h.dup
47
+
48
+ i.except! 'a', :b
49
+
50
+ assert_equal h, i
51
+ end
52
+
53
+ def test_no_pairs_some_matching_keys
54
+
55
+ h = { a: 'a', 'b' => :b }
56
+
57
+ assert_equal ({ 'b' => :b }), h.except(:a, :b, :c)
58
+
59
+ i = h.dup
60
+
61
+ i.except! :a, :b, :c
62
+
63
+ assert_equal ({ 'b' => :b }), i
64
+ end
65
+ end
66
+
67
+
@@ -8,6 +8,9 @@ require 'test/unit'
8
8
 
9
9
  class Test_X_Kernel_raise_with_options < Test::Unit::TestCase
10
10
 
11
+ OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i) ? true : false
12
+ LINE_NUM_RE = OS_IS_WINDOWS ? /.+:(\d+):/ : /^[^:]+:(\d+)/
13
+
11
14
  class ArgumentErrorWithOptions < ArgumentError
12
15
 
13
16
  def initialize(message = nil, **options)
@@ -25,7 +28,7 @@ class Test_X_Kernel_raise_with_options < Test::Unit::TestCase
25
28
 
26
29
  msg ||= self.message
27
30
  options ||= {}
28
- r = self.class.new msg, self.options.merge(options)
31
+ r = self.class.new msg, **self.options.merge(options)
29
32
  r
30
33
  end
31
34
  end
@@ -207,7 +210,7 @@ class Test_X_Kernel_raise_with_options < Test::Unit::TestCase
207
210
  assert_kind_of(ArgumentError, x)
208
211
  assert_equal "abc", x.message
209
212
 
210
- assert $@[0] =~ /^[^:]+:(\d+)/
213
+ assert $@[0] =~ LINE_NUM_RE
211
214
  assert_equal line_number.to_s, $1.to_s
212
215
  end
213
216
 
@@ -231,7 +234,7 @@ class Test_X_Kernel_raise_with_options < Test::Unit::TestCase
231
234
  assert_equal "abc", x.message
232
235
  assert_equal ({ :blah => :blech, :id => 23 }), x.options
233
236
 
234
- assert $@[0] =~ /^[^:]+:(\d+)/
237
+ assert $@[0] =~ LINE_NUM_RE
235
238
  assert_equal line_number.to_s, $1.to_s
236
239
  end
237
240
  end
@@ -30,7 +30,7 @@ class Test_version < Test::Unit::TestCase
30
30
 
31
31
  def test_VERSION_has_consistent_format
32
32
 
33
- assert_equal Xqsr3::VERSION, "#{Xqsr3::VERSION_MAJOR}.#{Xqsr3::VERSION_MINOR}.#{Xqsr3::VERSION_REVISION}"
33
+ assert_equal Xqsr3::VERSION.split('.')[0..2].join('.'), "#{Xqsr3::VERSION_MAJOR}.#{Xqsr3::VERSION_MINOR}.#{Xqsr3::VERSION_REVISION}"
34
34
  end
35
35
  end
36
36
 
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.36.0
4
+ version: 0.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-26 00:00:00.000000000 Z
11
+ date: 2021-04-20 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
@@ -48,6 +48,7 @@ files:
48
48
  - lib/xqsr3/extensions/enumerable/unique.rb
49
49
  - lib/xqsr3/extensions/hash.rb
50
50
  - lib/xqsr3/extensions/hash/deep_transform.rb
51
+ - lib/xqsr3/extensions/hash/except.rb
51
52
  - lib/xqsr3/extensions/hash/has_match.rb
52
53
  - lib/xqsr3/extensions/hash/match.rb
53
54
  - lib/xqsr3/extensions/hash/slice.rb
@@ -113,6 +114,7 @@ files:
113
114
  - test/unit/extensions/enumerable/tc_unique.rb
114
115
  - test/unit/extensions/enumerable/ts_all.rb
115
116
  - test/unit/extensions/hash/tc_deep_transform.rb
117
+ - test/unit/extensions/hash/tc_except.rb
116
118
  - test/unit/extensions/hash/tc_hash.rb
117
119
  - test/unit/extensions/hash/tc_slice.rb
118
120
  - test/unit/extensions/hash/ts_all.rb
@@ -154,7 +156,7 @@ homepage: http://github.com/synesissoftware/xqsr3
154
156
  licenses:
155
157
  - BSD-3-Clause
156
158
  metadata: {}
157
- post_install_message:
159
+ post_install_message:
158
160
  rdoc_options: []
159
161
  require_paths:
160
162
  - lib
@@ -169,9 +171,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
171
  - !ruby/object:Gem::Version
170
172
  version: '0'
171
173
  requirements: []
172
- rubyforge_project:
173
- rubygems_version: 2.7.6
174
- signing_key:
174
+ rubyforge_project:
175
+ rubygems_version: 2.6.14.3
176
+ signing_key:
175
177
  specification_version: 4
176
178
  summary: xqsr3
177
179
  test_files: []