xqsr3 0.38.1.1 → 0.39.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -6
  3. data/examples/count_word_frequencies.md +13 -13
  4. data/examples/count_word_frequencies.rb +5 -5
  5. data/lib/xqsr3/array_utilities/join_with_or.rb +53 -54
  6. data/lib/xqsr3/array_utilities.rb +2 -2
  7. data/lib/xqsr3/command_line_utilities/map_option_string.rb +66 -67
  8. data/lib/xqsr3/command_line_utilities.rb +2 -2
  9. data/lib/xqsr3/containers/frequency_map.rb +405 -404
  10. data/lib/xqsr3/containers/multi_map.rb +454 -453
  11. data/lib/xqsr3/containers.rb +3 -3
  12. data/lib/xqsr3/conversion/bool_parser.rb +56 -57
  13. data/lib/xqsr3/conversion/integer_parser.rb +92 -93
  14. data/lib/xqsr3/conversion.rb +3 -3
  15. data/lib/xqsr3/diagnostics/exception_utilities.rb +152 -151
  16. data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +99 -95
  17. data/lib/xqsr3/diagnostics/inspect_builder.rb +86 -86
  18. data/lib/xqsr3/diagnostics.rb +3 -3
  19. data/lib/xqsr3/doc_.rb +136 -136
  20. data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
  21. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +18 -17
  22. data/lib/xqsr3/extensions/enumerable/detect_map.rb +41 -41
  23. data/lib/xqsr3/extensions/enumerable/unique.rb +32 -31
  24. data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -1
  25. data/lib/xqsr3/extensions/hash/except.rb +16 -16
  26. data/lib/xqsr3/extensions/hash/has_match.rb +10 -10
  27. data/lib/xqsr3/extensions/hash/match.rb +10 -10
  28. data/lib/xqsr3/extensions/hash/slice.rb +11 -11
  29. data/lib/xqsr3/extensions/hash.rb +1 -1
  30. data/lib/xqsr3/extensions/integer/to_s_grp.rb +118 -0
  31. data/lib/xqsr3/extensions/integer.rb +3 -0
  32. data/lib/xqsr3/extensions/io/writelines.rb +34 -34
  33. data/lib/xqsr3/extensions/kernel/integer.rb +26 -26
  34. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +15 -14
  35. data/lib/xqsr3/extensions/kernel.rb +1 -0
  36. data/lib/xqsr3/extensions/string/ends_with.rb +1 -1
  37. data/lib/xqsr3/extensions/string/map_option_string.rb +4 -5
  38. data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -1
  39. data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -1
  40. data/lib/xqsr3/extensions/string/quote_if.rb +1 -2
  41. data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
  42. data/lib/xqsr3/extensions/string/to_bool.rb +8 -9
  43. data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
  44. data/lib/xqsr3/extensions/string/truncate.rb +1 -2
  45. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +7 -7
  46. data/lib/xqsr3/extensions/test/unit/assert_false.rb +6 -7
  47. data/lib/xqsr3/extensions/test/unit/assert_not.rb +6 -7
  48. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +7 -7
  49. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -62
  50. data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +7 -8
  51. data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +7 -8
  52. data/lib/xqsr3/extensions/test/unit/assert_true.rb +6 -7
  53. data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +36 -38
  54. data/lib/xqsr3/extensions.rb +5 -5
  55. data/lib/xqsr3/hash_utilities/deep_transform.rb +71 -71
  56. data/lib/xqsr3/hash_utilities/key_matching.rb +82 -82
  57. data/lib/xqsr3/hash_utilities.rb +3 -3
  58. data/lib/xqsr3/internal_/test_unit_version_.rb +130 -88
  59. data/lib/xqsr3/io/writelines.rb +125 -125
  60. data/lib/xqsr3/quality/parameter_checking.rb +452 -453
  61. data/lib/xqsr3/quality.rb +2 -2
  62. data/lib/xqsr3/string_utilities/ends_with.rb +64 -64
  63. data/lib/xqsr3/string_utilities/nil_if_empty.rb +33 -34
  64. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +35 -35
  65. data/lib/xqsr3/string_utilities/quote_if.rb +55 -56
  66. data/lib/xqsr3/string_utilities/starts_with.rb +64 -64
  67. data/lib/xqsr3/string_utilities/to_symbol.rb +80 -80
  68. data/lib/xqsr3/string_utilities/truncate.rb +60 -61
  69. data/lib/xqsr3/string_utilities.rb +8 -8
  70. data/lib/xqsr3/version.rb +19 -20
  71. data/test/performance/frequency_map.rb +13 -27
  72. data/test/scratch/test_assert_raise_with_message.rb +12 -13
  73. data/test/unit/array_utilities/tc_join_with_or.rb +140 -142
  74. data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
  75. data/test/unit/containers/tc_frequency_map.rb +607 -554
  76. data/test/unit/containers/tc_multi_map.rb +573 -522
  77. data/test/unit/conversion/tc_integer_parser.rb +73 -73
  78. data/test/unit/conversion/tc_to_bool.rb +26 -26
  79. data/test/unit/diagnostics/exceptions/tc_with_cause.rb +165 -165
  80. data/test/unit/diagnostics/tc_exception_utilities.rb +156 -156
  81. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +14 -14
  82. data/test/unit/extensions/enumerable/tc_detect_map.rb +20 -20
  83. data/test/unit/extensions/enumerable/tc_unique.rb +34 -34
  84. data/test/unit/extensions/hash/tc_deep_transform.rb +22 -22
  85. data/test/unit/extensions/hash/tc_except.rb +28 -28
  86. data/test/unit/extensions/hash/tc_hash.rb +1 -1
  87. data/test/unit/extensions/hash/tc_slice.rb +14 -14
  88. data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
  89. data/test/unit/extensions/integer/ts_all.rb +12 -0
  90. data/test/unit/extensions/io/tc_writelines.rb +77 -77
  91. data/test/unit/extensions/kernel/tc_integer.rb +75 -75
  92. data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
  93. data/test/unit/extensions/object/tc_inspect.rb +51 -51
  94. data/test/unit/extensions/string/tc_bool.tb +24 -24
  95. data/test/unit/extensions/string/tc_ends_with.rb +53 -53
  96. data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
  97. data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
  98. data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
  99. data/test/unit/extensions/string/tc_quote_if.rb +18 -18
  100. data/test/unit/extensions/string/tc_starts_with.rb +53 -53
  101. data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
  102. data/test/unit/extensions/string/tc_truncate.rb +18 -18
  103. data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
  104. data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
  105. data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
  106. data/test/unit/hash_utilities/tc_has_match.rb +70 -70
  107. data/test/unit/hash_utilities/tc_match.rb +83 -83
  108. data/test/unit/io/tc_writelines.rb +106 -108
  109. data/test/unit/quality/tc_parameter_checking.rb +390 -390
  110. data/test/unit/string_utilities/tc_truncate.rb +28 -28
  111. data/test/unit/tc_version.rb +15 -15
  112. metadata +6 -2
