quality_extensions 1.1.4 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Xfind_bug_test.rb +28 -0
- data/lib/quality_extensions/array/all_same.rb +40 -0
- data/lib/quality_extensions/array/delete_if_bang.rb +145 -0
- data/lib/quality_extensions/array/expand_ranges.rb +3 -53
- data/lib/quality_extensions/array/include_any_of.rb +23 -0
- data/lib/quality_extensions/array/justify.rb +305 -0
- data/lib/quality_extensions/array/{average.rb → mean.rb} +1 -1
- data/lib/quality_extensions/array/select_if_bang.rb +0 -0
- data/lib/quality_extensions/array/sum.rb +30 -0
- data/lib/quality_extensions/enumerable/all_same.rb +43 -0
- data/lib/quality_extensions/enumerable/group_by_and_map.rb +110 -0
- data/lib/quality_extensions/enumerable/select_bang.rb +49 -0
- data/lib/quality_extensions/enumerable/select_while.rb +337 -52
- data/lib/quality_extensions/enumerable/select_with_index.rb +145 -0
- data/lib/quality_extensions/hash/hash_select.rb +5 -2
- data/lib/quality_extensions/hash/merge_if.rb +48 -0
- data/lib/quality_extensions/kernel/example_printer.rb +10 -3
- data/lib/quality_extensions/kernel/require_all.rb +24 -8
- data/lib/quality_extensions/kernel/sleep_loudly.rb +108 -0
- data/lib/quality_extensions/kernel/uninterruptable.rb +22 -0
- data/lib/quality_extensions/matrix/indexable.rb +68 -0
- data/lib/quality_extensions/matrix/linked_vectors.rb +137 -0
- data/lib/quality_extensions/module/class_methods.rb +2 -0
- data/lib/quality_extensions/object/non.rb +12 -0
- data/lib/quality_extensions/pathname.rb +435 -7
- data/lib/quality_extensions/range_list.rb +222 -0
- data/lib/quality_extensions/safe_nil.rb +5 -3
- data/lib/quality_extensions/string/each_char_with_index.rb +1 -2
- data/lib/quality_extensions/string/integer_eh.rb +3 -0
- data/lib/quality_extensions/string/numeric_eh.rb +74 -0
- data/lib/quality_extensions/string/safe_in_comment.rb +38 -0
- data/lib/quality_extensions/string/safe_numeric_conversion.rb +102 -0
- data/lib/quality_extensions/string/shell_escape.rb +4 -4
- data/lib/quality_extensions/string/with_knowledge_of_color.rb +8 -0
- data/lib/quality_extensions/table.rb +116 -0
- data/lib/quality_extensions/template.rb +4 -5
- data/lib/quality_extensions/template.rb_test_unit.rb +33 -0
- data/lib/quality_extensions/test/difference_highlighting-minitest.rb +321 -0
- data/lib/quality_extensions/test/difference_highlighting-test_unit.rb +325 -0
- data/lib/quality_extensions/test/difference_highlighting.rb +6 -314
- data/lib/quality_extensions/timeout/countdown_timer.rb +1 -0
- data/lib/quality_extensions/vector/enumerable.rb +51 -0
- metadata +35 -5
@@ -1,323 +1,15 @@
|
|
1
1
|
#--
|
2
2
|
# Author:: Tyler Rick
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) 2009 Tyler Rick
|
4
4
|
# License:: Ruby License
|
5
5
|
# Submit to Facets?::
|
6
6
|
# Developer notes::
|
7
7
|
#++
|
8
|
-
# This file adds a bit of color to your failed string comparisons (assert_equal).
|
9
|
-
# Differences will be highlighted for you in color so that you can instantly find them.
|
10
8
|
|
11
|
-
|
12
|
-
require 'rubygems'
|
13
|
-
gem 'colored'
|
14
|
-
require 'colored'
|
15
|
-
gem 'facets'
|
16
|
-
require 'facets/module/alias_method_chain'
|
17
|
-
require 'quality_extensions/object/send_if'
|
18
|
-
require 'quality_extensions/string/each_char_with_index'
|
19
|
-
require 'quality_extensions/module/bool_attr_accessor'
|
20
|
-
require 'quality_extensions/module/guard_method'
|
21
|
-
require 'quality_extensions/colored/toggleability'
|
22
|
-
|
23
|
-
require 'test/unit'
|
24
|
-
|
25
|
-
class String
|
26
|
-
# For all of the next 3 methods, we will underline spaces so that they are actually visible on the screen.
|
27
|
-
# Newlines will be replaced with '\n'"\n".
|
28
|
-
|
29
|
-
# This is a (sub)string that is common to both expected and actual
|
30
|
-
def highlight_commonality
|
31
|
-
self.
|
32
|
-
make_control_characters_visible.
|
33
|
-
make_spaces_visible(:green).
|
34
|
-
green.bold
|
35
|
-
#send_unless(self == ' ', :bold) # spaces are not bold; '_'s (and everything else) are
|
36
|
-
end
|
37
|
-
# This is a (sub)string that is different between expected and actual
|
38
|
-
def highlight_difference
|
39
|
-
self.
|
40
|
-
make_control_characters_visible.
|
41
|
-
make_spaces_visible(:red).
|
42
|
-
red.bold
|
43
|
-
#send_unless(self == ' ', :bold) # spaces are not bold; '_'s (and everything else) are
|
44
|
-
end
|
45
|
-
# This is a (sub)string that exists only in *self*, not in the other string
|
46
|
-
def highlight_unique
|
47
|
-
self.
|
48
|
-
make_control_characters_visible.
|
49
|
-
make_spaces_visible(:magenta).
|
50
|
-
magenta
|
51
|
-
end
|
52
|
-
# This is a (sub)string that doesn't exist in self, only in the *other* string. It's just a placeholder character (a space) that represents a *missing* character.
|
53
|
-
def highlight_absence
|
54
|
-
self.white.on_cyan.bold
|
55
|
-
end
|
56
|
-
def make_spaces_visible(color)
|
57
|
-
#:todo: Make this optional? Might be useful if you are comparing things with lots of spaces and underscores and you want to be able to tell the difference between them...?
|
58
|
-
self.gsub(' ', ' '.send(:"on_#{color}"))
|
59
|
-
end
|
60
|
-
def make_control_characters_visible
|
61
|
-
self.gsub(/\n/, '\n'+"\n"). # Show '\n' in addition to actually doing the line break
|
62
|
-
gsub(/\r/, '\r'). # Just escape it...
|
63
|
-
gsub(/\t/, '\t')
|
64
|
-
#:todo: Add other control characters?
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
module Test
|
69
|
-
module Unit
|
70
|
-
module Assertions
|
71
|
-
|
72
|
-
class AssertionMessage
|
73
|
-
@@inspect_strings = false
|
74
|
-
mguard_method :inspect_strings!, :@@inspect_strings
|
75
|
-
|
76
|
-
# The problem with the original convert() is that it always called #inspect on strings... which is fine if you really
|
77
|
-
# want to see all those \n's and such. But not so great if you want to visually compare the strings. And if you have
|
78
|
-
# ANSI color codes in the strings, it will escape those so that you see the codes (\e[33m1) rather than the nice
|
79
|
-
# colored strings that you (sometimes) *want* to see...
|
80
|
-
#
|
81
|
-
def convert_with_option_to_not_use_inspect_for_strings(object)
|
82
|
-
if String === object
|
83
|
-
if self.class.inspect_strings?
|
84
|
-
# Use the original method, which used pp or inspect
|
85
|
-
convert_without_option_to_not_use_inspect_for_strings(object)
|
86
|
-
else
|
87
|
-
object
|
88
|
-
end
|
89
|
-
else
|
90
|
-
# We only care about strings. Everything else can just keep happening like it was before.
|
91
|
-
convert_without_option_to_not_use_inspect_for_strings(object)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
alias_method_chain :convert, :option_to_not_use_inspect_for_strings
|
95
|
-
end # class AssertionMessage
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
module Test
|
102
|
-
module Unit
|
103
|
-
module Assertions
|
104
|
-
@@use_assert_equal_with_highlight = nil
|
105
|
-
mguard_method :use_assert_equal_with_highlight!, :@@use_assert_equal_with_highlight
|
106
|
-
|
107
|
-
# The built-in behavior for <tt>assert_equal</tt> method is great for comparing small strings, but not so great for long strings.
|
108
|
-
# If both the strings you are dealing with are both 20 paragraphs long, for example, and they differ by only one character,
|
109
|
-
# the task of locating and identifying the one character that is off is akin to finding a (literal) needle in a
|
110
|
-
# (literal) haystack (not fun!).
|
111
|
-
#
|
112
|
-
# link:include/assert_equal_with_difference_highlighting-wheres_waldo.png
|
113
|
-
#
|
114
|
-
# This replacement/wrapper for <tt>assert_equal</tt> aims to solve all of your string comparison woes (and eventually someday
|
115
|
-
# perhaps arrays and hashes as well), helping you to spot differences very quickly and to have fun doing it.
|
116
|
-
#
|
117
|
-
# Rather than simply showing you the raw (<tt>inspect</tt>ed) +expected+ and +actual+ and expecting you, the poor user, to
|
118
|
-
# painstakingly compare the two and figure out exactly which characters are different by yourself this method will *highlight*
|
119
|
-
# the differences for you, allowing you to spot them an instant or less!!
|
120
|
-
#
|
121
|
-
# link:include/assert_equal_with_difference_highlighting-there_he_is.png
|
122
|
-
#
|
123
|
-
# *Strings*:
|
124
|
-
# * Does a characterwise comparison between the two strings. That is, for each index, it will look at the character at that
|
125
|
-
# index and decide if it is the same or different than the character at the same location in the other string. There are
|
126
|
-
# 3 1/2 cases:
|
127
|
-
# * *Common* characters are displayed in _green_,
|
128
|
-
# * *Different* characters in _red_,
|
129
|
-
# * Characters that exist <b>in only one string</b> but not the other are displayed in _yellow_
|
130
|
-
# * A _cyan_ <tt>~</tt> will appear that location in the _other_ string, as a placeholder for the <b>missing character</b>.
|
131
|
-
# *Arrays*:
|
132
|
-
# * [:todo:]
|
133
|
-
# *Hashes*:
|
134
|
-
# * [:todo:]
|
135
|
-
#
|
136
|
-
# <b>Disabling/enabling highlighting</b>:
|
137
|
-
#
|
138
|
-
# By default, highlighting is only used when one or both of the strings being compared is long or spans multiple lines. You can override the default with the <tt>:higlight</tt> option:
|
139
|
-
# assert_equal 'really long string', 'another really long string', :highlight => true
|
140
|
-
# You can turn it on for all assert_equal assertions by calling
|
141
|
-
# Test::Unit::Assertions::use_assert_equal_with_highlight!
|
142
|
-
# Or you can just turn it on or off for the duration of a block only:
|
143
|
-
# Test::Unit::Assertions::use_assert_equal_with_highlight! do
|
144
|
-
# assert_equal 'really long string', 'another really long string'
|
145
|
-
# end
|
146
|
-
#
|
147
|
-
# *Notes*:
|
148
|
-
# * Spaces are displayed as with a bright colored background so that they are actually visible on the screen (so you can distinguish an empty line from a line with spaces on it, for example).
|
149
|
-
# * Newlines are displayed as the text <tt>\n</tt> followed by the actual newline. Other control characters (<tt>\t</tt>, <tt>\r</tt>) are escaped as well so that you can tell what character it is.
|
150
|
-
#
|
151
|
-
# <b>Difference in method signature</b> from <tt>assert_equal_without_difference_highlighting</tt> (the standard behavior):
|
152
|
-
# * The last argument (+options+) is expected to be a hash rather than message=nil, since I don't see the use in passing in a message if
|
153
|
-
# the _default_ message can be made useful enough.
|
154
|
-
# * However, for compatibility with existing assert_equal calls, it will check if the 3rd argument is a string and if it is will use it as the failure message.
|
155
|
-
# * If you to pass in a message in combination with other options, use <tt>:message => 'my message'</tt>
|
156
|
-
#
|
157
|
-
# *Advanced*:
|
158
|
-
# * If you want everything to be escaped (so you can see the color _codes_ instead of the color itself, for example), use <tt>:inspect_strings => true</tt>
|
159
|
-
#
|
160
|
-
def assert_equal_with_highlighting(expected, actual, options = {})
|
161
|
-
if options.is_a?(String)
|
162
|
-
message = options
|
163
|
-
options = {}
|
164
|
-
else
|
165
|
-
message = options.delete(:message) || nil
|
166
|
-
end
|
167
|
-
highlight = options.delete(:highlight)
|
168
|
-
|
169
|
-
Assertions.send_unless(highlight.nil?, :use_assert_equal_with_highlight!, highlight) do
|
170
|
-
|
171
|
-
if String===expected and String===actual and expected!=actual and
|
172
|
-
(Assertions.use_assert_equal_with_highlight? || [expected.length, actual.length].max > 80 || [expected, actual].any? {|a| a.include?("\n")}) and
|
173
|
-
!(Assertions.use_assert_equal_with_highlight? == false)
|
174
|
-
expected_with_highlighting = ''
|
175
|
-
actual_with_highlighting = ''
|
176
|
-
full_message = nil
|
177
|
-
String.color_on! do
|
178
|
-
longest_string = [expected, actual].max {|a, b| a.length <=> b.length}
|
179
|
-
longest_string.each_char_with_index do |i, exp|
|
180
|
-
exp = expected[i] ? expected[i].chr : nil
|
181
|
-
act = actual[i] ? actual[i].chr : nil
|
182
|
-
if act.nil?
|
183
|
-
expected_with_highlighting << exp.highlight_unique
|
184
|
-
actual_with_highlighting << '~'.highlight_absence
|
185
|
-
elsif exp.nil?
|
186
|
-
expected_with_highlighting << '~'.highlight_absence
|
187
|
-
actual_with_highlighting << act.highlight_unique
|
188
|
-
elsif exp != act
|
189
|
-
expected_with_highlighting << exp.highlight_difference
|
190
|
-
actual_with_highlighting << act.highlight_difference
|
191
|
-
else
|
192
|
-
expected_with_highlighting << exp.highlight_commonality
|
193
|
-
actual_with_highlighting << exp.highlight_commonality
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
full_message = build_message(message, <<End, expected_with_highlighting, actual_with_highlighting)
|
198
|
-
#{(' '*50 + ' Expected: ' + ' '*50).blue.underline.on_white }
|
199
|
-
?
|
200
|
-
#{(' '*50 + ' But was: ' + ' '*50).yellow.underline.on_red }
|
201
|
-
?
|
202
|
-
End
|
203
|
-
end
|
204
|
-
AssertionMessage.inspect_strings!(options.delete(:inspect_strings) || false) do
|
205
|
-
assert_block(full_message) { expected == actual }
|
206
|
-
end
|
207
|
-
else
|
208
|
-
assert_equal_without_highlighting(expected, actual, message)
|
209
|
-
end
|
210
|
-
|
211
|
-
end # use_assert_equal_with_highlight!
|
212
|
-
|
213
|
-
end # def assert_equal_with_highlighting
|
214
|
-
alias_method_chain :assert_equal, :highlighting
|
215
|
-
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
# _____ _
|
228
|
-
# |_ _|__ ___| |_
|
229
|
-
# | |/ _ \/ __| __|
|
230
|
-
# | | __/\__ \ |_
|
231
|
-
# |_|\___||___/\__|
|
232
|
-
#
|
233
|
-
=begin test
|
234
|
-
require 'test/unit'
|
235
|
-
#Test::Unit::Assertions::use_assert_equal_with_highlight!
|
236
|
-
|
237
|
-
# :todo: Currently these (intentionally failing) tests are just manual and require visual inspection. If possible it would be
|
238
|
-
# nice to capture the output of the failure and make an assertion against that. But I'm not sure how to do that...
|
239
|
-
|
240
|
-
class TheTest < Test::Unit::TestCase
|
241
|
-
def test01_single_character_differences
|
242
|
-
assert_equal <<End, <<End
|
243
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat mi. In sagittis, augue non eleifend sodales, arcu urna congue sapien, aliquet molestie pede urna sit amet dolor. Etiam diam. Vestibulum ornare, felis et porta faucibus, magna sapien vulputate arcu, vel facilisis lectus ipsum et ipsum.
|
244
|
-
|
245
|
-
Vivamus massa odio, lacinia eu, euismod vitae, lobortis eu, erat. Duis tincidunt, neque ac_tincidunt convallis, nibh tellus sodales eros, ut tristique nunc purus in urna. Nullam semper. Fusce quis augue ut metus interdum congue. Duis id dolor eu mi pellentesque sagittis. Quisque imperdiet orci a odio.
|
246
|
-
End
|
247
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat mi. In sagittis, augue non eleifend sodales, arcu urna congue sapien, aliquet molestie pede urna sit amet dolor. Etiam diam. Vestibulum ornare, felis et porta faucibus, magna sapien vulputate arcu, vel facilisis lectus ipsum et ipsum.
|
248
|
-
|
249
|
-
Vivamus massa odio, lacinia eu, euismod vitae, lobortis eu, erat. Duis tincidunt, neque ac tincidunt convallis, nibh tellus sodales eros, ut tristique nunc purus in urna. Nullam semper. Fusce quis augue ut metus interdum congue. Duis id color eu mi pellentesque sagittis. Quisque imperdiet orci a odio.
|
250
|
-
End
|
251
|
-
end
|
252
|
-
|
253
|
-
def test02_difference_in_control_characters
|
254
|
-
assert_equal "Lorem ipsum dolor sit amet,\nconsectetuer adipiscing elit.\nSed feugiat mi.",
|
255
|
-
"Lorem ipsum_dolor sit amet, consectetuer\tadipiscing elit.\n\rSed feugiat mi.", :highlight => true
|
256
|
-
end
|
257
|
-
|
258
|
-
def test03_expected_is_longer
|
259
|
-
assert_equal '1234567890', '123', :highlight => true
|
260
|
-
end
|
261
|
-
|
262
|
-
def test04_actual_is_longer
|
263
|
-
assert_equal '123', '1234567890', :highlight => true
|
264
|
-
end
|
265
|
-
|
266
|
-
# Use the ones above this line as screenshot material...
|
267
|
-
|
268
|
-
def test05_one_is_much_longer
|
269
|
-
assert_equal <<End, <<End
|
270
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat mi. In sagittis, augue non eleifend sodales, arcu urna congue sapien, aliquet molestie pede urna sit amet dolor. Etiam diam. Vestibulum ornare, felis et porta faucibus, magna sapien vulputate arcu, vel facilisis lectus ipsum et ipsum. Sed dictum, dolor suscipit malesuada pharetra, orci augue lobortis lectus, porta porta magna magna ut dui. Duis viverra enim sed felis. Mauris semper volutpat pede. Integer lectus lorem, lacinia in, iaculis ut, euismod non, nulla. Nunc non libero eget diam congue ornare. Nunc dictum tellus sed turpis. Sed venenatis, pede non ultricies pharetra, dolor felis malesuada nisl, id imperdiet lorem dui vel velit.
|
271
|
-
End
|
272
|
-
Lorem ipsum dolor sit amet
|
273
|
-
End
|
274
|
-
end
|
275
|
-
|
276
|
-
def test06_only_minor_single_character_differences_but_then_it_gets_out_of_sync
|
277
|
-
assert_equal <<End, <<End
|
278
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat mi. In sagittis, augue non eleifend sodales, arcu urna congue sapien.
|
279
|
-
|
280
|
-
Vivamus massa odio, lacinia eu, euismod vitae, lobortis eu, erat. Duis tincidunt, neque ac tincidunt convallis, nibh tellus sodales eros, ut tristique nunc purus in urna. Nullam semper. Fusce quis augue ut metus interdum congue. Duis id dolor eu mi pellentesque sagittis. Quisque imperdiet orci a odio.
|
281
|
-
End
|
282
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat mi. In sagittis, argue non eleifend sodales, arcu urna conque sapien.
|
283
|
-
|
284
|
-
Vivamus massa odio, lacinia eu, euismod vitae, lobortis eu, erat. Duis tincidunt, neque ac tincidunt convallis, nibh tellus sodales eros, ut tristique nunc purus in urna. Nullam semper. Fusce quis augue ut metus interdum congue. Duis id dolor eu mi pellentesque sagittis. Quisque imperdiet orci a odio.
|
285
|
-
End
|
286
|
-
end
|
287
|
-
|
288
|
-
def test07_underscores_versus_underlines
|
289
|
-
assert_equal <<End, <<End
|
290
|
-
___[Underscores]___[Underscores] [Spaces] _ _ _ _ _ [Mix]
|
291
|
-
End
|
292
|
-
[Spaces] ___[Underscores] [Spaces] _ _ __ _ _[Mix]
|
293
|
-
End
|
294
|
-
end
|
295
|
-
|
296
|
-
def test08_inspect_strings_true
|
297
|
-
assert_equal '1234567890', '123', :inspect_strings => true
|
298
|
-
end
|
299
|
-
def test09_inspect_highlight_false
|
300
|
-
assert_equal '1234567890', '123', :highlight => false
|
301
|
-
end
|
302
|
-
def test10_highlight_false
|
303
|
-
Test::Unit::Assertions::use_assert_equal_with_highlight! false do
|
304
|
-
assert_equal 'really long string', 'another really long string'
|
305
|
-
end
|
306
|
-
end
|
307
|
-
def test11_highlight_true
|
308
|
-
Test::Unit::Assertions::use_assert_equal_with_highlight! do
|
309
|
-
assert_equal 'really long string', 'another really long string'
|
310
|
-
end
|
311
|
-
end
|
312
|
-
def test12_compatibility__using_arg3_as_message
|
313
|
-
assert_equal 'really long string', 'another really long string', 'This is my message! Can you see it?'
|
314
|
-
end
|
315
|
-
def test13_that_assert_nil_still_works
|
316
|
-
# Exposed a bug that existed previously, where it tried to do "".delete(:message)
|
317
|
-
assert_nil nil
|
318
|
-
end
|
9
|
+
require 'facets'
|
319
10
|
|
11
|
+
if $LOADED_FEATURES.detect {|f| f =~ %r(minitest/unit.rb)}
|
12
|
+
require_local 'difference_highlighting-minitest.rb'
|
13
|
+
else
|
14
|
+
require_local 'difference_highlighting-test_unit.rb'
|
320
15
|
end
|
321
|
-
=end
|
322
|
-
|
323
|
-
|
@@ -0,0 +1 @@
|
|
1
|
+
# in separate threads does a sleep_loudly and a timeout
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Tyler Rick
|
3
|
+
# Copyright:: Copyright (c) 2009, Tyler Rick
|
4
|
+
# License:: Ruby License
|
5
|
+
# Submit to Facets?:: Yes
|
6
|
+
# Developer notes::
|
7
|
+
# History::
|
8
|
+
#++
|
9
|
+
|
10
|
+
require 'matrix'
|
11
|
+
|
12
|
+
class Vector
|
13
|
+
include Enumerable
|
14
|
+
|
15
|
+
def each &block
|
16
|
+
to_a.each &block
|
17
|
+
end
|
18
|
+
|
19
|
+
def sum
|
20
|
+
inject(&:+)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# _____ _
|
25
|
+
# |_ _|__ ___| |_
|
26
|
+
# | |/ _ \/ __| __|
|
27
|
+
# | | __/\__ \ |_
|
28
|
+
# |_|\___||___/\__|
|
29
|
+
#
|
30
|
+
=begin test
|
31
|
+
require 'spec'
|
32
|
+
|
33
|
+
describe 'Vector' do
|
34
|
+
it 'has an each method' do
|
35
|
+
Vector[1, 2].each.to_a.should == [1, 2]
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'includes Enumerable' do
|
39
|
+
Vector.ancestors.should include(Enumerable)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has an inject method that works' do
|
43
|
+
Vector[1, 2].inject(&:+).should == 3
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'has a sum method' do
|
47
|
+
Vector[1, 2].sum.should == 3
|
48
|
+
end
|
49
|
+
end
|
50
|
+
=end
|
51
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quality_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick and others
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,8 +28,10 @@ files:
|
|
28
28
|
- lib/quality_extensions/date/month_ranges.rb
|
29
29
|
- lib/quality_extensions/date/deprecated.rb
|
30
30
|
- lib/quality_extensions/month.rb
|
31
|
+
- lib/quality_extensions/kernel/uninterruptable.rb
|
31
32
|
- lib/quality_extensions/kernel/example_printer.rb
|
32
33
|
- lib/quality_extensions/kernel/require_once.rb
|
34
|
+
- lib/quality_extensions/kernel/sleep_loudly.rb
|
33
35
|
- lib/quality_extensions/kernel/all.rb
|
34
36
|
- lib/quality_extensions/kernel/require_all.rb
|
35
37
|
- lib/quality_extensions/kernel/trap_chain.rb
|
@@ -49,6 +51,7 @@ files:
|
|
49
51
|
- lib/quality_extensions/hash/only.rb
|
50
52
|
- lib/quality_extensions/hash/to_date.rb
|
51
53
|
- lib/quality_extensions/hash/except.rb
|
54
|
+
- lib/quality_extensions/hash/merge_if.rb
|
52
55
|
- lib/quality_extensions/hash/all.rb
|
53
56
|
- lib/quality_extensions/hash/delete_unless.rb
|
54
57
|
- lib/quality_extensions/hash/to_query_string.rb
|
@@ -62,24 +65,35 @@ files:
|
|
62
65
|
- lib/quality_extensions/string/to_underscored_label.rb
|
63
66
|
- lib/quality_extensions/string/md5.rb
|
64
67
|
- lib/quality_extensions/string/prefix_lines.rb
|
68
|
+
- lib/quality_extensions/string/safe_numeric_conversion.rb
|
65
69
|
- lib/quality_extensions/string/all.rb
|
70
|
+
- lib/quality_extensions/string/safe_in_comment.rb
|
71
|
+
- lib/quality_extensions/string/numeric_eh.rb
|
66
72
|
- lib/quality_extensions/string/constantize.rb
|
67
73
|
- lib/quality_extensions/string/with_knowledge_of_color.rb
|
68
74
|
- lib/quality_extensions/string/shell_escape.rb
|
69
75
|
- lib/quality_extensions/string/each_char_with_index.rb
|
70
76
|
- lib/quality_extensions/string/digits_only.rb
|
77
|
+
- lib/quality_extensions/string/integer_eh.rb
|
71
78
|
- lib/quality_extensions/file_test/binary_file.rb
|
72
79
|
- lib/quality_extensions/color/gradiate.rb
|
73
80
|
- lib/quality_extensions/color/rgb.rb
|
81
|
+
- lib/quality_extensions/table.rb
|
82
|
+
- lib/quality_extensions/enumerable/select_bang.rb
|
83
|
+
- lib/quality_extensions/enumerable/all_same.rb
|
74
84
|
- lib/quality_extensions/enumerable/map_with_index.rb
|
85
|
+
- lib/quality_extensions/enumerable/group_by_and_map.rb
|
75
86
|
- lib/quality_extensions/enumerable/every.rb
|
76
87
|
- lib/quality_extensions/enumerable/select_until.rb
|
88
|
+
- lib/quality_extensions/enumerable/select_with_index.rb
|
77
89
|
- lib/quality_extensions/enumerable/select_while.rb
|
78
90
|
- lib/quality_extensions/regexp/rfc822.rb
|
79
91
|
- lib/quality_extensions/regexp/named_captures.rb
|
80
92
|
- lib/quality_extensions/regexp/join.rb
|
81
93
|
- lib/quality_extensions/all.rb
|
82
94
|
- lib/quality_extensions/safe_nil.rb
|
95
|
+
- lib/quality_extensions/matrix/linked_vectors.rb
|
96
|
+
- lib/quality_extensions/matrix/indexable.rb
|
83
97
|
- lib/quality_extensions/numeric/diff.rb
|
84
98
|
- lib/quality_extensions/time/all.rb
|
85
99
|
- lib/quality_extensions/time/deprecated.rb
|
@@ -87,10 +101,13 @@ files:
|
|
87
101
|
- lib/quality_extensions/test/assert_exception.rb
|
88
102
|
- lib/quality_extensions/test/assert_user_error.rb
|
89
103
|
- lib/quality_extensions/test/all.rb
|
104
|
+
- lib/quality_extensions/test/difference_highlighting-minitest.rb
|
90
105
|
- lib/quality_extensions/test/assert_includes.rb
|
91
106
|
- lib/quality_extensions/test/assert_anything.rb
|
107
|
+
- lib/quality_extensions/test/difference_highlighting-test_unit.rb
|
92
108
|
- lib/quality_extensions/test/difference_highlighting.rb
|
93
109
|
- lib/quality_extensions/chainable_safe_nil.rb
|
110
|
+
- lib/quality_extensions/timeout/countdown_timer.rb
|
94
111
|
- lib/quality_extensions/histogram.rb
|
95
112
|
- lib/quality_extensions/file/exact_match_regexp.rb
|
96
113
|
- lib/quality_extensions/object/send_if_not_nil.rb
|
@@ -102,20 +119,29 @@ files:
|
|
102
119
|
- lib/quality_extensions/object/ignore_access.rb
|
103
120
|
- lib/quality_extensions/object/if_else.rb
|
104
121
|
- lib/quality_extensions/object/mcall.rb
|
122
|
+
- lib/quality_extensions/object/non.rb
|
105
123
|
- lib/quality_extensions/object/send_if.rb
|
106
124
|
- lib/quality_extensions/pathname.rb
|
107
125
|
- lib/quality_extensions/find/select.rb
|
108
126
|
- lib/quality_extensions/dictable.rb
|
127
|
+
- lib/quality_extensions/template.rb_test_unit.rb
|
109
128
|
- lib/quality_extensions/inspect_with.rb
|
129
|
+
- lib/quality_extensions/vector/enumerable.rb
|
110
130
|
- lib/quality_extensions/array/classify.rb
|
111
|
-
- lib/quality_extensions/array/
|
131
|
+
- lib/quality_extensions/array/select_if_bang.rb
|
132
|
+
- lib/quality_extensions/array/justify.rb
|
112
133
|
- lib/quality_extensions/array/group_by.rb
|
113
134
|
- lib/quality_extensions/array/all.rb
|
135
|
+
- lib/quality_extensions/array/all_same.rb
|
114
136
|
- lib/quality_extensions/array/to_a_recursive.rb
|
115
137
|
- lib/quality_extensions/array/shell_escape.rb
|
116
138
|
- lib/quality_extensions/array/to_query_string.rb
|
139
|
+
- lib/quality_extensions/array/include_any_of.rb
|
140
|
+
- lib/quality_extensions/array/delete_if_bang.rb
|
117
141
|
- lib/quality_extensions/array/expand_ranges.rb
|
142
|
+
- lib/quality_extensions/array/mean.rb
|
118
143
|
- lib/quality_extensions/array/sequence.rb
|
144
|
+
- lib/quality_extensions/array/sum.rb
|
119
145
|
- lib/quality_extensions/module/alias_method.rb
|
120
146
|
- lib/quality_extensions/module/includable_once.rb
|
121
147
|
- lib/quality_extensions/module/bool_attr_accessor.rb
|
@@ -139,14 +165,18 @@ files:
|
|
139
165
|
- lib/quality_extensions/module/create_setter.rb
|
140
166
|
- lib/quality_extensions/fixnum/change_base.rb
|
141
167
|
- lib/quality_extensions/nil_method_missing.rb
|
168
|
+
- lib/quality_extensions/range_list.rb
|
142
169
|
- lib/quality_extensions/colored/toggleability.rb
|
143
170
|
- lib/quality_extensions/float/truncate.rb
|
144
171
|
- lib/quality_extensions/template.rb
|
172
|
+
- lib/Xfind_bug_test.rb
|
145
173
|
- lib/quality_extensions.rb
|
146
174
|
- test/all.rb
|
147
175
|
- Readme.rdoc
|
148
176
|
has_rdoc: true
|
149
177
|
homepage: http://quality-ext.rubyforge.org/
|
178
|
+
licenses: []
|
179
|
+
|
150
180
|
post_install_message:
|
151
181
|
rdoc_options:
|
152
182
|
- --title
|
@@ -171,9 +201,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
201
|
requirements: []
|
172
202
|
|
173
203
|
rubyforge_project: quality_extensions
|
174
|
-
rubygems_version: 1.3.
|
204
|
+
rubygems_version: 1.3.5
|
175
205
|
signing_key:
|
176
|
-
specification_version:
|
206
|
+
specification_version: 3
|
177
207
|
summary: A collection of reusable Ruby methods which are not (yet) in Facets.
|
178
208
|
test_files:
|
179
209
|
- test/all.rb
|