xqsr3 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +27 -0
  3. data/README.md +26 -0
  4. data/lib/xqsr3/command_line_utilities/map_option_string.rb +137 -0
  5. data/lib/xqsr3/containers/frequency_map.rb +473 -0
  6. data/lib/xqsr3/containers/multi_map.rb +383 -0
  7. data/lib/xqsr3/diagnostics/exception_utilities.rb +216 -0
  8. data/lib/xqsr3/doc_.rb +116 -0
  9. data/lib/xqsr3/extensions/enumerable.rb +4 -0
  10. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +71 -0
  11. data/lib/xqsr3/extensions/enumerable/unique.rb +102 -0
  12. data/lib/xqsr3/extensions/io.rb +3 -0
  13. data/lib/xqsr3/extensions/io/writelines.rb +66 -0
  14. data/lib/xqsr3/extensions/kernel.rb +3 -0
  15. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +68 -0
  16. data/lib/xqsr3/extensions/string.rb +5 -0
  17. data/lib/xqsr3/extensions/string/ends_with.rb +8 -0
  18. data/lib/xqsr3/extensions/string/map_option_string.rb +8 -0
  19. data/lib/xqsr3/extensions/string/starts_with.rb +8 -0
  20. data/lib/xqsr3/extensions/string/to_symbol.rb +8 -0
  21. data/lib/xqsr3/extensions/test/unit.rb +5 -0
  22. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +18 -0
  23. data/lib/xqsr3/extensions/test/unit/assert_not.rb +18 -0
  24. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +18 -0
  25. data/lib/xqsr3/io/writelines.rb +192 -0
  26. data/lib/xqsr3/quality/parameter_checking.rb +343 -0
  27. data/lib/xqsr3/string_utilities/ends_with.rb +134 -0
  28. data/lib/xqsr3/string_utilities/starts_with.rb +127 -0
  29. data/lib/xqsr3/string_utilities/to_symbol.rb +145 -0
  30. data/lib/xqsr3/version.rb +68 -0
  31. data/test/unit/command_line_utilities/tc_map_option_string.rb +39 -0
  32. data/test/unit/command_line_utilities/ts_all.rb +13 -0
  33. data/test/unit/containers/tc_frequency_map.rb +738 -0
  34. data/test/unit/containers/tc_multi_map.rb +640 -0
  35. data/test/unit/containers/ts_all.rb +13 -0
  36. data/test/unit/diagnostics/tc_exception_utilities.rb +221 -0
  37. data/test/unit/diagnostics/ts_all.rb +13 -0
  38. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +36 -0
  39. data/test/unit/extensions/enumerable/tc_unique.rb +47 -0
  40. data/test/unit/extensions/enumerable/ts_all.rb +13 -0
  41. data/test/unit/extensions/io/tc_writelines.rb +110 -0
  42. data/test/unit/extensions/io/ts_all.rb +13 -0
  43. data/test/unit/extensions/kernel/tc_raise_with_options.rb +239 -0
  44. data/test/unit/extensions/kernel/ts_all.rb +13 -0
  45. data/test/unit/extensions/string/tc_ends_with.rb +70 -0
  46. data/test/unit/extensions/string/tc_map_option_string.rb +37 -0
  47. data/test/unit/extensions/string/tc_starts_with.rb +70 -0
  48. data/test/unit/extensions/string/tc_to_symbol.rb +51 -0
  49. data/test/unit/extensions/string/ts_all.rb +13 -0
  50. data/test/unit/extensions/ts_all.rb +13 -0
  51. data/test/unit/io/tc_writelines.rb +200 -0
  52. data/test/unit/io/ts_all.rb +13 -0
  53. data/test/unit/quality/tc_parameter_checking.rb +181 -0
  54. data/test/unit/quality/ts_all.rb +13 -0
  55. data/test/unit/tc_version.rb +37 -0
  56. data/test/unit/ts_all.rb +13 -0
  57. metadata +101 -0
