xqsr3 0.34.0 → 0.36.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: '08b7e3524dc96db46918345f810db795701f4a10'
4
- data.tar.gz: 05baa4102344c3fc236af32c03a596e592f6537d
2
+ SHA256:
3
+ metadata.gz: 4e3f5e422b5b6d6f88ee0c0eb620f38ce468ef54e1cf9d55ab41f24e909c897b
4
+ data.tar.gz: 80f3675582a96f52a108687c4a77911691972dd0a2167138ffa0c9992c13e3ed
5
5
  SHA512:
6
- metadata.gz: a4be49e79a61c9e44f12de294a1553f1cadc1e089bcda0b8defd567752716cface3e7b25e9a3699b584f305d94e9a5e6b848369a3fb10f6256b7c74f580ecbe0
7
- data.tar.gz: cf295f1ea20af9bff3ebe1a2e457c4ac2dd4b440dc0a84f9310e5c3980e4994b65ddb17edf533a646cdf7ae18a23fe9ed493fc600e26d833f01cca3d732209a8
6
+ metadata.gz: 41b2ac34f613f74b684223073ff61c3350b8433bda18520bb0af25db2464a22ed1be8fe53859eaf37f60d366d7053d8cab77d653b45b33a57ebd1a619b6186c6
7
+ data.tar.gz: 28d271b3501677420540ec6a55b1bf69bedf398dc422362ff7ca5e50e1d827d4f4fccc45c73eece170949bab755a47472d78f207a0b7c992cb942b13d368be76
@@ -0,0 +1,6 @@
1
+
2
+ require File.join(File.dirname(__FILE__), 'extensions')
3
+
4
+ require File.join(File.dirname(__FILE__), 'extensions', 'test', 'unit')
5
+
6
+
@@ -0,0 +1,10 @@
1
+
2
+ %w{
3
+
4
+ join_with_or
5
+ }.each do |name|
6
+
7
+ require File.join(File.dirname(__FILE__), 'array_utilities', name)
8
+ end
9
+
10
+
@@ -0,0 +1,10 @@
1
+
2
+ %w{
3
+
4
+ map_option_string
5
+ }.each do |name|
6
+
7
+ require File.join(File.dirname(__FILE__), 'command_line_utilities', name)
8
+ end
9
+
10
+
@@ -0,0 +1,11 @@
1
+
2
+ %w{
3
+
4
+ frequency_map
5
+ multi_map
6
+ }.each do |name|
7
+
8
+ require File.join(File.dirname(__FILE__), 'containers', name)
9
+ end
10
+
11
+
@@ -0,0 +1,11 @@
1
+
2
+ %w{
3
+
4
+ bool_parser
5
+ integer_parser
6
+ }.each do |name|
7
+
8
+ require File.join(File.dirname(__FILE__), 'conversion', name)
9
+ end
10
+
11
+
@@ -0,0 +1,11 @@
1
+
2
+ %w{
3
+
4
+ exception_utilities
5
+ inspect_builder
6
+ }.each do |name|
7
+
8
+ require File.join(File.dirname(__FILE__), 'diagnostics', name)
9
+ end
10
+
11
+
@@ -0,0 +1,13 @@
1
+
2
+ %w{
3
+
4
+ array
5
+ enumerable
6
+ hash
7
+ io
8
+ }.each do |name|
9
+
10
+ require File.join(File.dirname(__FILE__), 'extensions', name)
11
+ end
12
+
13
+
@@ -0,0 +1,3 @@
1
+
2
+ require 'xqsr3/extensions/array/join_with_or'
3
+
@@ -5,13 +5,13 @@
5
5
  # Purpose: Adds a writelines() method to the IO class
6
6
  #
7
7
  # Created: 13th April 2007
8
- # Updated: 10th June 2016
8
+ # Updated: 31st October 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2007-2016, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2007-2019, Matthew Wilson and Synesis Software
15
15
  # All rights reserved.
16
16
  #
17
17
  # Redistribution and use in source and binary forms, with or without
@@ -54,13 +54,45 @@ require 'xqsr3/io/writelines'
54
54
 
55
55
  class IO
56
56
 
57
- # Extends +IO+ class with the ::Xqsr3::IO::write_lines
58
- # method
59
- def self.writelines(path, contents, lineSep = nil, columnSep = nil)
57
+ # Extends +IO+ class with the +::Xqsr3::IO::write_lines+ method
58
+ #
59
+ #
60
+ #def self.writelines(path, contents, lineSep = nil, columnSep = nil)
61
+ def self.writelines(path, contents, *args)
60
62
 
