xqsr3 0.32.3 → 0.37.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xqsr3/all_extensions.rb +6 -0
  3. data/lib/xqsr3/array_utilities.rb +10 -0
  4. data/lib/xqsr3/command_line_utilities.rb +10 -0
  5. data/lib/xqsr3/command_line_utilities/map_option_string.rb +3 -2
  6. data/lib/xqsr3/containers.rb +11 -0
  7. data/lib/xqsr3/containers/frequency_map.rb +18 -1
  8. data/lib/xqsr3/containers/multi_map.rb +290 -29
  9. data/lib/xqsr3/conversion.rb +11 -0
  10. data/lib/xqsr3/conversion/integer_parser.rb +3 -2
  11. data/lib/xqsr3/diagnostics.rb +11 -0
  12. data/lib/xqsr3/diagnostics/inspect_builder.rb +5 -1
  13. data/lib/xqsr3/extensions.rb +13 -0
  14. data/lib/xqsr3/extensions/array.rb +3 -0
  15. data/lib/xqsr3/extensions/hash.rb +6 -0
  16. data/lib/xqsr3/extensions/hash/except.rb +26 -0
  17. data/lib/xqsr3/extensions/hash/slice.rb +22 -0
  18. data/lib/xqsr3/extensions/io/writelines.rb +38 -6
  19. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +22 -2
  20. data/lib/xqsr3/hash_utilities.rb +11 -0
  21. data/lib/xqsr3/hash_utilities/key_matching.rb +6 -4
  22. data/lib/xqsr3/internal_/test_unit_version_.rb +26 -0
  23. data/lib/xqsr3/io/writelines.rb +49 -13
  24. data/lib/xqsr3/quality.rb +8 -1
  25. data/lib/xqsr3/quality/parameter_checking.rb +3 -2
  26. data/lib/xqsr3/string_utilities.rb +16 -0
  27. data/lib/xqsr3/string_utilities/ends_with.rb +3 -2
  28. data/lib/xqsr3/string_utilities/nil_if_empty.rb +3 -2
  29. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +3 -2
  30. data/lib/xqsr3/string_utilities/quote_if.rb +7 -2
  31. data/lib/xqsr3/string_utilities/starts_with.rb +3 -2
  32. data/lib/xqsr3/string_utilities/to_symbol.rb +3 -2
  33. data/lib/xqsr3/string_utilities/truncate.rb +3 -2
  34. data/lib/xqsr3/version.rb +3 -2
  35. data/test/unit/containers/tc_multi_map.rb +174 -16
  36. data/test/unit/diagnostics/tc_exception_utilities.rb +7 -3
  37. data/test/unit/extensions/hash/tc_deep_transform.rb +0 -1
  38. data/test/unit/extensions/hash/tc_except.rb +67 -0
  39. data/test/unit/extensions/hash/tc_hash.rb +6 -0
  40. data/test/unit/extensions/hash/tc_slice.rb +31 -0
  41. data/test/unit/extensions/io/tc_writelines.rb +36 -0
  42. data/test/unit/extensions/kernel/tc_raise_with_options.rb +6 -3
  43. data/test/unit/tc_version.rb +1 -1
  44. metadata +22 -7
@@ -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
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
+
5
+ require 'xqsr3/extensions/hash'
6
+
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
+
5
+ require 'xqsr3/extensions/hash/slice'
6
+
7
+ class Test_Hash_slice < Test::Unit::TestCase
8
+
9
+ def test_empty
10
+
11
+ assert_equal ({}), ({}.slice())
12
+
13
+ assert_equal ({}), ({}.slice(:abc, 'def'))
14
+ end
15
+
16
+ def test_none_matching
17
+
18
+ assert_equal ({}), ({ abc: 'abc', 'def' => :def }.slice())
19
+ end
20
+
21
+ def test_all_matching
22
+
23
+ assert_equal ({ abc: 'abc', 'def' => :def }), ({ abc: 'abc', 'def' => :def }.slice(:abc, 'def'))
24
+ end
25
+
26
+ def test_some_matching
27
+
28
+ assert_equal ({ abc: 'abc' }), ({ abc: 'abc', 'def' => :def }.slice(:abc, 'ghi'))
29
+ end
30
+ end
31
+
@@ -22,6 +22,18 @@ class Test_IO_writelines < Test::Unit::TestCase
22
22
  assert_equal "abc\n", s.string
23
23
  end
24
24
 
25
+ def test_single_string_nolasteol
26
+
27
+ input = 'abc'
28
+
29
+ s = StringIO.new '', 'a'
30
+
31
+ r = ::IO.writelines s, input, no_last_eol: true
32
+
33
+ assert_equal 1, r
34
+ assert_equal "abc", s.string
35
+ end
36
+
25
37
  def test_single_string_in_array
26
38
 
27
39
  input = [ 'abc' ]
@@ -46,6 +58,18 @@ class Test_IO_writelines < Test::Unit::TestCase
46
58
  assert_equal "abc\n", s.string
47
59
  end
48
60
 
61
+ def test_single_string_in_hash_nolasteol
62
+
63
+ input = { 'abc' => '' }
64
+
65
+ s = StringIO.new '', 'a'
66
+
67
+ r = ::IO.writelines s, input, no_last_eol: true
68
+
69
+ assert_equal 1, r
70
+ assert_equal "abc", s.string
71
+ end
72
+
49
73
  def test_two_strings_in_array
50
74
 
51
75
  input = [ 'abc', 'def' ]