@@ -4,62 +4,60 @@ module Unit
4
4
 
5
5
  module Assertions
6
6
 
7
- unless respond_to? :assert_type_has_instance_methods
7
+ unless respond_to? :assert_type_has_instance_methods
8
8
 
9
- # Fails unless the given +type+ responds to all of the messages
10
- # given by +message_spec+
11
- #
12
- # === Signature
13
- #
14
- # * *Parameters:*
15
- # - +type+ (::Class) The type
16
- # - +message_spec+ (::Symbol, ::Array, ::Hash) A specification of message(s) received by the instances of +type+. If a ::Symbol, then instances must respond to this single message. If an ::Array (all elements of which must be ::Symbol), then instances must respond to _all_ messages. If a ::Hash, then instances must respond to _all_ messages represented by the keys; the values are available for specifying a custom failure message (or value is +nil+ for stock message)
17
- # - +failure_message+ (::String) If specified, is used when instances of +type+ do not respond to a message and no custom failure message is provided for it
18
- def assert_type_has_instance_methods(type, message_spec, failure_message = nil)
9
+ # Fails unless the given +type+ responds to all of the messages
10
+ # given by +message_spec+
11
+ #
12
+ # === Signature
13
+ #
14
+ # * *Parameters:*
15
+ # - +type+ (::Class) The type
16
+ # - +message_spec+ (::Symbol, ::Array, ::Hash) A specification of message(s) received by the instances of +type+. If a ::Symbol, then instances must respond to this single message. If an ::Array (all elements of which must be ::Symbol), then instances must respond to _all_ messages. If a ::Hash, then instances must respond to _all_ messages represented by the keys; the values are available for specifying a custom failure message (or value is +nil+ for stock message)
17
+ # - +failure_message+ (::String) If specified, is used when instances of +type+ do not respond to a message and no custom failure message is provided for it
18
+ def assert_type_has_instance_methods(type, message_spec, failure_message = nil)
19
19
 