61
- ::Xqsr3::IO.writelines path, contents, line_separator: lineSep, column_separator: columnSep, eol_lookahead_limit: 20
63
+ options = {}
64
+
65
+ case args.size
66
+ when 0
67
+
68
+ ;
69
+ when 1
70
+
71
+ arg3 = args[0]
72
+
73
+ if arg3.respond_to?(:to_hash)
74
+
75
+ options.merge! arg3.to_hash
76
+ else
77
+
78
+ options[:line_separator] = arg3
79
+ end
80
+ when 2
81
+
82
+ arg3 = args[0]
83
+ arg4 = args[1]
84
+
85
+ options[:line_separator] = arg2
86
+ options[:column_separator] = arg2
87
+ else
88
+
89
+ raise ArgumentError, "wrong number of arguments (given #{2 + args.size}, expected 2..4)"
90
+ end
91
+
92
+ ::Xqsr3::IO.writelines path, contents, **options
62
93
  end
63
94
  end # class IO
64
95
 
65
96
  # ############################## end of file ############################# #
66
97
 
98
+
@@ -11,11 +11,9 @@ 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
15
14
  AssertionFailedError_ = Test::Unit::AssertionFailedError # :nodoc:
16
15
  else
17
16
 
18
- # @!visibility private
19
17
  class AssertionFailedError_ < ArgumentError; end # :nodoc:
20
18
  end
21
19
 
@@ -0,0 +1,11 @@
1
+
2
+ %w{
3
+
4
+ deep_transform
5
+ key_matching
6
+ }.each do |name|
7
+
8
+ require File.join(File.dirname(__FILE__), 'hash_utilities', name)
9
+ end
10
+
11
+
@@ -5,7 +5,7 @@
5
5
  # Purpose: Adds a writelines() method to the IO module
6
6
  #
7
7
  # Created: 13th April 2007
8
- # Updated: 16th April 2019
8
+ # Updated: 31st October 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
@@ -60,26 +60,54 @@ module IO
60
60
  module WriteLine_Constants_ #:nodoc: all
61
61
 
62
62
  NUMBER_OF_LINES_TO_EXAMINE = 20
63
-
64
63
  end # module WriteLine_Constants_
65
64
 
66
65
  private
67
66
 
68
67
  # @!visibility private
69
- def self.write_to_target_ target, contents, line_separator, column_separator # :nodoc:
68
+ def self.write_to_target_ target, contents, line_separator, column_separator, no_last_eol # :nodoc:
70
69
 
71
- $stderr.puts "#{self.class}.write_to_target_(target(#{target.class})='#{target}', contents(#{contents.class})='#{contents}', line_separator(#{line_separator.class})='#{line_separator}', column_separator=(#{column_separator.class})='#{column_separator}')" if $DEBUG
72
- if contents.instance_of? ::Hash
70
+ $stderr.puts "#{self.class}.write_to_target_(target(#{target.class})='#{target}', contents(#{contents.class})='#{contents}', line_separator(#{line_separator.class})='#{line_separator}', column_separator(#{column_separator.class})='#{column_separator}', no_last_eol(#{no_last_eol.class})=#{no_last_eol})" if $DEBUG
71
+
72
+ if no_last_eol
73
+
74
+ first = true
75
+
76
+ if contents.instance_of? ::Hash
77
+
78
+ contents.each do |k, v|
79
+
80
+ target << line_separator unless first
81
+
82
+ target << "#{k}#{column_separator}#{v}"
83
+
84
+ first = false
85
+ end
86
+ else
87
+
88
+ contents.each do |element|
89
+
90
+ target << line_separator unless first
73
91
 
74
- contents.each do |k, v|
92
+ target << "#{element}"
75
93
 
76
- target << "#{k}#{column_separator}#{v}#{line_separator}"
94
+ first = false
95
+ end
77
96
  end
78
97
  else
79
98
 
80
- contents.each do |element|
99
+ if contents.instance_of? ::Hash
100
+
101
+ contents.each do |k, v|
81
102
 
82
- target << "#{element}#{line_separator}"
103
+ target << "#{k}#{column_separator}#{v}#{line_separator}"
104
+ end
105
+ else
106
+
107
+ contents.each do |element|
108
+
109
+ target << "#{element}#{line_separator}"
110
+ end
83
111
  end
84
112
  end
85
113
 
@@ -139,6 +167,7 @@ $stderr.puts "#{self.class}.write_to_target_(target(#{target.class})='#{target}'
139
167
  # - +:column_separator+ {optional} The column separator, to be applied between each field in the case where +contents+ is a +Hash+.
