-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
661 lines (501 loc) · 10.9 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
require 'sinatra'
require 'json'
require 'faker'
locales = ['ca-CAT', 'ca', 'da-DK', 'de-AT', 'de-CH', 'de', 'en-AU', 'en-BORK', 'en-CA', 'en-GB', 'en-IND', 'en-NEP', 'en-NG', 'en-NZ', 'en-PAK', 'en-SG', 'en-UG', 'en-US', 'en-ZA', 'en-au-ocker', 'en', 'es-MX', 'es', 'fa', 'fi-FI', 'fr', 'he', 'it', 'ja', 'ko', 'nb-NO', 'nl', 'pl', 'pt-BR', 'pt', 'ru', 'sk', 'sv', 'uk', 'vi', 'zh-CN', 'zh-TW']
# executed only once, at startup
configure do
# to prevents errors due to Rack::Protection::JsonCsrf
disable :protection
end
# Before processing each http request
before do
# Set the response headers
cache_control :no_cache
content_type 'text/plain'
# If a locale parameter is included in the request,
# change to that locale
if params.key?('locale')
locale_param = params['locale']
if locales.include?(locale_param)
puts "Switching to the #{locale_param.to_sym} locale"
Faker::Config.locale = locale_param.to_sym
end
end
end
# After processing each http request
after do
# Revert to the default english locale
Faker::Config.locale = :en
end
get '/faker/locales' do
content_type 'application/json'
locales.to_json
end
get '/faker/name' do
Faker::Name.name
end
get '/faker/name-with-middle' do
Faker::Name.name_with_middle
end
get '/faker/name/firstname' do
Faker::Name.first_name
end
get '/faker/name/lastname' do
Faker::Name.last_name
end
get '/faker/name/prefix' do
Faker::Name.prefix
end
get '/faker/name/suffix' do
Faker::Name.suffix
end
get '/faker/name/title' do
Faker::Name.title
end
get '/faker/phone-number' do
Faker::PhoneNumber.phone_number
end
get '/faker/phone-number/cell-phone' do
Faker::PhoneNumber.cell_phone
end
get '/faker/phone-number/area-code' do
Faker::PhoneNumber.area_code
end
get '/faker/phone-number/exchange-code' do
Faker::PhoneNumber.exchange_code
end
get '/faker/phone-number/subscriber' do
Faker::PhoneNumber.subscriber_number
end
get '/faker/phone-number/extension' do
Faker::PhoneNumber.extension
end
get '/faker/address/city' do
Faker::Address.city
end
get '/faker/address/street-name' do
Faker::Address.street_name
end
get '/faker/address/street-address' do
Faker::Address.street_address
end
get '/faker/address/secondary-address' do
Faker::Address.secondary_address
end
get '/faker/address/building-number' do
Faker::Address.building_number
end
get '/faker/address/zip-code' do
Faker::Address.zip_code
end
get '/faker/address/zip' do
Faker::Address.zip
end
get '/faker/address/postcode' do
Faker::Address.postcode
end
get '/faker/address/time-zone' do
Faker::Address.time_zone
end
get '/faker/address/street-suffix' do
Faker::Address.street_suffix
end
get '/faker/address/city-suffix' do
Faker::Address.city_suffix
end
get '/faker/address/city-prefix' do
Faker::Address.city_prefix
end
get '/faker/address/state' do
Faker::Address.state
end
get '/faker/address/state-abbr' do
Faker::Address.state_abbr
end
get '/faker/address/country' do
Faker::Address.country
end
get '/faker/address/country-code' do
Faker::Address.country_code
end
get '/faker/address/latitude' do
Faker::Address.latitude
end
get '/faker/address/longitude' do
Faker::Address.longitude
end
get '/faker/business/credit-card/number' do
Faker::Business.credit_card_number
end
get '/faker/business/credit-card/expiry-date' do
Faker::Business.credit_card_expiry_date
end
get '/faker/business/credit-card/type' do
Faker::Business.credit_card_type
end
get '/faker/commerce/department' do
Faker::Commerce.department
end
get '/faker/commerce/product-name' do
Faker::Commerce.product_name
end
get '/faker/commerce/price' do
Faker::Commerce.price
end
get '/faker/company/name' do
Faker::Company.name
end
get '/faker/company/suffix' do
Faker::Company.suffix
end
get '/faker/company/catch-phrase' do
Faker::Company.catch_phrase
end
get '/faker/company/buzzword' do
Faker::Company.buzzword
end
get '/faker/company/bs' do
Faker::Company.bs
end
get '/faker/company/ein' do
Faker::Company.ein
end
get '/faker/company/duns' do
Faker::Company.duns_number
end
get '/faker/company/logo' do
Faker::Company.logo
end
get '/faker/company/swedish-organisation-number' do
Faker::Company.swedish_organisation_number
end
get '/faker/company/australian-business-number' do
Faker::Company.australian_business_number
end
get '/faker/company/profession' do
Faker::Company.profession
end
get '/faker/book/title' do
Faker::Book.title
end
get '/faker/book/author' do
Faker::Book.author
end
get '/faker/book/publisher' do
Faker::Book.publisher
end
get '/faker/book/genre' do
Faker::Book.genre
end
get '/faker/educator/university' do
Faker::Educator.university
end
get '/faker/educator/secondary-school' do
Faker::Educator.secondary_school
end
get '/faker/educator/course' do
Faker::Educator.course
end
get '/faker/educator/campus' do
Faker::Educator.campus
end
get '/faker/team/name' do
Faker::Team.name
end
get '/faker/team/state' do
Faker::Team.state
end
get '/faker/team/sport' do
Faker::Team.sport
end
get '/faker/team/creature' do
Faker::Team.creature
end
get '/faker/bitcoin/address' do
Faker::Bitcoin.address
end
get '/faker/bitcoin/testnet-address' do
Faker::Bitcoin.testnet_address
end
get '/faker/codes/isbn' do
Faker::Code.isbn
end
get '/faker/codes/ean' do
Faker::Code.ean
end
get '/faker/codes/imei' do
Faker::Code.imei
end
get '/faker/codes/asin' do
Faker::Code.asin
end
get '/faker/color/hex' do
Faker::Color.hex_color
end
get '/faker/color/name' do
Faker::Color.color_name
end
get '/faker/color/rgb' do
Faker::Color.rgb_color.join(",")
end
get '/faker/color/hsl' do
Faker::Color.hsl_color.join(",")
end
get '/faker/color/hsla' do
Faker::Color.hsla_color.join(",")
end
get '/faker/internet/email' do
Faker::Internet.email
end
get '/faker/internet/free-email' do
Faker::Internet.free_email
end
get '/faker/internet/safe-email' do
Faker::Internet.safe_email
end
get '/faker/internet/username' do
Faker::Internet.user_name
end
get '/faker/internet/password' do
Faker::Internet.password
end
get '/faker/internet/domain-name' do
Faker::Internet.domain_name
end
get '/faker/internet/domain-suffix' do
Faker::Internet.domain_suffix
end
get '/faker/internet/ipv4' do
Faker::Internet.ip_v4_address
end
get '/faker/internet/ipv4/private' do
Faker::Internet.private_ip_v4_address
end
get '/faker/internet/ipv4/public' do
Faker::Internet.public_ip_v4_address
end
get '/faker/internet/ipv4/cdir' do
Faker::Internet.ip_v4_cidr
end
get '/faker/internet/ipv6' do
Faker::Internet.ip_v6_address
end
get '/faker/internet/ipv6/cdir' do
Faker::Internet.ip_v6_cidr
end
get '/faker/internet/mac-address' do
Faker::Internet.mac_address
end
get '/faker/internet/url' do
Faker::Internet.url
end
get '/faker/file/name' do
Faker::File.file_name
end
get '/faker/file/extension' do
Faker::File.extension
end
get '/faker/file/mime-type' do
Faker::File.mime_type
end
get '/faker/hacker/something-smart' do
Faker::Hacker.say_something_smart
end
get '/faker/hacker/abbreviation' do
Faker::Hacker.abbreviation
end
get '/faker/hacker/adjvective' do
Faker::Hacker.adjective
end
get '/faker/hacker/noun' do
Faker::Hacker.noun
end
get '/faker/hacker/verb' do
Faker::Hacker.verb
end
get '/faker/hacker/ingverb' do
Faker::Hacker.ingverb
end
get '/faker/crypto/md5' do
Faker::Crypto.md5
end
get '/faker/crypto/sha1' do
Faker::Crypto.sha1
end
get '/faker/crypto/sha256' do
Faker::Crypto.sha256
end
get '/faker/app/name' do
Faker::App.name
end
get '/faker/app/version' do
Faker::App.version
end
get '/faker/app/author' do
Faker::App.author
end
get '/faker/slack-emoji' do
Faker::SlackEmoji.emoji
end
get '/faker/slack-emoji/people' do
Faker::SlackEmoji.people
end
get '/faker/slack-emoji/nature' do
Faker::SlackEmoji.nature
end
get '/faker/slack-emoji/food-and-drink' do
Faker::SlackEmoji.food_and_drink
end
get '/faker/slack-emoji/celebration' do
Faker::SlackEmoji.celebration
end
get '/faker/slack-emoji/activity' do
Faker::SlackEmoji.activity
end
get '/faker/slack-emoji/travel-and-places' do
Faker::SlackEmoji.travel_and_places
end
get '/faker/slack-emoji/objects-and-symbols' do
Faker::SlackEmoji.objects_and_symbols
end
get '/faker/superhero/name' do
Faker::Superhero.name
end
get '/faker/superhero/power' do
Faker::Superhero.power
end
get '/faker/starwars/character' do
Faker::StarWars.character
end
get '/faker/starwars/droid' do
Faker::StarWars.droid
end
get '/faker/starwars/planet' do
Faker::StarWars.planet
end
get '/faker/starwars/quote' do
Faker::StarWars.quote
end
get '/faker/starwars/specie' do
Faker::StarWars.specie
end
get '/faker/starwars/vehicle' do
Faker::StarWars.vehicle
end
get '/faker/space/planet' do
Faker::Space.planet
end
get '/faker/space/moon' do
Faker::Space.moon
end
get '/faker/space/galaxy' do
Faker::Space.galaxy
end
get '/faker/space/nebula' do
Faker::Space.nebula
end
get '/faker/space/star-cluster' do
Faker::Space.star_cluster
end
get '/faker/space/constellation' do
Faker::Space.constellation
end
get '/faker/space/star' do
Faker::Space.star
end
get '/faker/space/agency' do
Faker::Space.agency
end
get '/faker/space/agency-abv' do
Faker::Space.agency_abv
end
get '/faker/space/nasa-space-craft' do
Faker::Space.nasa_space_craft
end
get '/faker/space/company' do
Faker::Space.company
end
get '/faker/space/distance-measurement' do
Faker::Space.distance_measurement
end
get '/faker/music/key' do
Faker::Music.key
end
get '/faker/music/instrument' do
Faker::Music.instrument
end
get '/faker/vehicle/vin' do
Faker::Vehicle.vin
end
get '/faker/vehicle/manufacture' do
Faker::Vehicle.manufacture
end
get '/faker/gameofthrones/character' do
Faker::GameOfThrones.character
end
get '/faker/gameofthrones/house' do
Faker::GameOfThrones.house
end
get '/faker/gameofthrones/city' do
Faker::GameOfThrones.city
end
get '/faker/pokemon/name' do
Faker::Pokemon.name
end
get '/faker/pokemon/location' do
Faker::Pokemon.location
end
# Not yet released in the gem
# get '/faker/food/ingredient' do
# Faker::Food.ingredient
# end
#
# get '/faker/food/spice' do
# Faker::Food.spice
# end
#
# get '/faker/food/measurement' do
# Faker::Food.measurement
# end
get '/faker/beer/name' do
Faker::Beer.name
end
get '/faker/beer/style' do
Faker::Beer.style
end
get '/faker/beer/hop' do
Faker::Beer.hop
end
get '/faker/beer/yeast' do
Faker::Beer.yeast
end
get '/faker/beer/malts' do
Faker::Beer.malts
end
get '/faker/beer/ibu' do
Faker::Beer.ibu
end
get '/faker/beer/alcohol' do
Faker::Beer.alcohol
end
get '/faker/beer/blg' do
Faker::Beer.blg
end
get '/faker/lorem/words' do
Faker::Lorem.words
end
get '/faker/lorem/sentences' do
Faker::Lorem.sentences
end
get '/faker/lorem/paragraphs' do
Faker::Lorem.paragraphs
end
get '/faker/hipster/words' do
Faker::Hipster.words
end
get '/faker/hipster/sentences' do
Faker::Hipster.sentences
end
get '/faker/hipster/paragraphs' do
Faker::Hipster.paragraphs
end