word_salad 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/History.txt +13 -0
- data/README.txt +48 -0
- data/Rakefile +2 -0
- data/lib/version.rb +3 -0
- data/lib/word_salad/core_ext.rb +47 -0
- data/lib/word_salad/dictionary +852 -0
- data/lib/word_salad/version.rb +3 -0
- data/lib/word_salad.rb +20 -0
- data/spec/word_salad_spec.rb +98 -0
- data/word_salad.gemspec +21 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
=== 1.0.0 / 2009-11-07
|
2
|
+
|
3
|
+
* Happy Birthday Word Salad!
|
4
|
+
|
5
|
+
=== 2.0.0 / 2011-02-17
|
6
|
+
|
7
|
+
* switched to included wordlist for more basic words
|
8
|
+
* switched singular methods to strings instead of arrays
|
9
|
+
* made the variance bigger for sentence length
|
10
|
+
* published gem to Rubygems
|
11
|
+
* fixed bugs
|
12
|
+
** EOFError: end of file reached
|
13
|
+
** NoMethodError: undefined method `words' for 2.6187173419804153:Float
|
data/README.txt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= Word Salad
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
Word Salad is a very simple Ruby library for generating random strings
|
6
|
+
of English words based on a list of basic english words. Words retrieved
|
7
|
+
from http://www.langmaker.com/wordlist/basiclex.htm
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
WordSalad adds six methods to the <tt>Fixnum</tt> class.
|
12
|
+
|
13
|
+
1.word ==> "quite"
|
14
|
+
5.words ==> ["stone", "bent", "kick", "name", "event"]
|
15
|
+
1.sentence => "Take past even rice land red open name engine grass thick pen."
|
16
|
+
3.sentences(5) ==> ["Move mass increase fact step quite.", "Clock shirt pocket mountain drain.", "Before fat group such."]
|
17
|
+
1.paragraph(5, 5) => "Belief same minute market control. Stamp sand stocking ant angle. Grip form distribution up. Leaf blue committee camera test. Event detail addition point trousers be."
|
18
|
+
2.paragraphs(2, 3) ==> ["Disgust idea bucket. Branch sail right.", "Cotton root discussion. Grey thumb.", "Lift minute pipe cake. Any scale.", "Size take gun. Not bell smash out."]
|
19
|
+
|
20
|
+
== INSTALL:
|
21
|
+
|
22
|
+
sudo gem install word_salad
|
23
|
+
|
24
|
+
== LICENSE:
|
25
|
+
|
26
|
+
(The MIT License)
|
27
|
+
|
28
|
+
Copyright (c) 2008 Alex Vollmer
|
29
|
+
Copyright (c) 2011 Alice Brown
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/lib/version.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
class Fixnum
|
2
|
+
|
3
|
+
# Returns +num+ random words from the dictionary.
|
4
|
+
def words
|
5
|
+
dict = WordSalad.dictionary
|
6
|
+
(1..self).to_a.map do |x|
|
7
|
+
WordSalad.words[rand(WordSalad.size)].strip
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns 1 random word
|
12
|
+
def word
|
13
|
+
1.words.first
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns +num+ sentences of random words about +size+ long
|
17
|
+
def sentences(size=10)
|
18
|
+
(1..self).to_a.map do |x|
|
19
|
+
variance = rand(size/3 + 1)
|
20
|
+
variance = 0 - variance if rand(2) == 0 # plus or minus
|
21
|
+
w = (size + variance).words
|
22
|
+
w[0].capitalize!
|
23
|
+
w.join(' ') + '.'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns 1 sentence of random words about +size+ long
|
28
|
+
def sentence(size=10)
|
29
|
+
1.sentences(size).first
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns +num+ paragraphs of +psize+ sentences,
|
33
|
+
# each about +ssize+ words long
|
34
|
+
def paragraphs(psize=5, ssize=10)
|
35
|
+
(1..self).to_a.map do |x|
|
36
|
+
psize.sentences(ssize).join(' ')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns 1 paragraph of +psize+ sentences,
|
41
|
+
# each about +ssize+ words long
|
42
|
+
def paragraph(psize=5, ssize=10)
|
43
|
+
1.paragraphs(psize, ssize).first
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,852 @@
|
|
1
|
+
a
|
2
|
+
able
|
3
|
+
about
|
4
|
+
account
|
5
|
+
acid
|
6
|
+
across
|
7
|
+
act
|
8
|
+
addition
|
9
|
+
adjustment
|
10
|
+
advertisement
|
11
|
+
after
|
12
|
+
again
|
13
|
+
against
|
14
|
+
agreement
|
15
|
+
air
|
16
|
+
all
|
17
|
+
almost
|
18
|
+
among
|
19
|
+
amount
|
20
|
+
amusement
|
21
|
+
and
|
22
|
+
angle
|
23
|
+
angry
|
24
|
+
animal
|
25
|
+
answer
|
26
|
+
ant
|
27
|
+
any
|
28
|
+
apparatus
|
29
|
+
apple
|
30
|
+
approval
|
31
|
+
arch
|
32
|
+
argument
|
33
|
+
arm
|
34
|
+
army
|
35
|
+
art
|
36
|
+
as
|
37
|
+
at
|
38
|
+
attack
|
39
|
+
attempt
|
40
|
+
attention
|
41
|
+
attraction
|
42
|
+
authority
|
43
|
+
automatic
|
44
|
+
awake
|
45
|
+
baby
|
46
|
+
back
|
47
|
+
bad
|
48
|
+
bag
|
49
|
+
balance
|
50
|
+
ball
|
51
|
+
band
|
52
|
+
base
|
53
|
+
basin
|
54
|
+
basket
|
55
|
+
bath
|
56
|
+
be
|
57
|
+
beautiful
|
58
|
+
because
|
59
|
+
bed
|
60
|
+
bee
|
61
|
+
before
|
62
|
+
behaviour
|
63
|
+
belief
|
64
|
+
bell
|
65
|
+
bent
|
66
|
+
berry
|
67
|
+
between
|
68
|
+
bird
|
69
|
+
birth
|
70
|
+
bit
|
71
|
+
bite
|
72
|
+
bitter
|
73
|
+
black
|
74
|
+
blade
|
75
|
+
blood
|
76
|
+
blow
|
77
|
+
blue
|
78
|
+
board
|
79
|
+
boat
|
80
|
+
body
|
81
|
+
boiling
|
82
|
+
bone
|
83
|
+
book
|
84
|
+
boot
|
85
|
+
bottle
|
86
|
+
box
|
87
|
+
boy
|
88
|
+
brain
|
89
|
+
brake
|
90
|
+
branch
|
91
|
+
brass
|
92
|
+
bread
|
93
|
+
breath
|
94
|
+
brick
|
95
|
+
bridge
|
96
|
+
bright
|
97
|
+
broken
|
98
|
+
brother
|
99
|
+
brown
|
100
|
+
brush
|
101
|
+
bucket
|
102
|
+
building
|
103
|
+
bulb
|
104
|
+
burn
|
105
|
+
burst
|
106
|
+
business
|
107
|
+
but
|
108
|
+
butter
|
109
|
+
button
|
110
|
+
by
|
111
|
+
cake
|
112
|
+
camera
|
113
|
+
canvas
|
114
|
+
card
|
115
|
+
care
|
116
|
+
carriage
|
117
|
+
cart
|
118
|
+
cat
|
119
|
+
cause
|
120
|
+
certain
|
121
|
+
chain
|
122
|
+
chalk
|
123
|
+
chance
|
124
|
+
change
|
125
|
+
cheap
|
126
|
+
cheese
|
127
|
+
chemical
|
128
|
+
chest
|
129
|
+
chief
|
130
|
+
chin
|
131
|
+
church
|
132
|
+
circle
|
133
|
+
clean
|
134
|
+
clear
|
135
|
+
clock
|
136
|
+
cloth
|
137
|
+
cloud
|
138
|
+
coal
|
139
|
+
coat
|
140
|
+
cold
|
141
|
+
collar
|
142
|
+
colour
|
143
|
+
comb
|
144
|
+
come
|
145
|
+
comfort
|
146
|
+
committee
|
147
|
+
common
|
148
|
+
company
|
149
|
+
comparison
|
150
|
+
competition
|
151
|
+
complete
|
152
|
+
complex
|
153
|
+
condition
|
154
|
+
connection
|
155
|
+
conscious
|
156
|
+
control
|
157
|
+
cook
|
158
|
+
copper
|
159
|
+
copy
|
160
|
+
cord
|
161
|
+
cork
|
162
|
+
cotton
|
163
|
+
cough
|
164
|
+
country
|
165
|
+
cover
|
166
|
+
cow
|
167
|
+
crack
|
168
|
+
credit
|
169
|
+
crime
|
170
|
+
cruel
|
171
|
+
crush
|
172
|
+
cry
|
173
|
+
cup
|
174
|
+
cup
|
175
|
+
current
|
176
|
+
curtain
|
177
|
+
curve
|
178
|
+
cushion
|
179
|
+
damage
|
180
|
+
danger
|
181
|
+
dark
|
182
|
+
daughter
|
183
|
+
day
|
184
|
+
dead
|
185
|
+
dear
|
186
|
+
death
|
187
|
+
debt
|
188
|
+
decision
|
189
|
+
deep
|
190
|
+
degree
|
191
|
+
delicate
|
192
|
+
dependent
|
193
|
+
design
|
194
|
+
desire
|
195
|
+
destruction
|
196
|
+
detail
|
197
|
+
development
|
198
|
+
different
|
199
|
+
digestion
|
200
|
+
direction
|
201
|
+
dirty
|
202
|
+
discovery
|
203
|
+
discussion
|
204
|
+
disease
|
205
|
+
disgust
|
206
|
+
distance
|
207
|
+
distribution
|
208
|
+
division
|
209
|
+
do
|
210
|
+
dog
|
211
|
+
door
|
212
|
+
doubt
|
213
|
+
down
|
214
|
+
drain
|
215
|
+
drawer
|
216
|
+
dress
|
217
|
+
drink
|
218
|
+
driving
|
219
|
+
drop
|
220
|
+
dry
|
221
|
+
dust
|
222
|
+
ear
|
223
|
+
early
|
224
|
+
earth
|
225
|
+
east
|
226
|
+
edge
|
227
|
+
education
|
228
|
+
effect
|
229
|
+
egg
|
230
|
+
elastic
|
231
|
+
electric
|
232
|
+
end
|
233
|
+
engine
|
234
|
+
enough
|
235
|
+
equal
|
236
|
+
error
|
237
|
+
even
|
238
|
+
event
|
239
|
+
ever
|
240
|
+
every
|
241
|
+
example
|
242
|
+
exchange
|
243
|
+
existence
|
244
|
+
expansion
|
245
|
+
experience
|
246
|
+
expert
|
247
|
+
eye
|
248
|
+
face
|
249
|
+
fact
|
250
|
+
fall
|
251
|
+
false
|
252
|
+
family
|
253
|
+
far
|
254
|
+
farm
|
255
|
+
fat
|
256
|
+
father
|
257
|
+
fear
|
258
|
+
feather
|
259
|
+
feeble
|
260
|
+
feeling
|
261
|
+
female
|
262
|
+
fertile
|
263
|
+
fiction
|
264
|
+
field
|
265
|
+
fight
|
266
|
+
finger
|
267
|
+
fire
|
268
|
+
first
|
269
|
+
fish
|
270
|
+
fixed
|
271
|
+
flag
|
272
|
+
flame
|
273
|
+
flat
|
274
|
+
flight
|
275
|
+
floor
|
276
|
+
flower
|
277
|
+
fly
|
278
|
+
fold
|
279
|
+
food
|
280
|
+
foolish
|
281
|
+
foot
|
282
|
+
for
|
283
|
+
force
|
284
|
+
fork
|
285
|
+
form
|
286
|
+
forward
|
287
|
+
fowl
|
288
|
+
frame
|
289
|
+
free
|
290
|
+
frequent
|
291
|
+
friend
|
292
|
+
from
|
293
|
+
front
|
294
|
+
fruit
|
295
|
+
full
|
296
|
+
future
|
297
|
+
garden
|
298
|
+
general
|
299
|
+
get
|
300
|
+
girl
|
301
|
+
give
|
302
|
+
glass
|
303
|
+
glove
|
304
|
+
go
|
305
|
+
goat
|
306
|
+
gold
|
307
|
+
good
|
308
|
+
government
|
309
|
+
grain
|
310
|
+
grass
|
311
|
+
great
|
312
|
+
green
|
313
|
+
grey
|
314
|
+
grip
|
315
|
+
group
|
316
|
+
growth
|
317
|
+
guide
|
318
|
+
gun
|
319
|
+
hair
|
320
|
+
hammer
|
321
|
+
hand
|
322
|
+
hanging
|
323
|
+
happy
|
324
|
+
harbour
|
325
|
+
hard
|
326
|
+
harmony
|
327
|
+
hat
|
328
|
+
hate
|
329
|
+
have
|
330
|
+
he
|
331
|
+
head
|
332
|
+
healthy
|
333
|
+
hear
|
334
|
+
hearing
|
335
|
+
heart
|
336
|
+
heat
|
337
|
+
help
|
338
|
+
high
|
339
|
+
history
|
340
|
+
hole
|
341
|
+
hollow
|
342
|
+
hook
|
343
|
+
hope
|
344
|
+
horn
|
345
|
+
horse
|
346
|
+
hospital
|
347
|
+
hour
|
348
|
+
house
|
349
|
+
how
|
350
|
+
humour
|
351
|
+
I
|
352
|
+
ice
|
353
|
+
idea
|
354
|
+
if
|
355
|
+
ill
|
356
|
+
important
|
357
|
+
impulse
|
358
|
+
in
|
359
|
+
increase
|
360
|
+
industry
|
361
|
+
ink
|
362
|
+
insect
|
363
|
+
instrument
|
364
|
+
insurance
|
365
|
+
interest
|
366
|
+
invention
|
367
|
+
iron
|
368
|
+
island
|
369
|
+
jelly
|
370
|
+
jewel
|
371
|
+
join
|
372
|
+
journey
|
373
|
+
judge
|
374
|
+
jump
|
375
|
+
keep
|
376
|
+
kettle
|
377
|
+
key
|
378
|
+
kick
|
379
|
+
kind
|
380
|
+
kiss
|
381
|
+
knee
|
382
|
+
knife
|
383
|
+
knot
|
384
|
+
knowledge
|
385
|
+
land
|
386
|
+
language
|
387
|
+
last
|
388
|
+
late
|
389
|
+
laugh
|
390
|
+
law
|
391
|
+
lead
|
392
|
+
leaf
|
393
|
+
learning
|
394
|
+
leather
|
395
|
+
left
|
396
|
+
leg
|
397
|
+
let
|
398
|
+
letter
|
399
|
+
level
|
400
|
+
library
|
401
|
+
lift
|
402
|
+
light
|
403
|
+
like
|
404
|
+
limit
|
405
|
+
line
|
406
|
+
linen
|
407
|
+
lip
|
408
|
+
liquid
|
409
|
+
list
|
410
|
+
little
|
411
|
+
living
|
412
|
+
lock
|
413
|
+
long
|
414
|
+
look
|
415
|
+
loose
|
416
|
+
loss
|
417
|
+
loud
|
418
|
+
love
|
419
|
+
low
|
420
|
+
machine
|
421
|
+
make
|
422
|
+
male
|
423
|
+
man
|
424
|
+
manager
|
425
|
+
map
|
426
|
+
mark
|
427
|
+
market
|
428
|
+
married
|
429
|
+
mass
|
430
|
+
match
|
431
|
+
material
|
432
|
+
may
|
433
|
+
meal
|
434
|
+
measure
|
435
|
+
meat
|
436
|
+
medical
|
437
|
+
meeting
|
438
|
+
memory
|
439
|
+
metal
|
440
|
+
middle
|
441
|
+
military
|
442
|
+
milk
|
443
|
+
mind
|
444
|
+
mine
|
445
|
+
minute
|
446
|
+
mist
|
447
|
+
mixed
|
448
|
+
money
|
449
|
+
monkey
|
450
|
+
month
|
451
|
+
moon
|
452
|
+
morning
|
453
|
+
mother
|
454
|
+
motion
|
455
|
+
mountain
|
456
|
+
mouth
|
457
|
+
move
|
458
|
+
much
|
459
|
+
muscle
|
460
|
+
music
|
461
|
+
nail
|
462
|
+
name
|
463
|
+
narrow
|
464
|
+
nation
|
465
|
+
natural
|
466
|
+
near
|
467
|
+
necessary
|
468
|
+
neck
|
469
|
+
need
|
470
|
+
needle
|
471
|
+
nerve
|
472
|
+
net
|
473
|
+
new
|
474
|
+
news
|
475
|
+
night
|
476
|
+
no
|
477
|
+
noise
|
478
|
+
normal
|
479
|
+
north
|
480
|
+
nose
|
481
|
+
not
|
482
|
+
note
|
483
|
+
now
|
484
|
+
number
|
485
|
+
nut
|
486
|
+
observation
|
487
|
+
of
|
488
|
+
off
|
489
|
+
offer
|
490
|
+
office
|
491
|
+
oil
|
492
|
+
old
|
493
|
+
on
|
494
|
+
only
|
495
|
+
open
|
496
|
+
operation
|
497
|
+
opinion
|
498
|
+
opposite
|
499
|
+
or
|
500
|
+
orange
|
501
|
+
order
|
502
|
+
organization
|
503
|
+
ornament
|
504
|
+
other
|
505
|
+
out
|
506
|
+
oven
|
507
|
+
over
|
508
|
+
owner
|
509
|
+
page
|
510
|
+
pain
|
511
|
+
paint
|
512
|
+
paper
|
513
|
+
parallel
|
514
|
+
parcel
|
515
|
+
part
|
516
|
+
past
|
517
|
+
paste
|
518
|
+
payment
|
519
|
+
peace
|
520
|
+
pen
|
521
|
+
pencil
|
522
|
+
person
|
523
|
+
physical
|
524
|
+
picture
|
525
|
+
pig
|
526
|
+
pin
|
527
|
+
pipe
|
528
|
+
place
|
529
|
+
plane
|
530
|
+
plant
|
531
|
+
plate
|
532
|
+
play
|
533
|
+
please
|
534
|
+
pleasure
|
535
|
+
plough
|
536
|
+
pocket
|
537
|
+
point
|
538
|
+
poison
|
539
|
+
polish
|
540
|
+
political
|
541
|
+
poor
|
542
|
+
porter
|
543
|
+
position
|
544
|
+
possible
|
545
|
+
pot
|
546
|
+
potato
|
547
|
+
powder
|
548
|
+
power
|
549
|
+
present
|
550
|
+
price
|
551
|
+
print
|
552
|
+
prison
|
553
|
+
private
|
554
|
+
probable
|
555
|
+
process
|
556
|
+
produce
|
557
|
+
profit
|
558
|
+
property
|
559
|
+
prose
|
560
|
+
protest
|
561
|
+
public
|
562
|
+
pull
|
563
|
+
pump
|
564
|
+
punishment
|
565
|
+
purpose
|
566
|
+
push
|
567
|
+
put
|
568
|
+
quality
|
569
|
+
question
|
570
|
+
quick
|
571
|
+
quiet
|
572
|
+
quite
|
573
|
+
rail
|
574
|
+
rain
|
575
|
+
range
|
576
|
+
rat
|
577
|
+
rate
|
578
|
+
ray
|
579
|
+
reaction
|
580
|
+
reading
|
581
|
+
ready
|
582
|
+
reason
|
583
|
+
receipt
|
584
|
+
record
|
585
|
+
red
|
586
|
+
regret
|
587
|
+
regular
|
588
|
+
relation
|
589
|
+
religion
|
590
|
+
representative
|
591
|
+
request
|
592
|
+
respect
|
593
|
+
responsible
|
594
|
+
rest
|
595
|
+
reward
|
596
|
+
rhythm
|
597
|
+
rice
|
598
|
+
right
|
599
|
+
ring
|
600
|
+
river
|
601
|
+
road
|
602
|
+
rod
|
603
|
+
roll
|
604
|
+
roof
|
605
|
+
room
|
606
|
+
root
|
607
|
+
rough
|
608
|
+
round
|
609
|
+
rub
|
610
|
+
rule
|
611
|
+
run
|
612
|
+
sad
|
613
|
+
safe
|
614
|
+
sail
|
615
|
+
salt
|
616
|
+
same
|
617
|
+
sand
|
618
|
+
say
|
619
|
+
scale
|
620
|
+
school
|
621
|
+
science
|
622
|
+
scissors
|
623
|
+
screw
|
624
|
+
sea
|
625
|
+
seat
|
626
|
+
second
|
627
|
+
secret
|
628
|
+
secretary
|
629
|
+
see
|
630
|
+
seed
|
631
|
+
seem
|
632
|
+
selection
|
633
|
+
self
|
634
|
+
send
|
635
|
+
sense
|
636
|
+
separate
|
637
|
+
serious
|
638
|
+
servant
|
639
|
+
sex
|
640
|
+
shade
|
641
|
+
shake
|
642
|
+
shame
|
643
|
+
sharp
|
644
|
+
sheep
|
645
|
+
shelf
|
646
|
+
ship
|
647
|
+
shirt
|
648
|
+
shock
|
649
|
+
shoe
|
650
|
+
short
|
651
|
+
shut
|
652
|
+
side
|
653
|
+
sign
|
654
|
+
silk
|
655
|
+
silver
|
656
|
+
simple
|
657
|
+
sister
|
658
|
+
size
|
659
|
+
skin
|
660
|
+
|
661
|
+
skirt
|
662
|
+
sky
|
663
|
+
sleep
|
664
|
+
slip
|
665
|
+
slope
|
666
|
+
slow
|
667
|
+
small
|
668
|
+
smash
|
669
|
+
smell
|
670
|
+
smile
|
671
|
+
smoke
|
672
|
+
smooth
|
673
|
+
snake
|
674
|
+
sneeze
|
675
|
+
snow
|
676
|
+
so
|
677
|
+
soap
|
678
|
+
society
|
679
|
+
sock
|
680
|
+
soft
|
681
|
+
solid
|
682
|
+
some
|
683
|
+
|
684
|
+
son
|
685
|
+
song
|
686
|
+
sort
|
687
|
+
sound
|
688
|
+
soup
|
689
|
+
south
|
690
|
+
space
|
691
|
+
spade
|
692
|
+
special
|
693
|
+
sponge
|
694
|
+
spoon
|
695
|
+
spring
|
696
|
+
square
|
697
|
+
stage
|
698
|
+
stamp
|
699
|
+
star
|
700
|
+
start
|
701
|
+
statement
|
702
|
+
station
|
703
|
+
steam
|
704
|
+
steel
|
705
|
+
stem
|
706
|
+
step
|
707
|
+
stick
|
708
|
+
sticky
|
709
|
+
stiff
|
710
|
+
still
|
711
|
+
stitch
|
712
|
+
stocking
|
713
|
+
stomach
|
714
|
+
stone
|
715
|
+
stop
|
716
|
+
store
|
717
|
+
story
|
718
|
+
straight
|
719
|
+
strange
|
720
|
+
street
|
721
|
+
stretch
|
722
|
+
strong
|
723
|
+
structure
|
724
|
+
substance
|
725
|
+
such
|
726
|
+
sudden
|
727
|
+
sugar
|
728
|
+
suggestion
|
729
|
+
summer
|
730
|
+
sun
|
731
|
+
support
|
732
|
+
surprise
|
733
|
+
sweet
|
734
|
+
swim
|
735
|
+
system
|
736
|
+
table
|
737
|
+
tail
|
738
|
+
take
|
739
|
+
talk
|
740
|
+
tall
|
741
|
+
taste
|
742
|
+
tax
|
743
|
+
teaching
|
744
|
+
tendency
|
745
|
+
test
|
746
|
+
than
|
747
|
+
that
|
748
|
+
the
|
749
|
+
then
|
750
|
+
theory
|
751
|
+
there
|
752
|
+
thick
|
753
|
+
thin
|
754
|
+
thing
|
755
|
+
this
|
756
|
+
thought
|
757
|
+
thread
|
758
|
+
throat
|
759
|
+
through
|
760
|
+
through
|
761
|
+
thumb
|
762
|
+
thunder
|
763
|
+
ticket
|
764
|
+
tight
|
765
|
+
till
|
766
|
+
time
|
767
|
+
tin
|
768
|
+
tired
|
769
|
+
to
|
770
|
+
toe
|
771
|
+
together
|
772
|
+
tomorrow
|
773
|
+
tongue
|
774
|
+
tooth
|
775
|
+
top
|
776
|
+
touch
|
777
|
+
town
|
778
|
+
trade
|
779
|
+
train
|
780
|
+
transport
|
781
|
+
tray
|
782
|
+
tree
|
783
|
+
trick
|
784
|
+
trouble
|
785
|
+
trousers
|
786
|
+
true
|
787
|
+
turn
|
788
|
+
twist
|
789
|
+
umbrella
|
790
|
+
under
|
791
|
+
unit
|
792
|
+
up
|
793
|
+
use
|
794
|
+
value
|
795
|
+
verse
|
796
|
+
very
|
797
|
+
vessel
|
798
|
+
view
|
799
|
+
violent
|
800
|
+
voice
|
801
|
+
waiting
|
802
|
+
walk
|
803
|
+
wall
|
804
|
+
war
|
805
|
+
warm
|
806
|
+
wash
|
807
|
+
waste
|
808
|
+
watch
|
809
|
+
water
|
810
|
+
wave
|
811
|
+
wax
|
812
|
+
way
|
813
|
+
weather
|
814
|
+
week
|
815
|
+
weight
|
816
|
+
well
|
817
|
+
west
|
818
|
+
wet
|
819
|
+
wheel
|
820
|
+
when
|
821
|
+
where
|
822
|
+
while
|
823
|
+
whip
|
824
|
+
whistle
|
825
|
+
white
|
826
|
+
who
|
827
|
+
why
|
828
|
+
wide
|
829
|
+
will
|
830
|
+
wind
|
831
|
+
window
|
832
|
+
wine
|
833
|
+
wing
|
834
|
+
winter
|
835
|
+
wire
|
836
|
+
wise
|
837
|
+
with
|
838
|
+
woman
|
839
|
+
wood
|
840
|
+
wool
|
841
|
+
word
|
842
|
+
work
|
843
|
+
worm
|
844
|
+
wound
|
845
|
+
writing
|
846
|
+
wrong
|
847
|
+
year
|
848
|
+
yellow
|
849
|
+
yes
|
850
|
+
yesterday
|
851
|
+
you
|
852
|
+
young
|
data/lib/word_salad.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "word_salad/core_ext"
|
2
|
+
|
3
|
+
module WordSalad
|
4
|
+
|
5
|
+
# the dictionary as a File object
|
6
|
+
def self.dictionary
|
7
|
+
open(File.join(File.dirname(__FILE__), "word_salad/dictionary"))
|
8
|
+
end
|
9
|
+
|
10
|
+
# all the words in the dictionary
|
11
|
+
def self.words
|
12
|
+
IO.readlines(self.dictionary)
|
13
|
+
end
|
14
|
+
|
15
|
+
# the number of words in the dictionary
|
16
|
+
def self.size
|
17
|
+
@size ||= self.words.size
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "tempfile"
|
3
|
+
require "rubygems"
|
4
|
+
require "spec"
|
5
|
+
|
6
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
7
|
+
require "word_salad"
|
8
|
+
|
9
|
+
describe WordSalad do
|
10
|
+
describe "generating random words" do
|
11
|
+
it "should return an array of the right size" do
|
12
|
+
w = 5.words
|
13
|
+
w.should be_kind_of(Array)
|
14
|
+
w.size.should eql(5)
|
15
|
+
w.each do |word|
|
16
|
+
word.should be_kind_of(String)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should respond to the singular version too" do
|
21
|
+
w = 1.word
|
22
|
+
w.should be_kind_of(Array)
|
23
|
+
w.size.should == 1
|
24
|
+
w.first.should be_kind_of(String)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "generating random sentences" do
|
29
|
+
it "should return an array of sentences" do
|
30
|
+
s = 5.sentences
|
31
|
+
s.should be_kind_of(Array)
|
32
|
+
s.size.should == 5
|
33
|
+
s.each do |sent|
|
34
|
+
sent.should be_kind_of(String)
|
35
|
+
sent.should match(/^[A-Z].*\.$/)
|
36
|
+
sent.split(' ').size.should be_close(10, 2)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should respond to the singular version too" do
|
41
|
+
s = 1.sentence
|
42
|
+
s.should be_kind_of(Array)
|
43
|
+
s.size.should == 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "generating random paragraphs" do
|
48
|
+
it "should return an array of paragraphs" do
|
49
|
+
p = 5.paragraphs
|
50
|
+
p.should be_kind_of(Array)
|
51
|
+
p.size.should == 5
|
52
|
+
p.each do |para|
|
53
|
+
para.should be_kind_of(String)
|
54
|
+
s = para.split('.')
|
55
|
+
s.size.should == 5
|
56
|
+
s.each do |sent|
|
57
|
+
sent.split(' ').size.should be_close(10, 2)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should respond to singular version too" do
|
63
|
+
p = 1.paragraph
|
64
|
+
p.should be_kind_of(Array)
|
65
|
+
p.size.should == 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'overriding the default dictionary path' do
|
70
|
+
before(:each) do
|
71
|
+
@tmpfile = Tempfile.new "word_salad"
|
72
|
+
2000.times { @tmpfile << "alpha\n" }
|
73
|
+
@tmpfile.close
|
74
|
+
WordSalad.dictionary_path = @tmpfile.path
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should work for words' do
|
78
|
+
w = 5.words
|
79
|
+
w.each { |e| e.should == "alpha" }
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should work for sentences' do
|
83
|
+
s = 5.sentences
|
84
|
+
s.each do |sent|
|
85
|
+
sent.split(' ').each { |e| e.downcase.should match(/alpha/) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should work for paragraphs' do
|
90
|
+
p = 5.paragraphs
|
91
|
+
p.each do |para|
|
92
|
+
para.split('.').each do |sent|
|
93
|
+
sent.split(' ').each { |e| e.downcase.should match(/alpha/) }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/word_salad.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "word_salad/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "word_salad"
|
7
|
+
s.version = WordSalad::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Alex Vollmer", "Alice Brown"]
|
10
|
+
s.email = ["alex.vollmer@gmail.com", "alice@alum.mit.edu"]
|
11
|
+
s.homepage = "https://github.com/ambtus/word_salad"
|
12
|
+
s.summary = %q{Generate strings of random English text}
|
13
|
+
s.description = %q{Word Salad is a very simple Ruby library for generating random strings of English words based on a list of basic english words.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "word_salad"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: word_salad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 2.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Alex Vollmer
|
13
|
+
- Alice Brown
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-17 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Word Salad is a very simple Ruby library for generating random strings of English words based on a list of basic english words.
|
23
|
+
email:
|
24
|
+
- alex.vollmer@gmail.com
|
25
|
+
- alice@alum.mit.edu
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- History.txt
|
36
|
+
- README.txt
|
37
|
+
- Rakefile
|
38
|
+
- lib/version.rb
|
39
|
+
- lib/word_salad.rb
|
40
|
+
- lib/word_salad/core_ext.rb
|
41
|
+
- lib/word_salad/dictionary
|
42
|
+
- lib/word_salad/version.rb
|
43
|
+
- spec/word_salad_spec.rb
|
44
|
+
- word_salad.gemspec
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: https://github.com/ambtus/word_salad
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project: word_salad
|
73
|
+
rubygems_version: 1.3.7
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Generate strings of random English text
|
77
|
+
test_files:
|
78
|
+
- spec/word_salad_spec.rb
|