data/lib/xqsr3/doc_.rb ADDED
@@ -0,0 +1,116 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/doc_.rb
4
+ #
5
+ # Purpose: Documentation of the ::Xqsr3 modules
6
+ #
7
+ # Created: 10th June 2016
8
+ # Updated: 10th June 2016
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2016, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright notice,
22
+ # this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ =begin
48
+ =end
49
+
50
+ # Main module for Xqsr3 library
51
+ #
52
+ # === Subordinate modules of interest
53
+ # * ::Xqsr3::CommandLineUtilities
54
+ # * ::Xqsr3::Containers
55
+ # * ::Xqsr3::Diagnostics
56
+ # * ::Xqsr3::IO
57
+ # * ::Xqsr3::Quality
58
+ # * ::Xqsr3::StringUtilities
59
+ module Xqsr3
60
+
61
+ # Command-line Utilities
62
+ #
63
+ # === Subordinate modules of interest
64
+ # * ::Xqsr3::CommandLineUtilities::MapOptionString
65
+ module CommandLineUtilities
66
+
67
+ end # module CommandLineUtilities
68
+
69
+ # Containers
70
+ #
71
+ module Containers
72
+
73
+ end # module Containers
74
+
75
+ # Diagnostic facilities
76
+ #
77
+ # === Subordinate modules of interest
78
+ # * ::Xqsr3::Diagnostics::ExceptionUtilities
79
+ #
80
+ module Diagnostics
81
+
82
+ # Exception-related utilities
83
+ #
84
+ # === Components of interest
85
+ # * ::Xqsr3::Diagnostics::ExceptionUtilities::raise_with_options
86
+ #
87
+ module ExceptionUtilities
88
+ end # module ExceptionUtilities
89
+ end # module Diagnostics
90
+
91
+ # IO
92
+ #
93
+ module IO
94
+
95
+ end # module IO
96
+
97
+ # Quality
98
+ #
99
+ # === Subordinate modules of interest
100
+ # * ::Xqsr3::Quality::ParameterChecking
101
+ module Quality
102
+
103
+ end # module Quality
104
+
105
+ # String utilities
106
+ #
107
+ # === Subordinate modules of interest
108
+ # * ::Xqsr3::StringUtilities::ToSymbol
109
+ module StringUtilities
110
+
111
+ end # module StringUtilities
112
+
113
+ end # module Xqsr3
114
+
115
+ # ############################## end of file ############################# #
116
+
@@ -0,0 +1,4 @@
1
+
2
+ require 'xqsr3/extensions/enumerable/collect_with_index'
3
+ require 'xqsr3/extensions/enumerable/unique'
4
+
@@ -0,0 +1,71 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/extensions/enumerable/collect_with_index.rb
4
+ #
5
+ # Purpose: Adds a collect_with_index() method to the Enumerable module
6
+ #
7
+ # Created: 24th October 2010
8
+ # Updated: 4th April 2016
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2010-2016, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright notice,
22
+ # this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ # ##########################################################
48
+ # ::Enumerable
49
+
50
+ =begin
51
+ =end
52
+
53
+ module Enumerable
54
+
55
+ ## Two-parameter #collect, where the second parameter is a #base-based
56
+ # index, which increments by 1 for each enumerated element.
57
+ def collect_with_index(base = 0)
58
+
59
+ a = []
60
+
61
+ self.each_with_index do |element, index|
62
+
63
+ a.push yield(element, base + index)
64
+ end
65
+
66
+ a
67
+ end
68
+ end # module Enumerable
69
+
70
+ # ############################## end of file ############################# #
71
+
@@ -0,0 +1,102 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/extensions/enumerable/unique.rb
4
+ #
5
+ # Purpose: Adds a unique() method to the Enumerable module
6
+ #
7
+ # Created: 5th March 2007
8
+ # Updated: 4th April 2016
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2007-2016, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright notice,
22
+ # this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ # ##########################################################
48
+ # ::Enumerable
49
+
50
+ =begin
51
+ =end
52
+
53
+ module Enumerable
54
+
55
+ # Removes all duplicate elements in a sequence subject to an optional
56
+ # two-parameter block in order to return an array containing unique
57
+ # elements
58
+ def unique(&block)
59
+
60
+ if not block
61
+
62
+ return unique { |a, b| a == b }
63
+ else
64
+
65
+ if block.arity != 2
66
+
67
+ raise ArgumentError, "block requires two parameters"
68
+ end
69
+
70
+ ar = self.to_a
71
+
72
+ return ar if ar.length < 2
73
+
74
+ ar = ar.clone
75
+
76
+ i = 0
77
+
78
+ while i < ar.length do
79
+
80
+ j = i + 1
81
+
82
+ while j < ar.length do
83
+
84
+ if yield ar[i], ar[j]
85
+
86
+ ar.delete_at(j)
87
+ else
88
+
89
+ j = j + 1
90
+ end
91
+ end
92
+
93
+ i = i + 1
94
+ end
95
+
96
+ return ar
97
+ end
98
+ end
99
+ end # module Enumerable
100
+
101
+ # ############################## end of file ############################# #
102
+
@@ -0,0 +1,3 @@
1
+
2
+ require 'xqsr3/extensions/io/writelines'
3
+
@@ -0,0 +1,66 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/extensions/io/writelines.rb
4
+ #
5
+ # Purpose: Adds a writelines() method to the IO class
6
+ #
7
+ # Created: 13th April 2007
8
+ # Updated: 10th June 2016
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2007-2016, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright notice,
22
+ # this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ require 'xqsr3/io/writelines'
48
+
49
+ # ##########################################################
50
+ # ::IO
51
+
52
+ =begin
53
+ =end
54
+
55
+ class IO
56
+
57
+ # Extends +IO+ class with the ::Xqsr3::IO::write_lines
58
+ # method
59
+ def self.writelines(path, contents, lineSep = nil, columnSep = nil)
60
+
61
+ ::Xqsr3::IO.writelines path, contents, line_separator: lineSep, column_separator: columnSep, eol_lookahead_limit: 20
62
+ end
63
+ end # class IO
64
+
65
+ # ############################## end of file ############################# #
66
+
@@ -0,0 +1,3 @@
1
+
2
+ require 'xqsr3/extensions/kernel/raise_with_options'
3
+
@@ -0,0 +1,68 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/extensions/kernel/raise_with_options.rb
4
+ #
5
+ # Purpose: Adds a raise_with_options() method to the Kernel module
6
+ #
7
+ # Created: 12th February 2015
8
+ # Updated: 3rd April 2016
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2015-2016, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright
22
+ # notice, this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ require 'xqsr3/diagnostics/exception_utilities'
48
+
49
+ # ##########################################################
50
+ # ::Kernel
51
+
52
+ =begin
53
+ =end
54
+
55
+ module Kernel
56
+
57
+ # Extends +Kernel+ module with the ::Xqsr3::Diagnostics::ExceptionUtilities::raise_with_options
58
+ # method
59
+ def raise_with_options *args, **options
60
+
61
+ options ||= {}
62
+
63
+ ::Xqsr3::Diagnostics::ExceptionUtilities.raise_with_options *args, **(options.merge({ :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 => 1}))
64
+ end
65
+ end # module Kernel
66
+
67
+ # ############################## end of file ############################# #
68
+
@@ -0,0 +1,5 @@
1
+
2
+ require 'xqsr3/extensions/string/ends_with'
3
+ require 'xqsr3/extensions/string/starts_with'
4
+ require 'xqsr3/extensions/string/to_symbol'
5
+