forgery 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/README.markdown +99 -0
  2. data/VERSION.yml +4 -0
  3. data/generators/forgery/USAGE +6 -0
  4. data/generators/forgery/forgery_generator.rb +12 -0
  5. data/lib/dictionaries.rb +24 -0
  6. data/lib/dictionaries/cities +478 -0
  7. data/lib/dictionaries/colors +19 -0
  8. data/lib/dictionaries/company_names +400 -0
  9. data/lib/dictionaries/countries +249 -0
  10. data/lib/dictionaries/female_first_names +100 -0
  11. data/lib/dictionaries/frequencies +8 -0
  12. data/lib/dictionaries/genders +2 -0
  13. data/lib/dictionaries/languages +97 -0
  14. data/lib/dictionaries/last_names +250 -0
  15. data/lib/dictionaries/lorem_ipsum +151 -0
  16. data/lib/dictionaries/male_first_names +100 -0
  17. data/lib/dictionaries/name_suffixes +5 -0
  18. data/lib/dictionaries/name_titles +6 -0
  19. data/lib/dictionaries/province_abbrevs +13 -0
  20. data/lib/dictionaries/provinces +13 -0
  21. data/lib/dictionaries/races +93 -0
  22. data/lib/dictionaries/shirt_sizes +7 -0
  23. data/lib/dictionaries/state_abbrevs +50 -0
  24. data/lib/dictionaries/states +50 -0
  25. data/lib/dictionaries/street_suffixes +21 -0
  26. data/lib/dictionaries/streets +500 -0
  27. data/lib/dictionaries/top_level_domains +9 -0
  28. data/lib/extensions/array.rb +11 -0
  29. data/lib/extensions/hash.rb +12 -0
  30. data/lib/extensions/range.rb +9 -0
  31. data/lib/extensions/string.rb +48 -0
  32. data/lib/file_reader.rb +53 -0
  33. data/lib/forgeries/address_forgery.rb +136 -0
  34. data/lib/forgeries/basic_forgery.rb +71 -0
  35. data/lib/forgeries/internet_forgery.rb +17 -0
  36. data/lib/forgeries/lorem_ipsum_forgery.rb +112 -0
  37. data/lib/forgeries/monetary_forgery.rb +13 -0
  38. data/lib/forgeries/name_forgery.rb +34 -0
  39. data/lib/forgeries/personal_forgery.rb +22 -0
  40. data/lib/forgery.rb +47 -0
  41. data/lib/formats.rb +24 -0
  42. data/lib/formats/phone +1 -0
  43. data/lib/formats/street_number +5 -0
  44. data/lib/formats/zip +2 -0
  45. data/spec/dictionaries_spec.rb +35 -0
  46. data/spec/extensions/array_spec.rb +25 -0
  47. data/spec/extensions/range_spec.rb +26 -0
  48. data/spec/extensions/string_spec.rb +29 -0
  49. data/spec/file_reader_spec.rb +11 -0
  50. data/spec/forgeries/address_forgery_spec.rb +79 -0
  51. data/spec/forgeries/basic_forgery_spec.rb +175 -0
  52. data/spec/forgeries/internet_forgery_spec.rb +30 -0
  53. data/spec/forgeries/lorem_ipsum_forgery_spec.rb +128 -0
  54. data/spec/forgeries/monetary_forgery_spec.rb +4 -0
  55. data/spec/forgeries/name_forgery_spec.rb +4 -0
  56. data/spec/forgeries/personal_forgery_spec.rb +15 -0
  57. data/spec/forgery_spec.rb +42 -0
  58. data/spec/formats_spec.rb +35 -0
  59. data/spec/spec_helper.rb +32 -0
  60. metadata +114 -0
