sparky 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jason Campbell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ = sparky
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Jason Campbell. See LICENSE for details.
@@ -0,0 +1,3 @@
1
+ require 'sparky/sparky'
2
+ require 'sparky/lorem'
3
+ require 'sparky/name'
@@ -0,0 +1,89 @@
1
+ class Sparky
2
+ class UnsupportedType < StandardError; end
3
+
4
+ class Lorem
5
+ attr_reader :output
6
+ attr_accessor :type, :count
7
+
8
+ TYPES = [ :paragraphs, :sentences, :words ]
9
+ LOREM = "Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."
10
+
11
+ def initialize (type = :sentences, count = 1)
12
+ @type = lorem_type_for(type)
13
+ @count = count.to_i
14
+ raise UnsupportedType unless TYPES.include?(type)
15
+ @output = generate_lorem
16
+ end
17
+
18
+ def self.create (type = :sentences, count = 1)
19
+ instance = Lorem.new(type, count)
20
+ instance.output
21
+ end
22
+
23
+ def self.total_words
24
+ LOREM.split(' ').size
25
+ end
26
+
27
+ private
28
+ def lorem_type_for (symbol)
29
+ symbol.to_sym
30
+ end
31
+
32
+ def generate_lorem
33
+ send("output_#{@type}")
34
+ end
35
+
36
+ def random_words
37
+ LOREM.split(' ').sort_by { rand }
38
+ end
39
+
40
+ def output_words
41
+ if @count <= 1
42
+ grab_words(@count).gsub(/\W/, '')
43
+ else
44
+ grab_words(@count)
45
+ end
46
+ end
47
+
48
+ def output_sentences
49
+ sentences = ''
50
+ @count.times { sentences << make_sentence << ' ' }
51
+ sentences.strip
52
+ end
53
+
54
+ def output_paragraphs
55
+ paragraphs = ''
56
+
57
+ @count.times do
58
+ sentence_count = rand(4) + 3
59
+ sentence_count.times { paragraphs << make_sentence << ' ' }
60
+ paragraphs << "\n\n"
61
+ end
62
+ paragraphs.strip
63
+ end
64
+
65
+ def grab_words (word_count)
66
+ if word_count <= self.class.total_words
67
+ words = random_words[0, word_count].join(' ')
68
+ else
69
+ repeat = (word_count / self.class.total_words.to_f).ceil
70
+ words = (random_words * repeat)[0, word_count].join(' ')
71
+ end
72
+
73
+ words.gsub(/\\S/, '')
74
+ end
75
+
76
+ def make_sentence
77
+ word_count = rand(9) + 8
78
+ end_chars = ['.', '.', '.', '.', '!', '?', '...']
79
+ punct = end_chars.sort_by { rand }.last
80
+ sentence = grab_words(word_count).capitalize
81
+ last_char = sentence[sentence.length - 1, 1]
82
+ if end_chars.include?(last_char)
83
+ sentence.chop << punct
84
+ else
85
+ sentence << punct
86
+ end
87
+ end
88
+ end # Lorem
89
+ end # Sparky
@@ -0,0 +1,11 @@
1
+ class Sparky
2
+ class Name
3
+ require File.expand_path(File.dirname(__FILE__) + '/names/first_names')
4
+ require File.expand_path(File.dirname(__FILE__) + '/names/last_names')
5
+
6
+ def self.create
7
+ FIRST_NAMES.split("\n").first
8
+ "#{FIRST_NAMES.split("\n")[rand(600)]} #{LAST_NAMES.split("\n")[rand(600)]}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,602 @@
1
+ FIRST_NAMES = <<EOF
2
+ Mary
3
+ Patricia
4
+ Linda
5
+ Barbara
6
+ Elizabeth
7
+ Jennifer
8
+ Maria
9
+ Susan
10
+ Margaret
11
+ Dorothy
12
+ Lisa
13
+ Nancy
14
+ Karen
15
+ Betty
16
+ Helen
17
+ Sandra
18
+ Donna
19
+ Carol
20
+ Ruth
21
+ Sharon
22
+ Michelle
23
+ Laura
24
+ Sarah
25
+ Kimberly
26
+ Deborah
27
+ Jessica
28
+ Shirley
29
+ Cynthia
30
+ Angela
31
+ Melissa
32
+ Brenda
33
+ Amy
34
+ Anna
35
+ Rebecca
36
+ Virginia
37
+ Kathleen
38
+ Pamela
39
+ Martha
40
+ Debra
41
+ Amanda
42
+ Stephanie
43
+ Carolyn
44
+ Christine
45
+ Marie
46
+ Janet
47
+ Catherine
48
+ Frances
49
+ Ann
50
+ Joyce
51
+ Diane
52
+ Alice
53
+ Julie
54
+ Heather
55
+ Teresa
56
+ Doris
57
+ Gloria
58
+ Evelyn
59
+ Jean
60
+ Cheryl
61
+ Mildred
62
+ Katherine
63
+ Joan
64
+ Ashley
65
+ Judith
66
+ Rose
67
+ Janice
68
+ Kelly
69
+ Nicole
70
+ Judy
71
+ Christina
72
+ Kathy
73
+ Theresa
74
+ Beverly
75
+ Denise
76
+ Tammy
77
+ Irene
78
+ Jane
79
+ Lori
80
+ Rachel
81
+ Marilyn
82
+ Andrea
83
+ Kathryn
84
+ Louise
85
+ Sara
86
+ Anne
87
+ Jacqueline
88
+ Wanda
89
+ Bonnie
90
+ Julia
91
+ Ruby
92
+ Lois
93
+ Tina
94
+ Phyllis
95
+ Norma
96
+ Paula
97
+ Diana
98
+ Annie
99
+ Lillian
100
+ Emily
101
+ Robin
102
+ Peggy
103
+ Crystal
104
+ Gladys
105
+ Rita
106
+ Dawn
107
+ Connie
108
+ Florence
109
+ Tracy
110
+ Edna
111
+ Tiffany
112
+ Carmen
113
+ Rosa
114
+ Cindy
115
+ Grace
116
+ Wendy
117
+ Victoria
118
+ Edith
119
+ Kim
120
+ Sherry
121
+ Sylvia
122
+ Josephine
123
+ Thelma
124
+ Shannon
125
+ Sheila
126
+ Ethel
127
+ Ellen
128
+ Elaine
129
+ Marjorie
130
+ Carrie
131
+ Charlotte
132
+ Monica
133
+ Esther
134
+ Pauline
135
+ Emma
136
+ Juanita
137
+ Anita
138
+ Rhonda
139
+ Hazel
140
+ Amber
141
+ Eva
142
+ Debbie
143
+ April
144
+ Leslie
145
+ Clara
146
+ Lucille
147
+ Jamie
148
+ Joanne
149
+ Eleanor
150
+ Valerie
151
+ Danielle
152
+ Megan
153
+ Alicia
154
+ Suzanne
155
+ Michele
156
+ Gail
157
+ Bertha
158
+ Darlene
159
+ Veronica
160
+ Jill
161
+ Erin
162
+ Geraldine
163
+ Lauren
164
+ Cathy
165
+ Joann
166
+ Lorraine
167
+ Lynn
168
+ Sally
169
+ Regina
170
+ Erica
171
+ Beatrice
172
+ Dolores
173
+ Bernice
174
+ Audrey
175
+ Yvonne
176
+ Annette
177
+ June
178
+ Samantha
179
+ Marion
180
+ Dana
181
+ Stacy
182
+ Ana
183
+ Renee
184
+ Ida
185
+ Vivian
186
+ Roberta
187
+ Holly
188
+ Brittany
189
+ Melanie
190
+ Loretta
191
+ Yolanda
192
+ Jeanette
193
+ Laurie
194
+ Katie
195
+ Kristen
196
+ Vanessa
197
+ Alma
198
+ Sue
199
+ Elsie
200
+ Beth
201
+ Jeanne
202
+ Vicki
203
+ Carla
204
+ Tara
205
+ Rosemary
206
+ Eileen
207
+ Terri
208
+ Gertrude
209
+ Lucy
210
+ Tonya
211
+ Ella
212
+ Stacey
213
+ Wilma
214
+ Gina
215
+ Kristin
216
+ Jessie
217
+ Natalie
218
+ Agnes
219
+ Vera
220
+ Willie
221
+ Charlene
222
+ Bessie
223
+ Delores
224
+ Melinda
225
+ Pearl
226
+ Arlene
227
+ Maureen
228
+ Colleen
229
+ Allison
230
+ Tamara
231
+ Joy
232
+ Georgia
233
+ Constance
234
+ Lillie
235
+ Claudia
236
+ Jackie
237
+ Marcia
238
+ Tanya
239
+ Nellie
240
+ Minnie
241
+ Marlene
242
+ Heidi
243
+ Glenda
244
+ Lydia
245
+ Viola
246
+ Courtney
247
+ Marian
248
+ Stella
249
+ Caroline
250
+ Dora
251
+ Jo
252
+ Vickie
253
+ Mattie
254
+ Terry
255
+ Maxine
256
+ Irma
257
+ Mabel
258
+ Marsha
259
+ Myrtle
260
+ Lena
261
+ Christy
262
+ Deanna
263
+ Patsy
264
+ Hilda
265
+ Gwendolyn
266
+ Jennie
267
+ Nora
268
+ Margie
269
+ Nina
270
+ Cassandra
271
+ Leah
272
+ Penny
273
+ Kay
274
+ Priscilla
275
+ Naomi
276
+ Carole
277
+ Brandy
278
+ Olga
279
+ Billie
280
+ Dianne
281
+ Tracey
282
+ Leona
283
+ Jenny
284
+ Felicia
285
+ Sonia
286
+ Miriam
287
+ Velma
288
+ Becky
289
+ Bobbie
290
+ Violet
291
+ Kristina
292
+ Toni
293
+ Misty
294
+ Mae
295
+ Shelly
296
+ Daisy
297
+ Ramona
298
+ Sherri
299
+ Erika
300
+ Katrina
301
+ Claire
302
+ James
303
+ John
304
+ Robert
305
+ Michael
306
+ William
307
+ David
308
+ Richard
309
+ Charles
310
+ Joseph
311
+ Thomas
312
+ Christopher
313
+ Daniel
314
+ Paul
315
+ Mark
316
+ Donald
317
+ George
318
+ Kenneth
319
+ Steven
320
+ Edward
321
+ Brian
322
+ Ronald
323
+ Anthony
324
+ Kevin
325
+ Jason
326
+ Matthew
327
+ Gary
328
+ Timothy
329
+ Jose
330
+ Larry
331
+ Jeffrey
332
+ Frank
333
+ Scott
334
+ Eric
335
+ Stephen
336
+ Andrew
337
+ Raymond
338
+ Gregory
339
+ Joshua
340
+ Jerry
341
+ Dennis
342
+ Walter
343
+ Patrick
344
+ Peter
345
+ Harold
346
+ Douglas
347
+ Henry
348
+ Carl
349
+ Arthur
350
+ Ryan
351
+ Roger
352
+ Joe
353
+ Juan
354
+ Jack
355
+ Albert
356
+ Jonathan
357
+ Justin
358
+ Terry
359
+ Gerald
360
+ Keith
361
+ Samuel
362
+ Willie
363
+ Ralph
364
+ Lawrence
365
+ Nicholas
366
+ Roy
367
+ Benjamin
368
+ Bruce
369
+ Brandon
370
+ Adam
371
+ Harry
372
+ Fred
373
+ Wayne
374
+ Billy
375
+ Steve
376
+ Louis
377
+ Jeremy
378
+ Aaron
379
+ Randy
380
+ Howard
381
+ Eugene
382
+ Carlos
383
+ Russell
384
+ Bobby
385
+ Victor
386
+ Martin
387
+ Ernest
388
+ Phillip
389
+ Todd
390
+ Jesse
391
+ Craig
392
+ Alan
393
+ Shawn
394
+ Clarence
395
+ Sean
396
+ Philip
397
+ Chris
398
+ Johnny
399
+ Earl
400
+ Jimmy
401
+ Antonio
402
+ Danny
403
+ Bryan
404
+ Tony
405
+ Luis
406
+ Mike
407
+ Stanley
408
+ Leonard
409
+ Nathan
410
+ Dale
411
+ Manuel
412
+ Rodney
413
+ Curtis
414
+ Norman
415
+ Allen
416
+ Marvin
417
+ Vincent
418
+ Glenn
419
+ Jeffery
420
+ Travis
421
+ Jeff
422
+ Chad
423
+ Jacob
424
+ Lee
425
+ Melvin
426
+ Alfred
427
+ Kyle
428
+ Francis
429
+ Bradley
430
+ Jesus
431
+ Herbert
432
+ Frederick
433
+ Ray
434
+ Joel
435
+ Edwin
436
+ Don
437
+ Eddie
438
+ Ricky
439
+ Troy
440
+ Randall
441
+ Barry
442
+ Alexander
443
+ Bernard
444
+ Mario
445
+ Leroy
446
+ Francisco
447
+ Marcus
448
+ Micheal
449
+ Theodore
450
+ Clifford
451
+ Miguel
452
+ Oscar
453
+ Jay
454
+ Jim
455
+ Tom
456
+ Calvin
457
+ Alex
458
+ Jon
459
+ Ronnie
460
+ Bill
461
+ Lloyd
462
+ Tommy
463
+ Leon
464
+ Derek
465
+ Warren
466
+ Darrell
467
+ Jerome
468
+ Floyd
469
+ Leo
470
+ Alvin
471
+ Tim
472
+ Wesley
473
+ Gordon
474
+ Dean
475
+ Greg
476
+ Jorge
477
+ Dustin
478
+ Pedro
479
+ Derrick
480
+ Dan
481
+ Lewis
482
+ Zachary
483
+ Corey
484
+ Herman
485
+ Maurice
486
+ Vernon
487
+ Roberto
488
+ Clyde
489
+ Glen
490
+ Hector
491
+ Shane
492
+ Ricardo
493
+ Sam
494
+ Rick
495
+ Lester
496
+ Brent
497
+ Ramon
498
+ Charlie
499
+ Tyler
500
+ Gilbert
501
+ Gene
502
+ Marc
503
+ Reginald
504
+ Ruben
505
+ Brett
506
+ Angel
507
+ Nathaniel
508
+ Rafael
509
+ Leslie
510
+ Edgar
511
+ Milton
512
+ Raul
513
+ Ben
514
+ Chester
515
+ Cecil
516
+ Duane
517
+ Franklin
518
+ Andre
519
+ Elmer
520
+ Brad
521
+ Gabriel
522
+ Ron
523
+ Mitchell
524
+ Roland
525
+ Arnold
526
+ Harvey
527
+ Jared
528
+ Adrian
529
+ Karl
530
+ Cory
531
+ Claude
532
+ Erik
533
+ Darryl
534
+ Jamie
535
+ Neil
536
+ Jessie
537
+ Christian
538
+ Javier
539
+ Fernando
540
+ Clinton
541
+ Ted
542
+ Mathew
543
+ Tyrone
544
+ Darren
545
+ Lonnie
546
+ Lance
547
+ Cody
548
+ Julio
549
+ Kelly
550
+ Kurt
551
+ Allan
552
+ Nelson
553
+ Guy
554
+ Clayton
555
+ Hugh
556
+ Max
557
+ Dwayne
558
+ Dwight
559
+ Armando
560
+ Felix
561
+ Jimmie
562
+ Everett
563
+ Jordan
564
+ Ian
565
+ Wallace
566
+ Ken
567
+ Bob
568
+ Jaime
569
+ Casey
570
+ Alfredo
571
+ Alberto
572
+ Dave
573
+ Ivan
574
+ Johnnie
575
+ Sidney
576
+ Byron
577
+ Julian
578
+ Isaac
579
+ Morris
580
+ Clifton
581
+ Willard
582
+ Daryl
583
+ Ross
584
+ Virgil
585
+ Andy
586
+ Marshall
587
+ Salvador
588
+ Perry
589
+ Kirk
590
+ Sergio
591
+ Marion
592
+ Tracy
593
+ Seth
594
+ Kent
595
+ Terrance
596
+ Rene
597
+ Eduardo
598
+ Terrence
599
+ Enrique
600
+ Freddie
601
+ Wade
602
+ EOF