20
- warn "type parameter - '#{type} (#{type.class})' - should be a Class" unless type.is_a?(::Class)
20
+ warn "type parameter - '#{type} (#{type.class})' - should be a Class" unless type.is_a?(::Class)
21
21
 
22
- case message_spec
23
- when ::Hash
22
+ case message_spec
23
+ when ::Hash
24
24
 
25
- warn "every key in a Hash message_spec should be of type Symbol" unless message_spec.keys.all? { |k| ::Symbol === k }
26
- when ::Array
25
+ warn "every key in a Hash message_spec should be of type Symbol" unless message_spec.keys.all? { |k| ::Symbol === k }
26
+ when ::Array
27
27
 
28
- warn "every key in an Array message_spec should be of type Symbol" unless message_spec.all? { |k| ::Symbol === k }
28
+ warn "every key in an Array message_spec should be of type Symbol" unless message_spec.all? { |k| ::Symbol === k }
29
29
 
30
- message_spec = Hash[message_spec.map { |s| [ s, nil ] }]
31
- when ::Symbol
30
+ message_spec = Hash[message_spec.map { |s| [ s, nil ] }]
31
+ when ::Symbol
32
32
 
33
- message_spec[message_spec] = nil
34
- else
33
+ message_spec[message_spec] = nil
34
+ else
35
35
 
36
- msg = "message_spec - '#{message_spec} (#{message_spec.class})' - should be a Symbol, an Array of Symbols, or a Hash of Symbol => message"
36
+ msg = "message_spec - '#{message_spec} (#{message_spec.class})' - should be a Symbol, an Array of Symbols, or a Hash of Symbol => message"
37
37
 
38
- warn msg
38
+ warn msg
39
39
 
40
- return assert false, msg
41
- end
40
+ return assert false, msg
41
+ end
42
42
 
43
- ims = type.instance_methods
43
+ ims = type.instance_methods
44
44
 
45
- message_spec.each do |sym, message|
45
+ message_spec.each do |sym, message|
46
46
 
47
- unless ims.include? sym
47
+ unless ims.include? sym
48
48
 
49
- message ||= failure_message
50
- message ||= "type #{type} does not contain the instance method #{sym}"
49
+ message ||= failure_message
50
+ message ||= "type #{type} does not contain the instance method #{sym}"
51
51
 
52
- return assert false, message
53
- end
54
- end
52
+ return assert false, message
53
+ end
54
+ end
55
55
 
56
- assert true
57
- end
58
- end
56
+ assert true
57
+ end
58
+ end
59
59
 
60
60
  end # class Assertions
61
61
  end # module Unit
62
62
  end # module Test
63
63
 
64
-
65
-
@@ -1,13 +1,13 @@
1
1
 
2
2
  %w{
3
3
 
4
- array
5
- enumerable
6
- hash
7
- io
4
+ array
5
+ enumerable
6
+ hash
7
+ io
8
8
  }.each do |name|
9
9
 
10
- require File.join(File.dirname(__FILE__), 'extensions', name)
10
+ require File.join(File.dirname(__FILE__), 'extensions', name)
11
11
  end
12
12
 
13
13
 
@@ -1,18 +1,18 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/hash_utilities/deep_transform.rb
3
+ # File: lib/xqsr3/hash_utilities/deep_transform.rb
4
4
  #
5
- # Purpose: Definition of the ::Xqsr3::HashUtilities::DeepTransform
6
- # module
5
+ # Purpose: Definition of the ::Xqsr3::HashUtilities::DeepTransform module
7
6
  #
8
- # Created: 3rd June 2017
9
- # Updated: 14th March 2018
7
+ # Created: 3rd June 2017
8
+ # Updated: 29th March 2024
10
9
  #
11
- # Home: http://github.com/synesissoftware/xqsr3
10
+ # Home: http://github.com/synesissoftware/xqsr3
12
11
  #
13
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
14
13
  #