@@ -82,6 +106,18 @@ class Test_IO_writelines < Test::Unit::TestCase
82
106
  assert_equal "abc\ndef\n", s.string
83
107
  end
84
108
 
109
+ def test_two_strings_in_hash_nolasteol
110
+
111
+ input = { 'ab' => 'c', 'de' => 'f' }
112
+
113
+ s = StringIO.new '', 'a'
114
+
115
+ r = ::IO.writelines s, input, no_last_eol: true
116
+
117
+ assert_equal 2, r
118
+ assert_equal "abc\ndef", s.string
119
+ end
120
+
85
121
  def test_ten_strings_in_array
86
122
 
87
123
  input = (0...10).map { |i| i.to_s }
@@ -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.32.3
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: 2019-04-12 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
@@ -23,16 +23,24 @@ files:
23
23
  - README.md
24
24
  - examples/count_word_frequencies.md
25
25
  - examples/count_word_frequencies.rb
26
+ - lib/xqsr3/all_extensions.rb
27
+ - lib/xqsr3/array_utilities.rb
26
28
  - lib/xqsr3/array_utilities/join_with_or.rb
29
+ - lib/xqsr3/command_line_utilities.rb
27
30
  - lib/xqsr3/command_line_utilities/map_option_string.rb
31
+ - lib/xqsr3/containers.rb
28
32
  - lib/xqsr3/containers/frequency_map.rb
29
33
  - lib/xqsr3/containers/multi_map.rb
34
+ - lib/xqsr3/conversion.rb
30
35
  - lib/xqsr3/conversion/bool_parser.rb
31
36
  - lib/xqsr3/conversion/integer_parser.rb
37
+ - lib/xqsr3/diagnostics.rb
32
38
  - lib/xqsr3/diagnostics/exception_utilities.rb
33
39
  - lib/xqsr3/diagnostics/exceptions/with_cause.rb
34
40
  - lib/xqsr3/diagnostics/inspect_builder.rb
35
41
  - lib/xqsr3/doc_.rb
42
+ - lib/xqsr3/extensions.rb
43
+ - lib/xqsr3/extensions/array.rb
36
44
  - lib/xqsr3/extensions/array/join_with_or.rb
37
45
  - lib/xqsr3/extensions/enumerable.rb
38
46
  - lib/xqsr3/extensions/enumerable/collect_with_index.rb
@@ -40,8 +48,10 @@ files:
40
48
  - lib/xqsr3/extensions/enumerable/unique.rb
41
49
  - lib/xqsr3/extensions/hash.rb
42
50
  - lib/xqsr3/extensions/hash/deep_transform.rb
51
+ - lib/xqsr3/extensions/hash/except.rb
43
52
  - lib/xqsr3/extensions/hash/has_match.rb
44
53
  - lib/xqsr3/extensions/hash/match.rb
54
+ - lib/xqsr3/extensions/hash/slice.rb
45
55
  - lib/xqsr3/extensions/io.rb
46
56
  - lib/xqsr3/extensions/io/writelines.rb
47
57
  - lib/xqsr3/extensions/kernel.rb
@@ -67,12 +77,14 @@ files:
67
77
  - lib/xqsr3/extensions/test/unit/assert_superclass_of.rb
68
78
  - lib/xqsr3/extensions/test/unit/assert_true.rb
69
79
  - lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb
80
+ - lib/xqsr3/hash_utilities.rb
70
81
  - lib/xqsr3/hash_utilities/deep_transform.rb
71
82
  - lib/xqsr3/hash_utilities/key_matching.rb
72
83
  - lib/xqsr3/internal_/test_unit_version_.rb
73
84
  - lib/xqsr3/io/writelines.rb
74
85
  - lib/xqsr3/quality.rb
75
86
  - lib/xqsr3/quality/parameter_checking.rb
87
+ - lib/xqsr3/string_utilities.rb
76
88
  - lib/xqsr3/string_utilities/ends_with.rb
77
89
  - lib/xqsr3/string_utilities/nil_if_empty.rb
78
90
  - lib/xqsr3/string_utilities/nil_if_whitespace.rb
@@ -102,6 +114,9 @@ files:
102
114
  - test/unit/extensions/enumerable/tc_unique.rb
103
115
  - test/unit/extensions/enumerable/ts_all.rb
104
116
  - test/unit/extensions/hash/tc_deep_transform.rb
117
+ - test/unit/extensions/hash/tc_except.rb
118
+ - test/unit/extensions/hash/tc_hash.rb
119
+ - test/unit/extensions/hash/tc_slice.rb
105
120
  - test/unit/extensions/hash/ts_all.rb
106
121
  - test/unit/extensions/io/tc_writelines.rb
107
122
  - test/unit/extensions/io/ts_all.rb
@@ -141,7 +156,7 @@ homepage: http://github.com/synesissoftware/xqsr3
141
156
  licenses:
142
157
  - BSD-3-Clause
143
158
  metadata: {}
144
- post_install_message:
159
+ post_install_message:
145
160
  rdoc_options: []
146
161
  require_paths:
147
162
  - lib
@@ -156,9 +171,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
171
  - !ruby/object:Gem::Version
157
172
  version: '0'
158
173
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.2.5
161
- signing_key:
174
+ rubyforge_project:
175
+ rubygems_version: 2.6.14.3
176
+ signing_key:
162
177
  specification_version: 4
163
178
  summary: xqsr3
164
179
  test_files: []