140
168
  # - +:eol_lookahead_limit+ {optional} The number of content elements (line/pair) to inspect to determine whether element has a terminating end-of-line sequence. Defaults to 20. If 0, and +:line_separator+ is not specified, then will default to <tt>"\n"</tt>. If +nil+, then every line will be inspected.
141
169
  # - +:line_separator+ {optional} The line separator, to be applied to the end of line created from each entry. When not specified, it will be deduced by inspecting +contents+ (according to +eol_lookahead_limit+).
170
+ # - +:no_last_eol+ {optional} If present and _truey_, causes suppression of the addition of the +:line_separator+ on the last line.
142
171
  #
143
172
  # === Return
144
173
  #
@@ -170,6 +199,7 @@ $stderr.puts "#{self.class}.write_to_target_(target(#{target.class})='#{target}'
170
199
  options ||= {}
171
200
  eol_lookahead_limit = options[:eol_lookahead_limit] || WriteLine_Constants_::NUMBER_OF_LINES_TO_EXAMINE
172
201
  column_separator = options[:column_separator] || ''
202
+ no_last_eol = options[:no_last_eol] || false
173
203
  line_separator = nil
174
204
  line_separator ||= options[:line_separator]
175
205
  line_separator ||= self.deduce_line_separator_(contents, eol_lookahead_limit) unless !eol_lookahead_limit.kind_of?(::Integer) || 0 == eol_lookahead_limit
@@ -186,11 +216,11 @@ $stderr.puts "#{self.class}.write_to_target_(target(#{target.class})='#{target}'
186
216
 
187
217
  File.open(target, "w") do |io|
188
218
 
189
- self.write_to_target_ io, contents, line_separator, column_separator
219
+ self.write_to_target_ io, contents, line_separator, column_separator, no_last_eol
190
220
  end
191
221
  else
192
222
 
193
- self.write_to_target_ target, contents, line_separator, column_separator
223
+ self.write_to_target_ target, contents, line_separator, column_separator, no_last_eol
194
224
  end
195
225
  end # writelines
196
226
  end # module IO
@@ -1,3 +1,10 @@
1
1
 
2
- require 'xqsr3/quality/parameter_checking'
2
+ %w{
3
+
4
+ parameter_checking
5
+ }.each do |name|
6
+
7
+ require File.join(File.dirname(__FILE__), 'quality', name)
8
+ end
9
+
3
10
 
@@ -0,0 +1,16 @@
1
+
2
+ %w{
3
+
4
+ ends_with
5
+ nil_if_empty
6
+ nil_if_whitespace
7
+ quote_if
8
+ starts_with
9
+ to_symbol
10
+ truncate
11
+ }.each do |name|
12
+
13
+ require File.join(File.dirname(__FILE__), 'string_utilities', name)
14
+ end
15
+
16
+
@@ -5,12 +5,13 @@
5
5
  # Purpose: Version for Xqsr3 library
6
6
  #
7
7
  # Created: 3rd April 2016
8
- # Updated: 4th July 2019
8
+ # Updated: 26th May 2020
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
15
  # Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -50,7 +51,7 @@
50
51
  module Xqsr3
51
52
 
52
53
  # Current version of the Xqsr3 library
53
- VERSION = '0.34.0'
54
+ VERSION = '0.36.0'
54
55
 
55
56
  private
56
57
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -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 }
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.34.0
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
11
+ date: 2020-05-26 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
@@ -68,12 +76,14 @@ files:
68
76
  - lib/xqsr3/extensions/test/unit/assert_superclass_of.rb
69
77
  - lib/xqsr3/extensions/test/unit/assert_true.rb
70
78
  - lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb
79
+ - lib/xqsr3/hash_utilities.rb
71
80
  - lib/xqsr3/hash_utilities/deep_transform.rb
72
81
  - lib/xqsr3/hash_utilities/key_matching.rb
73
82
  - lib/xqsr3/internal_/test_unit_version_.rb
74
83
  - lib/xqsr3/io/writelines.rb
75
84
  - lib/xqsr3/quality.rb
76
85
  - lib/xqsr3/quality/parameter_checking.rb
86
+ - lib/xqsr3/string_utilities.rb
77
87
  - lib/xqsr3/string_utilities/ends_with.rb
78
88
  - lib/xqsr3/string_utilities/nil_if_empty.rb
79
89
  - lib/xqsr3/string_utilities/nil_if_whitespace.rb
@@ -160,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
170
  version: '0'
161
171
  requirements: []
162
172
  rubyforge_project:
163
- rubygems_version: 2.6.11
173
+ rubygems_version: 2.7.6
164
174
  signing_key:
165
175
  specification_version: 4
166
176
  summary: xqsr3