clean_words 0.0.1
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 +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +2 -0
- data/clean_words.gemspec +24 -0
- data/data/words.txt +550 -0
- data/lib/clean_words.rb +45 -0
- data/lib/clean_words/version.rb +3 -0
- data/spec/clean_words_spec.rb +49 -0
- data/spec/spec_helper.rb +4 -0
- data/util/sanitize_list.rb +4 -0
- data/util/word_list_sanitizer.rb +23 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e21a8e581c088c6134cc3c12d99489e381cdec9f
|
4
|
+
data.tar.gz: 26940772316a30e2b53c06514018e2621b53b137
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9fc0620b64bea23d547f5462b38ac2dd79f9b303a268a59aef7e1523ef47013d98c9aef8d4719ace74b1b2a0a2837b51cf3945533abdbcc4e6c900f2f7fad47c
|
7
|
+
data.tar.gz: a2b0d728e53bda18a18e73d626d4a0e0580accf44a73fec75bcbc3cc0e5c700a20bca1abd626b73f767df8f663a8a52be2949326249dec9ecbef722aac9d1c28
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Foraker
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jake Sutton
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# CleanWords
|
2
|
+
|
3
|
+
A clean (i.e. "kid friendly") random word generator.
|
4
|
+
|
5
|
+
Currently the word list varies in size from 4 to 12 letters in length and consists mostly of words for animals, food, plants, and buildings.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'clean_words'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install clean_words
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```Ruby
|
26
|
+
words = CleanWords::Random.new
|
27
|
+
|
28
|
+
# Fetch a random word
|
29
|
+
words.fetch
|
30
|
+
#=> 'aspen'
|
31
|
+
|
32
|
+
# Fetch a number of random words
|
33
|
+
words.fetch(nil, 3)
|
34
|
+
#=> ['aspen', 'terrier', 'apple']
|
35
|
+
|
36
|
+
# Fetch a random word of a particular size
|
37
|
+
words.fetch(6)
|
38
|
+
#=> 'arctic'
|
39
|
+
|
40
|
+
# Fetch random words of an array of sizes
|
41
|
+
words.fetch([4,6], 2)
|
42
|
+
#=> ['arctic', 'fort']
|
43
|
+
|
44
|
+
# Fetch random words of a range of sizes
|
45
|
+
words.fetch((4..6), 4)
|
46
|
+
#=> ['fort', 'gopher', 'arctic', 'maple']
|
47
|
+
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/foraker/clean_words/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
- NOTE: If adding words to `data/words.txt`, please execute `ruby util/sanitize_list.rb` from the project root before commiting.
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/clean_words.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'clean_words/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "clean_words"
|
8
|
+
spec.version = CleanWords::VERSION
|
9
|
+
spec.authors = ["Jake Sutton"]
|
10
|
+
spec.email = ["jcs@foraker.com"]
|
11
|
+
spec.summary = %q{A clean (i.e. "kid friendly") random word generator.}
|
12
|
+
spec.description = %q{A random word generator featuring only words that would not be considered inappropriate for children of all ages.}
|
13
|
+
spec.homepage = "http://foraker.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
24
|
+
end
|
data/data/words.txt
ADDED
@@ -0,0 +1,550 @@
|
|
1
|
+
aardvark
|
2
|
+
abalone
|
3
|
+
abbey
|
4
|
+
acorn
|
5
|
+
aircraft
|
6
|
+
airport
|
7
|
+
albacore
|
8
|
+
albatross
|
9
|
+
alfalfa
|
10
|
+
algae
|
11
|
+
alligator
|
12
|
+
almond
|
13
|
+
alpaca
|
14
|
+
amoeba
|
15
|
+
amphibian
|
16
|
+
angelfish
|
17
|
+
animal
|
18
|
+
anteater
|
19
|
+
antelope
|
20
|
+
apartment
|
21
|
+
apple
|
22
|
+
applesauce
|
23
|
+
aqueduct
|
24
|
+
arachnid
|
25
|
+
arch
|
26
|
+
arctic
|
27
|
+
arena
|
28
|
+
armadillo
|
29
|
+
artichoke
|
30
|
+
arugala
|
31
|
+
asparagus
|
32
|
+
aspen
|
33
|
+
assembly
|
34
|
+
avocado
|
35
|
+
baboon
|
36
|
+
bacon
|
37
|
+
badger
|
38
|
+
bagel
|
39
|
+
bandicoot
|
40
|
+
barley
|
41
|
+
barn
|
42
|
+
barnacle
|
43
|
+
barracks
|
44
|
+
barracuda
|
45
|
+
bass
|
46
|
+
basset
|
47
|
+
beach
|
48
|
+
beagle
|
49
|
+
beans
|
50
|
+
bear
|
51
|
+
beetle
|
52
|
+
beluga
|
53
|
+
bighorn
|
54
|
+
bird
|
55
|
+
bison
|
56
|
+
bisque
|
57
|
+
bivalve
|
58
|
+
blackbird
|
59
|
+
bloodhound
|
60
|
+
blowfish
|
61
|
+
bluebird
|
62
|
+
bluefin
|
63
|
+
boathouse
|
64
|
+
bobcat
|
65
|
+
bongo
|
66
|
+
bonobo
|
67
|
+
border
|
68
|
+
bowhead
|
69
|
+
bowling
|
70
|
+
boxer
|
71
|
+
bread
|
72
|
+
bridge
|
73
|
+
brittle
|
74
|
+
broccoli
|
75
|
+
brown
|
76
|
+
brownstone
|
77
|
+
buffalo
|
78
|
+
building
|
79
|
+
bulldog
|
80
|
+
bullfrog
|
81
|
+
bumblebee
|
82
|
+
bungalow
|
83
|
+
bunkhouse
|
84
|
+
buritto
|
85
|
+
butterfly
|
86
|
+
cabana
|
87
|
+
cabbage
|
88
|
+
cabin
|
89
|
+
caiman
|
90
|
+
cake
|
91
|
+
camel
|
92
|
+
canary
|
93
|
+
capitol
|
94
|
+
cardinal
|
95
|
+
caribou
|
96
|
+
carport
|
97
|
+
carrot
|
98
|
+
castle
|
99
|
+
catamount
|
100
|
+
caterpillar
|
101
|
+
catfish
|
102
|
+
cathedral
|
103
|
+
cattle
|
104
|
+
cedar
|
105
|
+
celery
|
106
|
+
centipede
|
107
|
+
cereal
|
108
|
+
chalet
|
109
|
+
chameleon
|
110
|
+
chapel
|
111
|
+
cheese
|
112
|
+
cheetah
|
113
|
+
chickadee
|
114
|
+
chicken
|
115
|
+
chihuahua
|
116
|
+
chinchilla
|
117
|
+
chipmunk
|
118
|
+
chips
|
119
|
+
chocolate
|
120
|
+
chowder
|
121
|
+
church
|
122
|
+
cicada
|
123
|
+
cinema
|
124
|
+
clownfish
|
125
|
+
clubhouse
|
126
|
+
cobra
|
127
|
+
coffee
|
128
|
+
college
|
129
|
+
collie
|
130
|
+
compound
|
131
|
+
concert
|
132
|
+
conch
|
133
|
+
condominium
|
134
|
+
conservatory
|
135
|
+
cookie
|
136
|
+
coral
|
137
|
+
corn
|
138
|
+
cottage
|
139
|
+
cougar
|
140
|
+
coyote
|
141
|
+
crab
|
142
|
+
crane
|
143
|
+
crayfish
|
144
|
+
cricket
|
145
|
+
crocodile
|
146
|
+
crow
|
147
|
+
cupcake
|
148
|
+
curry
|
149
|
+
cuttlefish
|
150
|
+
cutworm
|
151
|
+
dalmatian
|
152
|
+
dates
|
153
|
+
deer
|
154
|
+
depot
|
155
|
+
diatom
|
156
|
+
dingo
|
157
|
+
dinosaur
|
158
|
+
doberman
|
159
|
+
dodo
|
160
|
+
dogfish
|
161
|
+
dolphin
|
162
|
+
dome
|
163
|
+
donkey
|
164
|
+
donut
|
165
|
+
dormitory
|
166
|
+
double
|
167
|
+
dove
|
168
|
+
downy
|
169
|
+
dragon
|
170
|
+
dragonfly
|
171
|
+
dromedary
|
172
|
+
duck
|
173
|
+
dugong
|
174
|
+
dumpling
|
175
|
+
duplex
|
176
|
+
dwelling
|
177
|
+
eagle
|
178
|
+
earthworm
|
179
|
+
earwig
|
180
|
+
eastern
|
181
|
+
egret
|
182
|
+
electric
|
183
|
+
elephant
|
184
|
+
embassy
|
185
|
+
emerald
|
186
|
+
emperor
|
187
|
+
ermine
|
188
|
+
exposition
|
189
|
+
factory
|
190
|
+
falcon
|
191
|
+
farm
|
192
|
+
farmhouse
|
193
|
+
ferret
|
194
|
+
finch
|
195
|
+
firefly
|
196
|
+
firehouse
|
197
|
+
fish
|
198
|
+
flamingo
|
199
|
+
flea
|
200
|
+
flightless
|
201
|
+
flounder
|
202
|
+
flower
|
203
|
+
flying
|
204
|
+
forest
|
205
|
+
forge
|
206
|
+
fort
|
207
|
+
fortress
|
208
|
+
foundry
|
209
|
+
fowl
|
210
|
+
frilled
|
211
|
+
frog
|
212
|
+
fruit
|
213
|
+
gallery
|
214
|
+
garage
|
215
|
+
garlic
|
216
|
+
gazebo
|
217
|
+
gazelle
|
218
|
+
gecko
|
219
|
+
gerbil
|
220
|
+
giant
|
221
|
+
gibbon
|
222
|
+
giraffe
|
223
|
+
gnat
|
224
|
+
gnocchi
|
225
|
+
goat
|
226
|
+
golden
|
227
|
+
goldfinch
|
228
|
+
goldfish
|
229
|
+
goose
|
230
|
+
gopher
|
231
|
+
gorilla
|
232
|
+
granary
|
233
|
+
granola
|
234
|
+
grape
|
235
|
+
grapes
|
236
|
+
grasshopper
|
237
|
+
great
|
238
|
+
green
|
239
|
+
greenhouse
|
240
|
+
greyhound
|
241
|
+
groundhog
|
242
|
+
grouper
|
243
|
+
grouse
|
244
|
+
guinea
|
245
|
+
gull
|
246
|
+
gumbo
|
247
|
+
gymnasium
|
248
|
+
halibut
|
249
|
+
hall
|
250
|
+
hamburger
|
251
|
+
hammerhead
|
252
|
+
hamster
|
253
|
+
hangar
|
254
|
+
hare
|
255
|
+
harlequin
|
256
|
+
hawk
|
257
|
+
headquarters
|
258
|
+
hedgehog
|
259
|
+
heron
|
260
|
+
herring
|
261
|
+
hickory
|
262
|
+
highland
|
263
|
+
honey
|
264
|
+
hornet
|
265
|
+
horse
|
266
|
+
horseshoe
|
267
|
+
hospital
|
268
|
+
hotel
|
269
|
+
hound
|
270
|
+
house
|
271
|
+
houseboat
|
272
|
+
howler
|
273
|
+
human
|
274
|
+
hummingbird
|
275
|
+
hyena
|
276
|
+
igloo
|
277
|
+
iguana
|
278
|
+
impala
|
279
|
+
insect
|
280
|
+
jaguar
|
281
|
+
jelly
|
282
|
+
jellyfish
|
283
|
+
joey
|
284
|
+
juice
|
285
|
+
junebug
|
286
|
+
kabobs
|
287
|
+
kale
|
288
|
+
kangaroo
|
289
|
+
ketchup
|
290
|
+
kidney
|
291
|
+
kiosk
|
292
|
+
kiwi
|
293
|
+
koala
|
294
|
+
laboratory
|
295
|
+
ladybug
|
296
|
+
lamb
|
297
|
+
larva
|
298
|
+
lasagna
|
299
|
+
laurel
|
300
|
+
lemming
|
301
|
+
lemon
|
302
|
+
lemur
|
303
|
+
leopard
|
304
|
+
library
|
305
|
+
lighthouse
|
306
|
+
lightning
|
307
|
+
lilac
|
308
|
+
linguine
|
309
|
+
lion
|
310
|
+
lizard
|
311
|
+
llama
|
312
|
+
lobster
|
313
|
+
locust
|
314
|
+
lodge
|
315
|
+
longhorn
|
316
|
+
loon
|
317
|
+
loris
|
318
|
+
luminous
|
319
|
+
lynx
|
320
|
+
macaw
|
321
|
+
mackerel
|
322
|
+
magnolia
|
323
|
+
mako
|
324
|
+
malamute
|
325
|
+
mall
|
326
|
+
mallard
|
327
|
+
mamba
|
328
|
+
mammal
|
329
|
+
mammoth
|
330
|
+
manor
|
331
|
+
manse
|
332
|
+
mansion
|
333
|
+
manta
|
334
|
+
mantid
|
335
|
+
mantis
|
336
|
+
maple
|
337
|
+
marbled
|
338
|
+
marina
|
339
|
+
marine
|
340
|
+
market
|
341
|
+
marmoset
|
342
|
+
marmot
|
343
|
+
marsupial
|
344
|
+
mastiff
|
345
|
+
mastodon
|
346
|
+
meadowlark
|
347
|
+
meerkat
|
348
|
+
meeting
|
349
|
+
mice
|
350
|
+
midge
|
351
|
+
migrate
|
352
|
+
milk
|
353
|
+
milkshake
|
354
|
+
mill
|
355
|
+
millipede
|
356
|
+
minaret
|
357
|
+
mink
|
358
|
+
minnow
|
359
|
+
mobile
|
360
|
+
moccasin
|
361
|
+
mockingbird
|
362
|
+
mole
|
363
|
+
mollusk
|
364
|
+
monarch
|
365
|
+
monastery
|
366
|
+
mongoose
|
367
|
+
monitor
|
368
|
+
monkey
|
369
|
+
monument
|
370
|
+
moose
|
371
|
+
moray
|
372
|
+
mosque
|
373
|
+
mosquito
|
374
|
+
motel
|
375
|
+
moth
|
376
|
+
mountain
|
377
|
+
mouse
|
378
|
+
muffin
|
379
|
+
museum
|
380
|
+
mussels
|
381
|
+
narwhal
|
382
|
+
nautilus
|
383
|
+
nest
|
384
|
+
newt
|
385
|
+
nightingale
|
386
|
+
noodles
|
387
|
+
northern
|
388
|
+
nurse
|
389
|
+
nymph
|
390
|
+
observatory
|
391
|
+
ocelot
|
392
|
+
octopus
|
393
|
+
office
|
394
|
+
opera
|
395
|
+
opossum
|
396
|
+
orangutan
|
397
|
+
oriole
|
398
|
+
ostrich
|
399
|
+
otter
|
400
|
+
painted
|
401
|
+
palace
|
402
|
+
pancake
|
403
|
+
panda
|
404
|
+
panther
|
405
|
+
parakeet
|
406
|
+
parking
|
407
|
+
parrot
|
408
|
+
pavilion
|
409
|
+
pelican
|
410
|
+
penguin
|
411
|
+
pigeon
|
412
|
+
pika
|
413
|
+
pine
|
414
|
+
pizza
|
415
|
+
plankton
|
416
|
+
plant
|
417
|
+
platypus
|
418
|
+
polar
|
419
|
+
poodle
|
420
|
+
porcupine
|
421
|
+
porpoise
|
422
|
+
prairie
|
423
|
+
puffin
|
424
|
+
puma
|
425
|
+
pyramid
|
426
|
+
python
|
427
|
+
quail
|
428
|
+
queen
|
429
|
+
quiche
|
430
|
+
rabbit
|
431
|
+
raccoon
|
432
|
+
racer
|
433
|
+
railway
|
434
|
+
ranch
|
435
|
+
reindeer
|
436
|
+
reptile
|
437
|
+
residence
|
438
|
+
restaurant
|
439
|
+
retriever
|
440
|
+
reuben
|
441
|
+
river
|
442
|
+
roach
|
443
|
+
roadrunner
|
444
|
+
robin
|
445
|
+
rodent
|
446
|
+
rooster
|
447
|
+
sailfish
|
448
|
+
salamander
|
449
|
+
salmon
|
450
|
+
scallop
|
451
|
+
scarlet
|
452
|
+
school
|
453
|
+
seahorse
|
454
|
+
seal
|
455
|
+
sealion
|
456
|
+
shack
|
457
|
+
shark
|
458
|
+
shed
|
459
|
+
sheep
|
460
|
+
sheepdog
|
461
|
+
shelter
|
462
|
+
shepherd
|
463
|
+
shopping
|
464
|
+
shrew
|
465
|
+
shrine
|
466
|
+
skating
|
467
|
+
skink
|
468
|
+
skipper
|
469
|
+
skunk
|
470
|
+
skyscraper
|
471
|
+
skyway
|
472
|
+
snail
|
473
|
+
snake
|
474
|
+
snapper
|
475
|
+
snapping
|
476
|
+
snow
|
477
|
+
spaghetti
|
478
|
+
spaniel
|
479
|
+
sparrow
|
480
|
+
spider
|
481
|
+
spinach
|
482
|
+
spiny
|
483
|
+
spire
|
484
|
+
sponge
|
485
|
+
spotted
|
486
|
+
squash
|
487
|
+
squid
|
488
|
+
squirrel
|
489
|
+
stable
|
490
|
+
stadium
|
491
|
+
starfish
|
492
|
+
starling
|
493
|
+
state
|
494
|
+
station
|
495
|
+
stingray
|
496
|
+
store
|
497
|
+
stork
|
498
|
+
strider
|
499
|
+
structure
|
500
|
+
studio
|
501
|
+
sunfish
|
502
|
+
supermarket
|
503
|
+
swan
|
504
|
+
swift
|
505
|
+
swordfish
|
506
|
+
sycamore
|
507
|
+
symphony
|
508
|
+
tamarin
|
509
|
+
tarpon
|
510
|
+
tent
|
511
|
+
terminal
|
512
|
+
termite
|
513
|
+
tern
|
514
|
+
terrier
|
515
|
+
theater
|
516
|
+
tiger
|
517
|
+
toast
|
518
|
+
tortoise
|
519
|
+
toucan
|
520
|
+
tower
|
521
|
+
townhouse
|
522
|
+
treefrog
|
523
|
+
treehouse
|
524
|
+
trout
|
525
|
+
trumpeter
|
526
|
+
tundra
|
527
|
+
turkey
|
528
|
+
turtle
|
529
|
+
university
|
530
|
+
urchin
|
531
|
+
valley
|
532
|
+
veiled
|
533
|
+
venison
|
534
|
+
villa
|
535
|
+
violet
|
536
|
+
walnut
|
537
|
+
warehouse
|
538
|
+
water
|
539
|
+
watermill
|
540
|
+
western
|
541
|
+
whippet
|
542
|
+
wine
|
543
|
+
wolf
|
544
|
+
wolverine
|
545
|
+
wombat
|
546
|
+
woodchuck
|
547
|
+
woodland
|
548
|
+
workshop
|
549
|
+
wren
|
550
|
+
yogurt
|
data/lib/clean_words.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "clean_words/version"
|
2
|
+
|
3
|
+
module CleanWords
|
4
|
+
class Random
|
5
|
+
def self.fetch(size=nil, count=1)
|
6
|
+
new(size, count).fetch
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch(size=nil, count=1)
|
10
|
+
@size = size
|
11
|
+
@count = count
|
12
|
+
@count > 1 ? @count.times.map { get_word } : get_word
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def get_word
|
18
|
+
word_pool.shuffle.pop
|
19
|
+
end
|
20
|
+
|
21
|
+
def word_pool
|
22
|
+
@size.nil? ? words : words_for_size
|
23
|
+
end
|
24
|
+
|
25
|
+
def words
|
26
|
+
@words ||= File.new(file_path).readlines.map(&:chomp)
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_path
|
30
|
+
File.dirname(__FILE__) + '/../data/words.txt'
|
31
|
+
end
|
32
|
+
|
33
|
+
def words_for_size
|
34
|
+
sizes.map { |size| words_by_length[size] }.flatten
|
35
|
+
end
|
36
|
+
|
37
|
+
def sizes
|
38
|
+
@size.respond_to?(:to_a) ? @size.to_a : [@size]
|
39
|
+
end
|
40
|
+
|
41
|
+
def words_by_length
|
42
|
+
@words_by_length ||= words.group_by(&:size)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path("spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module CleanWords
|
4
|
+
describe Random do
|
5
|
+
describe '#fetch' do
|
6
|
+
it 'calls fetch on a new instance' do
|
7
|
+
words = double(fetch: 'test')
|
8
|
+
allow(CleanWords::Random).to receive(:new).and_return(words)
|
9
|
+
|
10
|
+
expect(CleanWords::Random.fetch).to eq 'test'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.fetch' do
|
15
|
+
it 'returns a word' do
|
16
|
+
words = CleanWords::Random.new
|
17
|
+
allow(words).to receive(:words).and_return(%w(test))
|
18
|
+
|
19
|
+
expect(words.fetch).to eq 'test'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns the specified number of words' do
|
23
|
+
words = CleanWords::Random.new.fetch(nil, 3)
|
24
|
+
|
25
|
+
expect(words.size).to eq 3
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns a word of the specified size' do
|
29
|
+
word = CleanWords::Random.new.fetch(5)
|
30
|
+
|
31
|
+
expect(word.size).to eq 5
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns words that match an array of size options' do
|
35
|
+
words = CleanWords::Random.new.fetch([5,7], 100)
|
36
|
+
sizes = words.map(&:size).uniq
|
37
|
+
|
38
|
+
expect(sizes).to match_array [5,7]
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns words that match a range of sizes' do
|
42
|
+
words = CleanWords::Random.new.fetch((4..6), 100)
|
43
|
+
sizes = words.map(&:size).uniq
|
44
|
+
|
45
|
+
expect(sizes).to match_array [4,5,6]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class WordListSanitizer
|
2
|
+
def initialize
|
3
|
+
@words ||= File.new(file_path).readlines.map(&:chomp)
|
4
|
+
end
|
5
|
+
|
6
|
+
def run!
|
7
|
+
process_words
|
8
|
+
write_file
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def file_path
|
13
|
+
File.dirname(__FILE__) + '/../data/words.txt'
|
14
|
+
end
|
15
|
+
|
16
|
+
def process_words
|
17
|
+
@processed = @words.reject { |w| w.match(/^\w+$/).nil? }.map(&:downcase).sort.uniq
|
18
|
+
end
|
19
|
+
|
20
|
+
def write_file
|
21
|
+
File.open(file_path, 'w') { |f| @processed.each { |w| f.puts(w) } }
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clean_words
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jake Sutton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
description: A random word generator featuring only words that would not be considered
|
56
|
+
inappropriate for children of all ages.
|
57
|
+
email:
|
58
|
+
- jcs@foraker.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- clean_words.gemspec
|
70
|
+
- data/words.txt
|
71
|
+
- lib/clean_words.rb
|
72
|
+
- lib/clean_words/version.rb
|
73
|
+
- spec/clean_words_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
- util/sanitize_list.rb
|
76
|
+
- util/word_list_sanitizer.rb
|
77
|
+
homepage: http://foraker.com
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: A clean (i.e. "kid friendly") random word generator.
|
101
|
+
test_files:
|
102
|
+
- spec/clean_words_spec.rb
|
103
|
+
- spec/spec_helper.rb
|