15
- # Copyright (c) 2017-2018, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
+ # Copyright (c) 2017-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
@@ -26,7 +26,7 @@
26
26
  # notice, this list of conditions and the following disclaimer in the
27
27
  # documentation and/or other materials provided with the distribution.
28
28
  #
29
- # * Neither the names of the copyright holder nor the names of its
29
+ # * Neither the names of the copyright holders nor the names of its
30
30
  # contributors may be used to endorse or promote products derived from
31
31
  # this software without specific prior written permission.
32
32
  #
@@ -58,94 +58,94 @@ module HashUtilities
58
58
 
59
59
  module DeepTransform
60
60
 
61
- private
62
- def self.do_deep_transform_on_hashlike_ h, &block # :nodoc:
61
+ private
62
+ def self.do_deep_transform_on_hashlike_ h, &block # :nodoc:
63
63
 
64
- ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :map ]
64
+ ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :map ]
65
65
 
66
- case block.arity
67
- when 1
66
+ case block.arity
67
+ when 1
68
68
 
69
- h =
70
- Hash[h.map do |k, v|
69
+ h =
70
+ Hash[h.map do |k, v|
71
71
 
72
- k = k.deep_transform(&block) if ::Hash === k
73
- v = v.deep_transform(&block) if ::Hash === v
72
+ k = k.deep_transform(&block) if ::Hash === k
73
+ v = v.deep_transform(&block) if ::Hash === v
74
74
 
75
- [yield(k), v]
76
- end]
77
- when 2
75
+ [yield(k), v]
76
+ end]
77
+ when 2
78
78
 
79
- h =
80
- Hash[h.map do |k, v|
79
+ h =
80
+ Hash[h.map do |k, v|
81
81
 
82
- k = k.deep_transform(&block) if ::Hash === k
83
- v = v.deep_transform(&block) if ::Hash === v
82
+ k = k.deep_transform(&block) if ::Hash === k
83
+ v = v.deep_transform(&block) if ::Hash === v
84
84
 
85
- yield(k, v)
86
- end]
87
- else
85
+ yield(k, v)
86
+ end]
87
+ else
88
88
 
89
- raise ArgumentError, "block arity must be 1 or 2"
90
- end
89
+ raise ArgumentError, "block arity must be 1 or 2"
90
+ end
91
91
 
92
- h
93
- end
92
+ h
93
+ end
94
94
 
95
- def do_deep_transform_on_self_ &block # :nodoc:
95
+ def do_deep_transform_on_self_ &block # :nodoc:
96
96
 
97
- ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[]=, :delete, :keys ]
97
+ ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[]=, :delete, :keys ]
98
98
 
99
- case block.arity
100
- when 1
99
+ case block.arity
100
+ when 1
101
101
 
102
- self.keys.each do |k|
102
+ self.keys.each do |k|
103
103
 
104
- v = self.delete k
104
+ v = self.delete k
105
105
 
106
- k = k.deep_transform(&block) if ::Hash === k
107
- v = v.deep_transform(&block) if ::Hash === v
106
+ k = k.deep_transform(&block) if ::Hash === k
107
+ v = v.deep_transform(&block) if ::Hash === v
108
108
 
109
- self[yield(k)] = v
110
- end
111
- when 2
109
+ self[yield(k)] = v
110
+ end
111
+ when 2
112
112
 
113
- self.keys.each do |k|
113
+ self.keys.each do |k|
114
114
 
115
- v = self.delete k
115
+ v = self.delete k
116
116
 
117
- k = k.deep_transform(&block) if ::Hash === k
118
- v = v.deep_transform(&block) if ::Hash === v
117
+ k = k.deep_transform(&block) if ::Hash === k
118
+ v = v.deep_transform(&block) if ::Hash === v
119
119
 
120
- k, v = yield(k, v)
121
- end
122
- else
120
+ k, v = yield(k, v)
121
+ end
122
+ else
123
123
 
124
- raise ArgumentError, "block arity must be 1 or 2"
125
- end
126
- end
127
- public
124
+ raise ArgumentError, "block arity must be 1 or 2"
125
+ end
126
+ end
127
+ public
128
128
 