@@ -0,0 +1,99 @@
1
+ Forgery
2
+ =======
3
+
4
+ The Problem:
5
+ Making meaningful development data for your application.
6
+
7
+ The Solution:
8
+ A fake data generator that does more than just lorem ipsum and random text
9
+ (well, it does those too, but also does much more).
10
+
11
+ Forgery generates fake data from dictionaries, formats, and recipes. The
12
+ plugin includes a generator providing directories to make your own forgeries.
13
+
14
+
15
+ Install
16
+ =======
17
+
18
+ config.gem "sevenwire-forgery", :lib => "forgery", :source => "http://gems.github.com"
19
+
20
+
21
+ Generator
22
+ =========
23
+
24
+ ./script/generate forgery
25
+
26
+ In a rails project this generator creates:
27
+
28
+ * RAILS\_ROOT/lib/forgery
29
+ * RAILS\_ROOT/lib/forgery/dictionaries
30
+ * RAILS\_ROOT/lib/forgery/extensions
31
+ * RAILS\_ROOT/lib/forgery/forgeries
32
+ * RAILS\_ROOT/lib/forgery/formats
33
+
34
+ You can then use these directories to write your own dictionaries, class
35
+ extensions, forgeries, and formats.
36
+
37
+ Forgery will look first here for dictionaries and formats, so you can override
38
+ the ones used in the plugin.
39
+
40
+ See the forgeries in the plugin for examples of how to write your own.
41
+
42
+ See which dictionaries each forgery uses to override them with your own.
43
+
44
+
45
+ Examples
46
+ ========
47
+
48
+ Here I'll supply a few examples of how it works, in general. See each forgery
49
+ for individual examples.
50
+
51
+ # Traditional syntax
52
+ BasicForgery.password # => "wYMYvq"
53
+ BasicForgery.password :allow_special => true # => ";Qo^N[T"
54
+ BasicForgery.hex_color # => "#f4d841"
55
+
56
+ MonetaryForgery.money # => "8.21"
57
+ MonetaryForgery.formatted_money # => "$3.25"
58
+ MonetaryForgery.money :min => 100, :max => 1000 # => "848.97"
59
+
60
+ # Alternate syntax
61
+ Forgery(:basic).password # => "b6qZTQEH"
62
+ Forgery(:basic).password :allow_special => true # => "XlrhV%An"
63
+ Forgery(:basic).hex_color # => "#46b73f"
64
+
65
+ Forgery(:monetary).money # => "1.58"
66
+ Forgery(:monetary).formatted_money # => "$3.48"
67
+ Forgery(:monetary).money :min => 100, :max => 1000 # => "923.36"
68
+
69
+ DOCUMENTATION
70
+ =============
71
+
72
+ Documentation can be found at [http://docs.github.com/sevenwire/forgery](http://docs.github.com/sevenwire/forgery)
73
+
74
+ TODO
75
+ ====
76
+
77
+ * Add instanced forgeries for more relative information generation.
78
+ * Add markov chains.
79
+ * Add a way to use probability in forgeries.
80
+
81
+ Thanks
82
+ ======
83
+
84
+ Thanks to the authors and contributors:
85
+
86
+ * Nate Sutton (nate aka fowlduck)
87
+ * Brandon Arbini (brandonarbini)
88
+ * Josh Nichols (technicalpickles)
89
+ * Jeremy Stephens (viking aka crookshanks)
90
+
91
+ Notes
92
+ =====
93
+
94
+ This is a work in progress. If you find bugs or have forgeries to contribute,
95
+ we'll gladly take them and give credit.
96
+
97
+ Enjoy.
98
+
99
+ Nate Sutton (nate@sevenwire.com)
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 2
3
+ :patch: 2
4
+ :major: 0
@@ -0,0 +1,6 @@
1
+
2
+ ./script/generate forgery
3
+
4
+ Creates the Forgery directories in RAILS_ROOT/lib. The contents of these
5
+ directories can be used to extend Forgery, adding new forgeries and overriding
6
+ dictionaries and formats.
@@ -0,0 +1,12 @@
1
+ class ForgeryGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.directory 'lib'
5
+ m.directory 'lib/forgery'
6
+ m.directory 'lib/forgery/dictionaries'
7
+ m.directory 'lib/forgery/extensions'
8
+ m.directory 'lib/forgery/forgeries'
9
+ m.directory 'lib/forgery/formats'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ class Dictionaries
2
+
3
+ def initialize
4
+ @dictionaries = {}
5
+ end
6
+
7
+ def [](key)
8
+ symbolized_key = key.to_sym
9
+ if loaded?(symbolized_key)
10
+ @dictionaries[symbolized_key]
11
+ else
12
+ @dictionaries[symbolized_key] = FileReader.read_dictionary(symbolized_key)
13
+ end
14
+ end
15
+
16
+ def loaded?(key)
17
+ @dictionaries.has_key?(key.to_sym)
18
+ end
19
+
20
+ def reset!
21
+ @dictionaries = {}
22
+ end
23
+
24
+ end
@@ -0,0 +1,478 @@
1
+ Adelanto
2
+ Agoura Hills
3
+ Alameda
4
+ Albany
5
+ Alhambra
6
+ Aliso Viejo
7
+ Alturas
8
+ Amador City
9
+ American Canyon
10
+ Anaheim
11
+ Anderson
12
+ Angels Camp
13
+ Antioch
14
+ Apple Valley
15
+ Arcadia
16
+ Arcata
17
+ Arroyo Grande
18
+ Artesia
19
+ Arvin
20
+ Atascadero
21
+ Atherton
22
+ Atwater
23
+ Auburn
24
+ Avalon
25
+ Avenal
26
+ Azusa
27
+ Bakersfield
28
+ Baldwin Park
29
+ Banning
30
+ Barstow
31
+ Beaumont
32
+ Bell
33
+ Bell Gardens
34
+ Bellflower
35
+ Belmont
36
+ Belvedere
37
+ Benicia
38
+ Berkeley
39
+ Beverly Hills
40
+ Big Bear Lake
41
+ Biggs
42
+ Bishop
43
+ Blue Lake
44
+ Blythe
45
+ Bradbury
46
+ Brawley
47
+ Brea
48
+ Brentwood
49
+ Brisbane
50
+ Buellton
51
+ Buena Park
52
+ Burbank
53
+ Burlingame
54
+ Calabasas
55
+ Calexico
56
+ California City
57
+ Calimesa
58
+ Calipatria
59
+ Calistoga
60
+ Camarillo
61
+ Canyon Lake
62
+ Capitola
63
+ Carlsbad
64
+ Carmel-by-the-Sea
65
+ Carpinteria
66
+ Carson
67
+ Cathedral City
68
+ Ceres
69
+ Cerritos
70
+ Chico
71
+ Chino
72
+ Chino Hills
73
+ Chowchilla
74
+ Chula Vista
75
+ Citrus Heights
76
+ Claremont
77
+ Clayton
78
+ Clearlake
79
+ Cloverdale
80
+ Clovis
81
+ Coachella
82
+ Coalinga
83
+ Colfax
84
+ Colma
85
+ Colton
86
+ Colusa
87
+ City of Commerce
88
+ Compton
89
+ Concord
90
+ Corcoran
91
+ Corning
92
+ Corona
93
+ Coronado
94
+ Corte Madera
95
+ Costa Mesa
96
+ Cotati
97
+ Covina
98
+ Crescent City
99
+ Cudahy
100
+ Culver City
101
+ Cupertino
102
+ Cypress
103
+ Daly City
104
+ Dana Point
105
+ Danville
106
+ Davis
107
+ Del Mar
108
+ Del Rey Oaks
109
+ Delano
110
+ Desert Hot Springs
111
+ Diamond Bar
112
+ Dinuba
113
+ Dixon
114
+ Dorris
115
+ Dos Palos
116
+ Downey
117
+ Duarte
118
+ Dublin
119
+ Dunsmuir
120
+ East Palo Alto
121
+ El Cajon
122
+ El Centro
123
+ El Cerrito
124
+ El Monte
125
+ El Segundo
126
+ Elk Grove
127
+ Emeryville
128
+ Encinitas
129
+ Escalon
130
+ Escondido
131
+ Etna
132
+ Eureka
133
+ Exeter
134
+ Fairfax
135
+ Fairfield
136
+ Farmersville
137
+ Ferndale
138
+ Fillmore
139
+ Firebaugh
140
+ Folsom
141
+ Fontana
142
+ Fort Bragg
143
+ Fort Jones
144
+ Fortuna
145
+ Foster City
146
+ Fountain Valley
147
+ Fowler
148
+ Fremont
149
+ Fresno
150
+ Fullerton
151
+ Galt
152
+ Garden Grove
153
+ Gardena
154
+ Gilroy
155
+ Glendale
156
+ Glendora
157
+ Goleta
158
+ Gonzales
159
+ Grand Terrace
160
+ Grass Valley
161
+ Greenfield
162
+ Gridley
163
+ Grover Beach
164
+ Guadalupe
165
+ Gustine
166
+ Half Moon Bay
167
+ Hanford
168
+ Hawaiian Gardens
169
+ Hawthorne
170
+ Hayward
171
+ Healdsburg
172
+ Hemet
173
+ Hercules
174
+ Hermosa Beach
175
+ Hesperia
176
+ Hidden Hills
177
+ Highland
178
+ Hillsborough
179
+ Hollister
180
+ Holtville
181
+ Hughson
182
+ Huntington Beach
183
+ Huntington Park
184
+ Huron
185
+ Imperial
186
+ Imperial Beach
187
+ Indian Wells
188
+ Indio
189
+ City of Industry
190
+ Inglewood
191
+ Ione
192
+ Irvine
193
+ Irwindale
194
+ Isleton
195
+ Jackson
196
+ Kerman
197
+ King City
198
+ Kingsburg
199
+ La Cañada Flintridge
200
+ La Habra
201
+ La Habra Heights
202
+ La Mesa
203
+ La Mirada
204
+ La Palma
205
+ La Puente
206
+ La Quinta
207
+ La Verne
208
+ Lafayette
209
+ Laguna Beach
210
+ Laguna Hills
211
+ Laguna Niguel
212
+ Laguna Woods
213
+ Lake Elsinore
214
+ Lake Forest
215
+ Lakeport
216
+ Lakewood
217
+ Lancaster
218
+ Larkspur
219
+ Lathrop
220
+ Lawndale
221
+ Lemon Grove
222
+ Lemoore
223
+ Lincoln
224
+ Lindsay
225
+ Live Oak
226
+ Livermore
227
+ Livingston
228
+ Lodi
229
+ Loma Linda
230
+ Lomita
231
+ Lompoc
232
+ Long Beach
233
+ Loomis
234
+ Los Alamitos
235
+ Los Altos
236
+ Los Altos Hills
237
+ Los Angeles
238
+ Los Banos
239
+ Los Gatos
240
+ Loyalton
241
+ Lynwood
242
+ Madera
243
+ Malibu
244
+ Mammoth Lakes
245
+ Manhattan Beach
246
+ Manteca
247
+ Maricopa
248
+ Marina
249
+ Martinez
250
+ Marysville
251
+ Maywood
252
+ McFarland
253
+ Mendota
254
+ Menlo Park
255
+ Menifee
256
+ Merced
257
+ Mill Valley
258
+ Millbrae
259
+ Milpitas
260
+ Mission Viejo
261
+ Modesto
262
+ Monrovia
263
+ Montague
264
+ Montclair
265
+ Monte Sereno
266
+ Montebello
267
+ Monterey
268
+ Monterey Park
269
+ Moorpark
270
+ Moraga
271
+ Moreno Valley
272
+ Morgan Hill
273
+ Morro Bay
274
+ Mount Shasta
275
+ Mountain View
276
+ Murrieta
277
+ Napa
278
+ National City
279
+ Needles
280
+ Nevada City
281
+ Newark
282
+ Newman
283
+ Newport Beach
284
+ Norco
285
+ Norwalk
286
+ Novato
287
+ Oakdale
288
+ Oakland
289
+ Oakley
290
+ Oceanside
291
+ Ojai
292
+ Ontario
293
+ Orange
294
+ Orange Cove
295
+ Orinda
296
+ Orland
297
+ Oroville
298
+ Oxnard
299
+ Pacific Grove
300
+ Pacifica
301
+ Palm Desert
302
+ Palm Springs
303
+ Palmdale
304
+ Palo Alto
305
+ Palos Verdes Estates
306
+ Paradise
307
+ Paramount
308
+ Parlier
309
+ Pasadena
310
+ Paso Robles
311
+ Patterson
312
+ Perris
313
+ Petaluma
314
+ Pico Rivera
315
+ Piedmont
316
+ Pinole
317
+ Pismo Beach
318
+ Pittsburg
319
+ Placentia
320
+ Placerville
321
+ Pleasant Hill
322
+ Pleasanton
323
+ Plymouth
324
+ Point Arena
325
+ Pomona
326
+ Port Hueneme
327
+ Porterville
328
+ Portola
329
+ Portola Valley
330
+ Poway
331
+ Rancho Cordova
332
+ Rancho Cucamonga
333
+ Rancho Mirage
334
+ Rancho Palos Verdes
335
+ Rancho Santa Margarita
336
+ Red Bluff
337
+ Redding
338
+ Redlands
339
+ Redondo Beach
340
+ Redwood City
341
+ Reedley
342
+ Rialto
343
+ Richmond
344
+ Ridgecrest
345
+ Rio Dell
346
+ Rio Vista
347
+ Ripon
348
+ Riverbank
349
+ Riverside
350
+ Rocklin
351
+ Rohnert Park
352
+ Rolling Hills
353
+ Rolling Hills Estates
354
+ Rosemead
355
+ Roseville
356
+ Ross
357
+ Sacramento
358
+ Salinas
359
+ San Anselmo
360
+ San Bernardino
361
+ San Bruno
362
+ San Carlos
363
+ San Clemente
364
+ San Diego
365
+ San Dimas
366
+ San Fernando
367
+ San Francisco
368
+ San Gabriel
369
+ San Jacinto
370
+ San Joaquin
371
+ San Jose
372
+ San Juan Bautista
373
+ San Juan Capistrano
374
+ San Leandro
375
+ San Luis Obispo
376
+ San Marcos
377
+ San Marino
378
+ San Mateo
379
+ San Pablo
380
+ San Rafael
381
+ San Ramon
382
+ Sand City
383
+ Sanger
384
+ Santa Ana
385
+ Santa Barbara
386
+ Santa Clara
387
+ Santa Clarita
388
+ Santa Cruz
389
+ Santa Fe Springs
390
+ Santa Maria
391
+ Santa Monica
392
+ Santa Paula
393
+ Santa Rosa
394
+ Santee
395
+ Saratoga
396
+ Sausalito
397
+ Scotts Valley
398
+ Seal Beach
399
+ Seaside
400
+ Sebastopol
401
+ Selma
402
+ Shafter
403
+ Shasta Lake
404
+ Sierra Madre
405
+ Signal Hill
406
+ Simi Valley
407
+ Solana Beach
408
+ Soledad
409
+ Solvang
410
+ Sonoma
411
+ Sonora
412
+ South El Monte
413
+ South Gate
414
+ South Lake Tahoe
415
+ South Pasadena
416
+ South San Francisco
417
+ St. Helena
418
+ Stanton
419
+ Stockton
420
+ Studio City
421
+ Suisun City
422
+ Sunnyvale
423
+ Susanville
424
+ Sutter Creek
425
+ Taft
426
+ Tehachapi
427
+ Tehama
428
+ Temecula
429
+ Temple City
430
+ Thousand Oaks
431
+ Tiburon
432
+ Torrance
433
+ Tracy
434
+ Trinidad
435
+ Truckee
436
+ Tulare
437
+ Tulelake
438
+ Turlock
439
+ Tustin
440
+ Twentynine Palms
441
+ Ukiah
442
+ Union City
443
+ Upland
444
+ Vacaville
445
+ Vallejo
446
+ Ventura
447
+ Vernon
448
+ Victorville
449
+ Villa Park
450
+ Visalia
451
+ Vista
452
+ Walnut
453
+ Walnut Creek
454
+ Wasco
455
+ Waterford
456
+ Watsonville
457
+ Weed
458
+ West Covina
459
+ West Sacramento
460
+ Westlake Village
461
+ Westminster
462
+ Westmorland
463
+ Wheatland
464
+ Whittier
465
+ Williams
466
+ Willits
467
+ Willows
468
+ Windsor
469
+ Winters
470
+ Woodlake
471
+ Woodland
472
+ Woodside
473
+ Yorba Linda
474
+ Yountville
475
+ Yreka
476
+ Yuba City
477
+ Yucaipa
478
+ Yucca Valley