extlib 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of extlib might be problematic. Click here for more details.
- data/History.txt +22 -0
- data/LICENSE +1 -1
- data/README +0 -0
- data/Rakefile +17 -12
- data/lib/extlib.rb +1 -1
- data/lib/extlib/blank.rb +51 -21
- data/lib/extlib/boolean.rb +1 -1
- data/lib/extlib/class.rb +12 -12
- data/lib/extlib/datetime.rb +20 -2
- data/lib/extlib/dictionary.rb +2 -2
- data/lib/extlib/hash.rb +57 -34
- data/lib/extlib/inflection.rb +0 -1
- data/lib/extlib/lazy_array.rb +327 -36
- data/lib/extlib/logger.rb +8 -8
- data/lib/extlib/mash.rb +45 -45
- data/lib/extlib/module.rb +1 -1
- data/lib/extlib/nil.rb +1 -1
- data/lib/extlib/numeric.rb +1 -1
- data/lib/extlib/object.rb +8 -21
- data/lib/extlib/object_space.rb +3 -3
- data/lib/extlib/pathname.rb +10 -0
- data/lib/extlib/pooling.rb +9 -17
- data/lib/extlib/rubygems.rb +7 -7
- data/lib/extlib/simple_set.rb +35 -8
- data/lib/extlib/string.rb +85 -42
- data/lib/extlib/struct.rb +10 -1
- data/lib/extlib/symbol.rb +11 -7
- data/lib/extlib/time.rb +31 -9
- data/lib/extlib/version.rb +1 -1
- data/lib/extlib/virtual_file.rb +1 -1
- data/spec/blank_spec.rb +85 -0
- data/spec/class_spec.rb +141 -0
- data/spec/datetime_spec.rb +22 -0
- data/spec/hash_spec.rb +537 -0
- data/spec/hook_spec.rb +1198 -0
- data/spec/inflection/plural_spec.rb +564 -0
- data/spec/inflection/singular_spec.rb +497 -0
- data/spec/inflection_extras_spec.rb +93 -0
- data/spec/lazy_array_spec.rb +1869 -0
- data/spec/mash_spec.rb +286 -0
- data/spec/module_spec.rb +58 -0
- data/spec/object_space_spec.rb +9 -0
- data/spec/object_spec.rb +114 -0
- data/spec/pooling_spec.rb +499 -0
- data/spec/simple_set_spec.rb +57 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/string_spec.rb +220 -0
- data/spec/struct_spec.rb +12 -0
- data/spec/symbol_spec.rb +8 -0
- data/spec/time_spec.rb +22 -0
- data/spec/try_dup_spec.rb +45 -0
- data/spec/virtual_file_spec.rb +21 -0
- metadata +51 -26
- data/README.txt +0 -3
@@ -0,0 +1,564 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Extlib::Inflection, "#singular" do
|
4
|
+
it "pluralizes equipment => equipment" do
|
5
|
+
"equipment".plural.should == "equipment"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "pluralizes information => information" do
|
9
|
+
"information".plural.should == "information"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "pluralizes money => money" do
|
13
|
+
"money".plural.should == "money"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "pluralizes species => species" do
|
17
|
+
"species".plural.should == "species"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "pluralizes series => series" do
|
21
|
+
"series".plural.should == "series"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "pluralizes fish => fish" do
|
25
|
+
"fish".plural.should == "fish"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "pluralizes sheep => sheep" do
|
29
|
+
"sheep".plural.should == "sheep"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "pluralizes news => news" do
|
33
|
+
"news".plural.should == "news"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "pluralizes rain => rain" do
|
37
|
+
"rain".plural.should == "rain"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "pluralizes milk => milk" do
|
41
|
+
"milk".plural.should == "milk"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "pluralizes moose => moose" do
|
45
|
+
"moose".plural.should == "moose"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "pluralizes hovercraft => hovercraft" do
|
49
|
+
"hovercraft".plural.should == "hovercraft"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "pluralizes cacti => cactus" do
|
53
|
+
"cactus".plural.should == "cacti"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "pluralizes thesaurus => thesauri" do
|
57
|
+
"thesaurus".plural.should == "thesauri"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "pluralizes matrix => matrices" do
|
61
|
+
"matrix".plural.should == "matrices"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "pluralizes Swiss => Swiss" do
|
65
|
+
"Swiss".plural.should == "Swiss"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "pluralizes life => lives" do
|
69
|
+
"life".plural.should == "lives"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "pluralizes wife => wives" do
|
73
|
+
"wife".plural.should == "wives"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "pluralizes goose => geese" do
|
77
|
+
"goose".plural.should == "geese"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "pluralizes criterion => criteria" do
|
81
|
+
"criterion".plural.should == "criteria"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "pluralizes alias => aliases" do
|
85
|
+
"alias".plural.should == "aliases"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "pluralizes status => statuses" do
|
89
|
+
"status".plural.should == "statuses"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "pluralizes axis => axes" do
|
93
|
+
"axis".plural.should == "axes"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "pluralizes crisis => crises" do
|
97
|
+
"crisis".plural.should == "crises"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "pluralizes testis => testes" do
|
101
|
+
"testis".plural.should == "testes"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "pluralizes child => children" do
|
105
|
+
"child".plural.should == "children"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "pluralizes person => people" do
|
109
|
+
"person".plural.should == "people"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "pluralizes potato => potatoes" do
|
113
|
+
"potato".plural.should == "potatoes"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "pluralizes tomato => tomatoes" do
|
117
|
+
"tomato".plural.should == "tomatoes"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "pluralizes buffalo => buffaloes" do
|
121
|
+
"buffalo".plural.should == "buffaloes"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "pluralizes torpedo => torpedoes" do
|
125
|
+
"torpedo".plural.should == "torpedoes"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "pluralizes quiz => quizzes" do
|
129
|
+
"quiz".plural.should == "quizzes"
|
130
|
+
end
|
131
|
+
|
132
|
+
# used to be a bug exposed by this specs suite,
|
133
|
+
# this MUST pass or we've got regression
|
134
|
+
it "pluralizes vertex => vertices" do
|
135
|
+
"vertex".plural.should == "vertices"
|
136
|
+
end
|
137
|
+
|
138
|
+
it "pluralizes index => indices" do
|
139
|
+
"index".plural.should == "indices"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "pluralizes ox => oxen" do
|
143
|
+
"ox".plural.should == "oxen"
|
144
|
+
end
|
145
|
+
|
146
|
+
it "pluralizes mouse => mice" do
|
147
|
+
"mouse".plural.should == "mice"
|
148
|
+
end
|
149
|
+
|
150
|
+
it "pluralizes louse => lice" do
|
151
|
+
"louse".plural.should == "lice"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "pluralizes thesis => theses" do
|
155
|
+
"thesis".plural.should == "theses"
|
156
|
+
end
|
157
|
+
|
158
|
+
it "pluralizes thief => thieves" do
|
159
|
+
"thief".plural.should == "thieves"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "pluralizes analysis => analyses" do
|
163
|
+
"analysis".plural.should == "analyses"
|
164
|
+
end
|
165
|
+
|
166
|
+
it "pluralizes octopus => octopi" do
|
167
|
+
"octopus".plural.should == "octopi"
|
168
|
+
end
|
169
|
+
|
170
|
+
it "pluralizes grass => grass" do
|
171
|
+
"grass".plural.should == "grass"
|
172
|
+
end
|
173
|
+
|
174
|
+
it "pluralizes phenomenon => phenomena" do
|
175
|
+
"phenomenon".plural.should == "phenomena"
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
# ==== bugs, typos and reported issues
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
# ==== rules and most common cases
|
189
|
+
|
190
|
+
it "pluralizes forum => forums" do
|
191
|
+
"forum".plural.should == "forums"
|
192
|
+
end
|
193
|
+
|
194
|
+
it "pluralizes hive => hives" do
|
195
|
+
"hive".plural.should == "hives"
|
196
|
+
end
|
197
|
+
|
198
|
+
it "pluralizes athlete => athletes" do
|
199
|
+
"athlete".plural.should == "athletes"
|
200
|
+
end
|
201
|
+
|
202
|
+
it "pluralizes dwarf => dwarves" do
|
203
|
+
"dwarf".plural.should == "dwarves"
|
204
|
+
end
|
205
|
+
|
206
|
+
it "pluralizes hero => heroes" do
|
207
|
+
"hero".plural.should == "heroes"
|
208
|
+
end
|
209
|
+
|
210
|
+
it "pluralizes zero => zeroes" do
|
211
|
+
"zero".plural.should == "zeroes"
|
212
|
+
end
|
213
|
+
|
214
|
+
it "pluralizes man => men" do
|
215
|
+
"man".plural.should == "men"
|
216
|
+
end
|
217
|
+
|
218
|
+
it "pluralizes woman => women" do
|
219
|
+
"woman".plural.should == "women"
|
220
|
+
end
|
221
|
+
|
222
|
+
it "pluralizes sportsman => sportsmen" do
|
223
|
+
"sportsman".plural.should == "sportsmen"
|
224
|
+
end
|
225
|
+
|
226
|
+
it "pluralizes branch => branches" do
|
227
|
+
"branch".plural.should == "branches"
|
228
|
+
end
|
229
|
+
|
230
|
+
it "pluralizes crunch => crunches" do
|
231
|
+
"crunch".plural.should == "crunches"
|
232
|
+
end
|
233
|
+
|
234
|
+
it "pluralizes trash => trashes" do
|
235
|
+
"trash".plural.should == "trashes"
|
236
|
+
end
|
237
|
+
|
238
|
+
it "pluralizes mash => mashes" do
|
239
|
+
"mash".plural.should == "mashes"
|
240
|
+
end
|
241
|
+
|
242
|
+
it "pluralizes cross => crosses" do
|
243
|
+
"cross".plural.should == "crosses"
|
244
|
+
end
|
245
|
+
|
246
|
+
it "pluralizes erratum => errata" do
|
247
|
+
"erratum".plural.should == "errata"
|
248
|
+
end
|
249
|
+
|
250
|
+
# FIXME: add -ia => -ium cases
|
251
|
+
|
252
|
+
# FIXME: add -ra => -rum cases
|
253
|
+
|
254
|
+
it "pluralizes ray => rays" do
|
255
|
+
"ray".plural.should == "rays"
|
256
|
+
end
|
257
|
+
|
258
|
+
it "pluralizes spray => sprays" do
|
259
|
+
"spray".plural.should == "sprays"
|
260
|
+
end
|
261
|
+
|
262
|
+
# Merriam-Webster dictionary says
|
263
|
+
# preys is correct, too.
|
264
|
+
it "pluralizes prey => preys" do
|
265
|
+
"prey".plural.should == "preys"
|
266
|
+
end
|
267
|
+
|
268
|
+
it "pluralizes toy => toys" do
|
269
|
+
"toy".plural.should == "toys"
|
270
|
+
end
|
271
|
+
|
272
|
+
it "pluralizes joy => joys" do
|
273
|
+
"joy".plural.should == "joys"
|
274
|
+
end
|
275
|
+
|
276
|
+
it "pluralizes buy => buys" do
|
277
|
+
"buy".plural.should == "buys"
|
278
|
+
end
|
279
|
+
|
280
|
+
it "pluralizes guy => guys" do
|
281
|
+
"guy".plural.should == "guys"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "pluralizes cry => cries" do
|
285
|
+
"cry".plural.should == "cries"
|
286
|
+
end
|
287
|
+
|
288
|
+
it "pluralizes fly => flies" do
|
289
|
+
"fly".plural.should == "flies"
|
290
|
+
end
|
291
|
+
|
292
|
+
it "pluralizes fox => foxes" do
|
293
|
+
"fox".plural.should == "foxes"
|
294
|
+
end
|
295
|
+
|
296
|
+
it "pluralizes elf => elves" do
|
297
|
+
"elf".plural.should == "elves"
|
298
|
+
end
|
299
|
+
|
300
|
+
it "pluralizes shelf => shelves" do
|
301
|
+
"shelf".plural.should == "shelves"
|
302
|
+
end
|
303
|
+
|
304
|
+
it "pluralizes plus => plusses" do
|
305
|
+
"plus".plural.should == "plusses"
|
306
|
+
end
|
307
|
+
|
308
|
+
it "pluralizes cat => cats" do
|
309
|
+
"cat".plural.should == "cats"
|
310
|
+
end
|
311
|
+
|
312
|
+
it "pluralizes rat => rats" do
|
313
|
+
"rat".plural.should == "rats"
|
314
|
+
end
|
315
|
+
|
316
|
+
it "pluralizes rose => roses" do
|
317
|
+
"rose".plural.should == "roses"
|
318
|
+
end
|
319
|
+
|
320
|
+
it "pluralizes project => projects" do
|
321
|
+
"project".plural.should == "projects"
|
322
|
+
end
|
323
|
+
|
324
|
+
it "pluralizes post => posts" do
|
325
|
+
"post".plural.should == "posts"
|
326
|
+
end
|
327
|
+
|
328
|
+
it "pluralizes article => articles" do
|
329
|
+
"article".plural.should == "articles"
|
330
|
+
end
|
331
|
+
|
332
|
+
it "pluralizes location => locations" do
|
333
|
+
"location".plural.should == "locations"
|
334
|
+
end
|
335
|
+
|
336
|
+
it "pluralizes friend => friends" do
|
337
|
+
"friend".plural.should == "friends"
|
338
|
+
end
|
339
|
+
|
340
|
+
it "pluralizes link => links" do
|
341
|
+
"link".plural.should == "links"
|
342
|
+
end
|
343
|
+
|
344
|
+
it "pluralizes url => urls" do
|
345
|
+
"url".plural.should == "urls"
|
346
|
+
end
|
347
|
+
|
348
|
+
it "pluralizes account => accounts" do
|
349
|
+
"account".plural.should == "accounts"
|
350
|
+
end
|
351
|
+
|
352
|
+
it "pluralizes server => servers" do
|
353
|
+
"server".plural.should == "servers"
|
354
|
+
end
|
355
|
+
|
356
|
+
it "pluralizes fruit => fruits" do
|
357
|
+
"fruit".plural.should == "fruits"
|
358
|
+
end
|
359
|
+
|
360
|
+
it "pluralizes map => maps" do
|
361
|
+
"map".plural.should == "maps"
|
362
|
+
end
|
363
|
+
|
364
|
+
it "pluralizes income => incomes" do
|
365
|
+
"income".plural.should == "incomes"
|
366
|
+
end
|
367
|
+
|
368
|
+
it "pluralizes ping => pings" do
|
369
|
+
"ping".plural.should == "pings"
|
370
|
+
end
|
371
|
+
|
372
|
+
it "pluralizes event => events" do
|
373
|
+
"event".plural.should == "events"
|
374
|
+
end
|
375
|
+
|
376
|
+
it "pluralizes proof => proofs" do
|
377
|
+
"proof".plural.should == "proofs"
|
378
|
+
end
|
379
|
+
|
380
|
+
it "pluralizes typo => typos" do
|
381
|
+
"typo".plural.should == "typos"
|
382
|
+
end
|
383
|
+
|
384
|
+
it "pluralizes attachment => attachments" do
|
385
|
+
"attachment".plural.should == "attachments"
|
386
|
+
end
|
387
|
+
|
388
|
+
it "pluralizes download => downloads" do
|
389
|
+
"download".plural.should == "downloads"
|
390
|
+
end
|
391
|
+
|
392
|
+
it "pluralizes asset => assets" do
|
393
|
+
"asset".plural.should == "assets"
|
394
|
+
end
|
395
|
+
|
396
|
+
it "pluralizes job => jobs" do
|
397
|
+
"job".plural.should == "jobs"
|
398
|
+
end
|
399
|
+
|
400
|
+
it "pluralizes city => cities" do
|
401
|
+
"city".plural.should == "cities"
|
402
|
+
end
|
403
|
+
|
404
|
+
it "pluralizes package => packages" do
|
405
|
+
"package".plural.should == "packages"
|
406
|
+
end
|
407
|
+
|
408
|
+
it "pluralizes commit => commits" do
|
409
|
+
"commit".plural.should == "commits"
|
410
|
+
end
|
411
|
+
|
412
|
+
it "pluralizes version => versions" do
|
413
|
+
"version".plural.should == "versions"
|
414
|
+
end
|
415
|
+
|
416
|
+
it "pluralizes document => documents" do
|
417
|
+
"document".plural.should == "documents"
|
418
|
+
end
|
419
|
+
|
420
|
+
it "pluralizes edition => editions" do
|
421
|
+
"edition".plural.should == "editions"
|
422
|
+
end
|
423
|
+
|
424
|
+
it "pluralizes movie => movies" do
|
425
|
+
"movie".plural.should == "movies"
|
426
|
+
end
|
427
|
+
|
428
|
+
it "pluralizes song => songs" do
|
429
|
+
"song".plural.should == "songs"
|
430
|
+
end
|
431
|
+
|
432
|
+
it "pluralizes invoice => invoices" do
|
433
|
+
"invoice".plural.should == "invoices"
|
434
|
+
end
|
435
|
+
|
436
|
+
it "pluralizes product => products" do
|
437
|
+
"product".plural.should == "products"
|
438
|
+
end
|
439
|
+
|
440
|
+
it "pluralizes book => books" do
|
441
|
+
"book".plural.should == "books"
|
442
|
+
end
|
443
|
+
|
444
|
+
it "pluralizes ticket => tickets" do
|
445
|
+
"ticket".plural.should == "tickets"
|
446
|
+
end
|
447
|
+
|
448
|
+
it "pluralizes game => games" do
|
449
|
+
"game".plural.should == "games"
|
450
|
+
end
|
451
|
+
|
452
|
+
it "pluralizes tournament => tournaments" do
|
453
|
+
"tournament".plural.should == "tournaments"
|
454
|
+
end
|
455
|
+
|
456
|
+
it "pluralizes prize => prizes" do
|
457
|
+
"prize".plural.should == "prizes"
|
458
|
+
end
|
459
|
+
|
460
|
+
it "pluralizes price => prices" do
|
461
|
+
"price".plural.should == "prices"
|
462
|
+
end
|
463
|
+
|
464
|
+
it "pluralizes installation => installations" do
|
465
|
+
"installation".plural.should == "installations"
|
466
|
+
end
|
467
|
+
|
468
|
+
it "pluralizes date => dates" do
|
469
|
+
"date".plural.should == "dates"
|
470
|
+
end
|
471
|
+
|
472
|
+
it "pluralizes schedule => schedules" do
|
473
|
+
"schedule".plural.should == "schedules"
|
474
|
+
end
|
475
|
+
|
476
|
+
it "pluralizes arena => arenas" do
|
477
|
+
"arena".plural.should == "arenas"
|
478
|
+
end
|
479
|
+
|
480
|
+
it "pluralizes spam => spams" do
|
481
|
+
"spam".plural.should == "spams"
|
482
|
+
end
|
483
|
+
|
484
|
+
it "pluralizes bus => buses" do
|
485
|
+
"bus".plural.should == "buses"
|
486
|
+
end
|
487
|
+
|
488
|
+
it "pluralizes rice => rice" do
|
489
|
+
"rice".plural.should == "rice"
|
490
|
+
end
|
491
|
+
|
492
|
+
# Some specs from Rails
|
493
|
+
SingularToPlural = {
|
494
|
+
"search" => "searches",
|
495
|
+
"switch" => "switches",
|
496
|
+
"fix" => "fixes",
|
497
|
+
"box" => "boxes",
|
498
|
+
"process" => "processes",
|
499
|
+
"address" => "addresses",
|
500
|
+
"case" => "cases",
|
501
|
+
"stack" => "stacks",
|
502
|
+
"wish" => "wishes",
|
503
|
+
|
504
|
+
"category" => "categories",
|
505
|
+
"query" => "queries",
|
506
|
+
"ability" => "abilities",
|
507
|
+
"agency" => "agencies",
|
508
|
+
|
509
|
+
"archive" => "archives",
|
510
|
+
|
511
|
+
"safe" => "saves",
|
512
|
+
"half" => "halves",
|
513
|
+
|
514
|
+
"move" => "moves",
|
515
|
+
|
516
|
+
"salesperson" => "salespeople",
|
517
|
+
|
518
|
+
"spokesman" => "spokesmen",
|
519
|
+
|
520
|
+
"basis" => "bases",
|
521
|
+
"diagnosis" => "diagnoses",
|
522
|
+
"diagnosis_a" => "diagnosis_as",
|
523
|
+
|
524
|
+
"datum" => "data",
|
525
|
+
"medium" => "media",
|
526
|
+
|
527
|
+
"node_child" => "node_children",
|
528
|
+
|
529
|
+
"experience" => "experiences",
|
530
|
+
"day" => "days",
|
531
|
+
|
532
|
+
"comment" => "comments",
|
533
|
+
"foobar" => "foobars",
|
534
|
+
"newsletter" => "newsletters",
|
535
|
+
|
536
|
+
"old_news" => "old_news",
|
537
|
+
|
538
|
+
"perspective" => "perspectives",
|
539
|
+
|
540
|
+
"photo" => "photos",
|
541
|
+
"status_code" => "status_codes",
|
542
|
+
|
543
|
+
"house" => "houses",
|
544
|
+
"virus" => "viruses",
|
545
|
+
"portfolio" => "portfolios",
|
546
|
+
|
547
|
+
"matrix_fu" => "matrix_fus",
|
548
|
+
|
549
|
+
"axis" => "axes",
|
550
|
+
|
551
|
+
"shoe" => "shoes",
|
552
|
+
|
553
|
+
"horse" => "horses",
|
554
|
+
"edge" => "edges",
|
555
|
+
|
556
|
+
"cow" => "cows" # 'kine' is archaic and nobody uses it
|
557
|
+
}
|
558
|
+
|
559
|
+
SingularToPlural.each do |single_word, plural_word|
|
560
|
+
it "pluralizes #{single_word} => #{plural_word}" do
|
561
|
+
single_word.plural.should == plural_word
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|