129
- # Executes the given mandatory 1- or 2-parameter block on the receiving
130
- # instance, which must be a Hash or a type that responds to the +map+
131
- # message, returning a copy of the instance in which keys (1-parameter
132
- # block) or keys and values (2-parameter block) are transformed.
133
- def deep_transform &block
129
+ # Executes the given mandatory 1- or 2-parameter block on the receiving
130
+ # instance, which must be a Hash or a type that responds to the +map+
131
+ # message, returning a copy of the instance in which keys (1-parameter
132
+ # block) or keys and values (2-parameter block) are transformed.
133
+ def deep_transform &block
134
134
 
135
- DeepTransform.do_deep_transform_on_hashlike_(self, &block)
136
- end
135
+ DeepTransform.do_deep_transform_on_hashlike_(self, &block)
136
+ end
137
137
 
138
- # Executes the given mandatory 1- or 2-parameter block on the receiving
139
- # instance, whihc must be a Hash or a type that responds to +[]+,
140
- # +delete+, and +keys+ messages, changing the keys (1-parameter block)
141
- # or keys and values (2-parameter block).
142
- #
143
- # @note This method is not strongly exception-safe - failure during
144
- # transformation can result in a partially transformed instance
145
- def deep_transform! &block
138
+ # Executes the given mandatory 1- or 2-parameter block on the receiving
139
+ # instance, whihc must be a Hash or a type that responds to +[]+,
140
+ # +delete+, and +keys+ messages, changing the keys (1-parameter block)
141
+ # or keys and values (2-parameter block).
142
+ #
143
+ # @note This method is not strongly exception-safe - failure during
144
+ # transformation can result in a partially transformed instance
145
+ def deep_transform! &block
146
146
 
147
- do_deep_transform_on_self_(&block)
148
- end
147
+ do_deep_transform_on_self_(&block)
148
+ end
149
149
 
150
150
  end # module DeepTransform
151
151
 
@@ -1,17 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/hash_utilities/key_matching.rb
3
+ # File: lib/xqsr3/hash_utilities/key_matching.rb
4
4
  #
5
- # Purpose: Definition of the ::Xqsr3::HashUtilities::KeyMatching
6
- # module
5
+ # Purpose: Definition of the ::Xqsr3::HashUtilities::KeyMatching module
7
6
  #
8
- # Created: 15th November 2017
9
- # Updated: 15th April 2019
7
+ # Created: 15th November 2017
8
+ # Updated: 29th March 2024
10
9
  #
11
- # Home: http://github.com/synesissoftware/xqsr3
10
+ # Home: http://github.com/synesissoftware/xqsr3
12
11
  #
13
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
14
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -26,7 +26,7 @@
26
26
  # notice, this list of conditions and the following disclaimer in the
27
27
  # documentation and/or other materials provided with the distribution.
28
28
  #
29
- # * Neither the names of the copyright holder nor the names of its
29
+ # * Neither the names of the copyright holders nor the names of its
30
30
  # contributors may be used to endorse or promote products derived from
31
31
  # this software without specific prior written permission.
32
32
  #
@@ -60,113 +60,113 @@ module HashUtilities
60
60
  # and #match methods
61
61
  module KeyMatching
62
62
 
63
- private
64
- def self.do_match_ h, re, **options # :nodoc:
63
+ private
64
+ def self.do_match_ h, re, **options # :nodoc:
65
65
 
66
- ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[], :has_key?, :each ]
66
+ ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[], :has_key?, :each ]
67
67
 
68
- return h[re] if h.has_key? re
68
+ return h[re] if h.has_key? re
69
69
 
70
- case re
71
- when ::Regexp
70
+ case re
71
+ when ::Regexp
72
72
 
73
- h.each do |k, v|
73
+ h.each do |k, v|
74
74
 
75
- case k
76
- when ::Regexp
75
+ case k
76
+ when ::Regexp
77
77
 
78
- next
79
- else
78
+ next
79
+ else
80
80
 
81
- return v if k.to_s =~ re
82
- end
83
- end
84
- else
81
+ return v if k.to_s =~ re
82
+ end
83
+ end
84
+ else
85
85
 
86
- h.each do |k, v|
86
+ h.each do |k, v|
87
87
 
88
- case k
89
- when ::Regexp
88
+ case k
89
+ when ::Regexp
90
90
 
91
- return v if re.to_s =~ k
92
- else
91
+ return v if re.to_s =~ k
92
+ else
93
93
 
94
- next
95
- end
96
- end
97
- end
94
+ next
95
+ end
96
+ end
97
+ end
98
98
 
99
- nil
100
- end
99
+ nil
100
+ end
101
101
 
102
- def self.do_has_match_ h, re, **options # :nodoc:
102
+ def self.do_has_match_ h, re, **options # :nodoc:
103
103
 
104
- ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[], :has_key?, :each ]
104
+ ::Xqsr3::Quality::ParameterChecking.check_parameter h, 'h', responds_to: [ :[], :has_key?, :each ]
105
105
 
106
- return true if h.has_key? re
106
+ return true if h.has_key? re
107
107
 
108
- case re
109
- when ::Regexp
108
+ case re
109
+ when ::Regexp
110
110
 
111
- h.each do |k, v|
111
+ h.each do |k, v|
112
112
 
113
- case k
114
- when ::Regexp
113
+ case k
114
+ when ::Regexp
115
115
 
116
- next
117
- else
116
+ next
117
+ else
118
118
 
119
- return true if k.to_s =~ re
120
- end
121
- end
122
- else
119
+ return true if k.to_s =~ re
120
+ end
121
+ end
122
+ else
123
123
 
124
- h.each do |k, v|
124
+ h.each do |k, v|
125
125
 
126
- case k
127
- when ::Regexp
126
+ case k
127
+ when ::Regexp
128
128
 
129
- return true if re.to_s =~ k
130
- else
129
+ return true if re.to_s =~ k
130
+ else
131
131
 
132
- next
133
- end
134
- end
135
- end
132
+ next
133
+ end
134
+ end
135
+ end
136
136
 
137
- false
138
- end
139
- public
137
+ false
138
+ end
139
+ public
140
140
 
141
- # Retrieves the value object corresponding to the first key object that
142
- # matches the given +re+, in the hash +h+, according to the given
143
- # options.
144
- def self.match h, re, **options
141
+ # Retrieves the value object corresponding to the first key object that
142
+ # matches the given +re+, in the hash +h+, according to the given
143
+ # options.
144
+ def self.match h, re, **options
145
145
 
146
- Xqsr3::HashUtilities::KeyMatching.do_match_ h, re, **options
147
- end
146
+ Xqsr3::HashUtilities::KeyMatching.do_match_ h, re, **options
147
+ end
148
148
 
149
- # Returns true if the hash +h+ contains a key object that matches the
150
- # given +re+, according to the given options
151
- def self.has_match? h, re, **options
149
+ # Returns true if the hash +h+ contains a key object that matches the
150
+ # given +re+, according to the given options
151
+ def self.has_match? h, re, **options
152
152
 
153
- Xqsr3::HashUtilities::KeyMatching.do_has_match_ h, re, **options
154
- end
153
+ Xqsr3::HashUtilities::KeyMatching.do_has_match_ h, re, **options
154
+ end
155
155
 
156
- # Retrieves the value object corresponding to the first key object that
157
- # matches the given +re+, in the hash +h+, according to the given
158
- # options.
159
- def match h, re, **options
156
+ # Retrieves the value object corresponding to the first key object that
157
+ # matches the given +re+, in the hash +h+, according to the given
158
+ # options.
159
+ def match h, re, **options
160
160
 
161
- Xqsr3::HashUtilities::KeyMatching.do_match_ h, re, **options
162
- end
161
+ Xqsr3::HashUtilities::KeyMatching.do_match_ h, re, **options
162
+ end
163
163
 
164
- # Returns true if the hash +h+ contains a key object that matches the
165
- # given +re+, according to the given options
166
- def has_match? h, re, **options
164
+ # Returns true if the hash +h+ contains a key object that matches the
165
+ # given +re+, according to the given options
166
+ def has_match? h, re, **options
167
167
 
168
- Xqsr3::HashUtilities::KeyMatching.do_has_match_ h, re, **options
169
- end
168
+ Xqsr3::HashUtilities::KeyMatching.do_has_match_ h, re, **options
169
+ end
170
170
 
171
171
  end # module KeyMatching
172
172
 
@@ -1,11 +1,11 @@
1
1
 
2
2
  %w{
3
3
 
4
- deep_transform
5
- key_matching
4
+ deep_transform
5
+ key_matching
6
6
  }.each do |name|
7
7
 
8
- require File.join(File.dirname(__FILE__), 'hash_utilities', name)
8
+ require File.join(File.dirname(__FILE__), 'hash_utilities', name)
9
9
  end
10
10
 
11
11