faker 1.6.6 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +310 -0
  3. data/History.md +176 -0
  4. data/README.md +61 -830
  5. data/lib/faker.rb +18 -2
  6. data/lib/faker/address.rb +7 -3
  7. data/lib/faker/ancient.rb +21 -0
  8. data/lib/faker/artist.rb +9 -0
  9. data/lib/faker/bank.rb +30 -0
  10. data/lib/faker/bitcoin.rb +1 -2
  11. data/lib/faker/code.rb +5 -5
  12. data/lib/faker/color.rb +6 -29
  13. data/lib/faker/commerce.rb +15 -2
  14. data/lib/faker/company.rb +9 -5
  15. data/lib/faker/educator.rb +3 -3
  16. data/lib/faker/esport.rb +25 -0
  17. data/lib/faker/fillmurray.rb +18 -0
  18. data/lib/faker/finance.rb +3 -1
  19. data/lib/faker/food.rb +17 -0
  20. data/lib/faker/game_of_thrones.rb +8 -0
  21. data/lib/faker/hipster.rb +1 -1
  22. data/lib/faker/internet.rb +5 -6
  23. data/lib/faker/job.rb +16 -0
  24. data/lib/faker/lord_of_the_rings.rb +13 -0
  25. data/lib/faker/lorem_pixel.rb +21 -0
  26. data/lib/faker/music.rb +12 -0
  27. data/lib/faker/number.rb +7 -0
  28. data/lib/faker/rock_band.rb +9 -0
  29. data/lib/faker/space.rb +4 -0
  30. data/lib/faker/star_wars.rb +13 -0
  31. data/lib/faker/time.rb +10 -6
  32. data/lib/faker/twin_peaks.rb +17 -0
  33. data/lib/faker/version.rb +1 -1
  34. data/lib/helpers/unique_generator.rb +24 -0
  35. data/lib/locales/de.yml +39 -5
  36. data/lib/locales/en-IND.yml +5 -2
  37. data/lib/locales/en-NG.yml +75 -0
  38. data/lib/locales/en-NZ.yml +26 -9
  39. data/lib/locales/en-US.yml +3 -0
  40. data/lib/locales/en-ZA.yml +51 -0
  41. data/lib/locales/en.yml +150 -10
  42. data/lib/locales/es-MX.yml +12 -5
  43. data/lib/locales/fr.yml +1 -1
  44. data/lib/locales/id.yml +21 -0
  45. data/lib/locales/it.yml +1 -1
  46. data/lib/locales/ja.yml +3 -0
  47. data/lib/locales/nl.yml +7 -1
  48. data/lib/locales/pl.yml +1 -1
  49. data/lib/locales/pt-BR.yml +22 -22
  50. data/lib/locales/tr.yml +26 -0
  51. metadata +21 -4
  52. data/History.txt +0 -180
data/README.md CHANGED
@@ -11,7 +11,8 @@ development.
11
11
 
12
12
  ### NOTE
13
13
 
14
- * While Faker generates data at random, returned values are not guaranteed to be unique.
14
+ * While Faker generates data at random, returned values are not guaranteed to be unique by default.
15
+ You must explicity specify when you require unique values, see [details](#ensuring-unique-values).
15
16
  * This is the `master` branch of Faker and may contain changes that are not yet released.
16
17
  Please refer the README of your version for the available methods.
17
18
  List of all versions is [available here](https://github.com/stympy/faker/releases).
@@ -21,849 +22,79 @@ Contents
21
22
 
22
23
  - [Installing](#installing)
23
24
  - [Usage](#usage)
24
- - [Faker::Address](#fakeraddress)
25
- - [Faker::Bitcoin](#fakerbitcoin)
26
- - [Faker::Business](#fakerbusiness)
27
- - [Faker::Code](#fakercode)
28
- - [Faker::Color](#fakercolor)
29
- - [Faker::Commerce](#fakercommerce)
30
- - [Faker::Company](#fakercompany)
31
- - [Faker::Date](#fakerdate)
32
- - [Faker::Internet](#fakerinternet)
33
- - [Faker::File](#fakerfile)
34
- - [Faker::Lorem](#fakerlorem)
35
- - [Faker::Name](#fakername)
36
- - [Faker::Number](#fakernumber)
37
- - [Faker::Boolean](#fakerboolean)
38
- - [Faker::PhoneNumber](#fakerphonenumber)
39
- - [Faker::Time](#fakertime)
40
- - [Faker::Hacker](#fakerhacker)
41
- - [Faker::Crypto](#fakercrypto)
42
- - [Faker::App](#fakerapp)
43
- - [Faker::SlackEmoji](#fakerslackemoji)
44
- - [Faker::Team](#fakerteam)
45
- - [Faker::Book](#fakerbook)
46
- - [Faker::University](#fakeruniversity)
47
- - [Faker::Placeholdit](#fakerplaceholdit)
48
- - [Faker::Hipster](#fakerhipster)
49
- - [Faker::Superhero](#fakersuperhero)
50
- - [Faker::StarWars](#fakerstarwars)
51
- - [Faker::Beer](#fakerbeer)
52
- - [Faker::ChuckNorris](#fakerchucknorris)
53
- - [Faker::Educator](#fakereducator)
54
- - [Faker::Space](#fakerspace)
55
- - [Faker::Music](#fakermusic)
56
- - [Faker::Vehicle](#fakervehicle)
57
- - [Faker::GameOfThrones](#fakergameofthrones)
58
- - [Faker::Pokemon](#fakerpokemon)
25
+ - [Faker::Address](doc/address.md)
26
+ - [Faker::Ancient](doc/ancient.md)
27
+ - [Faker::App](doc/app.md)
28
+ - [Faker::Avatar](doc/avatar.md)
29
+ - [Faker::Bank](doc/bank.md)
30
+ - [Faker::Beer](doc/beer.md)
31
+ - [Faker::Bitcoin](doc/bitcoin.md)
32
+ - [Faker::Book](doc/book.md)
33
+ - [Faker::Boolean](doc/boolean.md)
34
+ - [Faker::Business](doc/business.md)
35
+ - [Faker::Cat](doc/cat.md)
36
+ - [Faker::ChuckNorris](doc/chuck_norris.md)
37
+ - [Faker::Code](doc/code.md)
38
+ - [Faker::Color](doc/color.md)
39
+ - [Faker::Commerce](doc/commerce.md)
40
+ - [Faker::Company](doc/company.md)
41
+ - [Faker::Crypto](doc/crypto.md)
42
+ - [Faker::Date](doc/date.md)
43
+ - [Faker::Educator](doc/educator.md)
44
+ - [Faker::File](doc/file.md)
45
+ - [Faker::Fillmurray](doc/fillmurray.md)
46
+ - [Faker::Food](doc/food.md)
47
+ - [Faker::GameOfThrones](doc/game_of_thrones.md)
48
+ - [Faker::Hacker](doc/hacker.md)
49
+ - [Faker::Hipster](doc/hipster.md)
50
+ - [Faker::Internet](doc/internet.md)
51
+ - [Faker::LordOfTheRings](doc/lord_of_the_rings.md)
52
+ - [Faker::LoremPixel](doc/lorem_pixel.md)
53
+ - [Faker::Lorem](doc/lorem.md)
54
+ - [Faker::Music](doc/music.md)
55
+ - [Faker::Name](doc/name.md)
56
+ - [Faker::Number](doc/number.md)
57
+ - [Faker::PhoneNumber](doc/phone_number.md)
58
+ - [Faker::Placeholdit](doc/placeholdit.md)
59
+ - [Faker::Pokemon](doc/pokemon.md)
60
+ - [Faker::RockBand](doc/rock_band.md)
61
+ - [Faker::SlackEmoji](doc/slack_emoji.md)
62
+ - [Faker::Space](doc/space.md)
63
+ - [Faker::StarWars](doc/star_wars.md)
64
+ - [Faker::Superhero](doc/superhero.md)
65
+ - [Faker::Team](doc/team.md)
66
+ - [Faker::Time](doc/time.md)
67
+ - [Faker::TwinPeaks](doc/twin_peaks.md)
68
+ - [Faker::University](doc/university.md)
69
+ - [Faker::Vehicle](doc/vehicle.md)
59
70
  - [Customization](#customization)
60
71
  - [Contributing](#contributing)
61
72
  - [Contact](#contact)
62
73
  - [License](#license)
63
74
 
64
- Installing
65
- ----------
75
+ ## Installing
76
+
66
77
  ```bash
67
78
  gem install faker
68
79
  ```
69
80
 
70
- ##Usage
71
- -----
81
+ ## Usage
82
+
72
83
  ```ruby
73
84
  Faker::Name.name #=> "Christophe Bartell"
74
85
 
75
86
  Faker::Internet.email #=> "kirsten.greenholt@corkeryfisher.info"
76
87
  ```
77
88
 
78
- ### Faker::Address
79
- -----------------
80
-
81
- ```ruby
82
- Faker::Address.city #=> "Imogeneborough"
83
-
84
- Faker::Address.street_name #=> "Larkin Fork"
85
-
86
- Faker::Address.street_address #=> "282 Kevin Brook"
87
-
88
- Faker::Address.secondary_address #=> "Apt. 672"
89
-
90
- Faker::Address.building_number #=> "7304"
91
-
92
- Faker::Address.zip_code #=> "58517"
93
-
94
- Faker::Address.zip #=> "58517"
95
-
96
- Faker::Address.postcode #=> "58517"
97
-
98
- Faker::Address.time_zone #=> "Asia/Yakutsk"
99
-
100
- Faker::Address.street_suffix #=> "Street"
101
-
102
- Faker::Address.city_suffix #=> "fort"
103
-
104
- Faker::Address.city_prefix #=> "Lake"
105
-
106
- Faker::Address.state #=> "California"
107
-
108
- Faker::Address.state_abbr #=> "AP"
109
-
110
- Faker::Address.country #=> "French Guiana"
111
-
112
- Faker::Address.country_code #=> "IT"
113
-
114
- Faker::Address.latitude #=> "-58.17256227443719"
115
-
116
- Faker::Address.longitude #=> "-156.65548382095133"
117
-
118
-
119
- ```
120
-
121
- ###Faker::Bitcoin
122
- -----------------
123
-
124
- ```ruby
125
-
126
- Faker::Bitcoin.address #=> "1HUoGjmgChmnxxYhz87YytV4gVjfPaExmh"
127
- Faker::Bitcoin.testnet_address #=> "msHGunDvoEwmVFXvd2Bub1SNw5RP1YHJaf"
128
-
129
- ```
130
-
131
- ###Faker::Business
132
- ------------------
133
-
134
- ```ruby
135
-
136
- Faker::Business.credit_card_number #=> "1228-1221-1221-1431"
137
-
138
- Faker::Business.credit_card_expiry_date #=> <Date: 2015-11-11 ((2457338j,0s,0n),+0s,2299161j)>
139
-
140
- Faker::Business.credit_card_type #=> "visa"
141
-
142
- ```
143
-
144
- ###Faker::Code
145
- --------------
146
-
147
- ```ruby
148
-
149
- Faker::Code.isbn #=> "759021701-8"
150
-
151
- Faker::Code.ean #=> "4600051000057"
152
-
153
- Faker::Code.imei #= "546327785982623"
154
-
155
- Faker::Code.asin #=> "B00000IGGJ"
156
-
157
- ```
158
-
159
- ###Faker::Color
160
- ---------------
161
-
162
- ```ruby
163
-
164
- Faker::Color.hex_color #=> "#31a785"
165
-
166
- Faker::Color.color_name #=> "yellow"
167
-
168
- Faker::Color.rgb_color #=> [54, 233, 67]
169
-
170
- Faker::Color.hsl_color #=> [69.87, 169.66, 225.3]
171
-
172
- Faker::Color.hsla_color #=> [154.77, 232.36, 58.9, 0.26170574657729073]
173
-
174
- ```
175
-
176
- ###Faker::Commerce
177
- ------------------
178
-
179
- ```ruby
180
-
181
- Faker::Commerce.color #=> "lavender"
182
-
183
- # Optional arguments max=3, fixed_amount=false
184
- Faker::Commerce.department #=> "Grocery, Health & Beauty"
185
- Faker::Commerce.department(5) #=> "Grocery, Books, Health & Beauty"
186
- Faker::Commerce.department(2, true) #=> "Books & Tools"
187
-
188
- Faker::Commerce.product_name #=> "Practical Granite Shirt"
189
-
190
- Faker::Commerce.price #=> "44.6"
191
-
192
- ```
193
-
194
- ###Faker::Company
195
- -----------------
196
-
197
- ```ruby
198
-
199
- Faker::Company.name #=> "Hirthe-Ritchie"
200
-
201
- Faker::Company.suffix #=> "Group"
202
-
203
- # Generate a buzzword-laden catch phrase.
204
- Faker::Company.catch_phrase #=> "Business-focused coherent parallelism"
205
-
206
- Faker::Company.buzzword #=> "Business-focused"
207
-
208
- # When a straight answer won't do, BS to the rescue!
209
- Faker::Company.bs #=> "empower one-to-one web-readiness"
210
-
211
- Faker::Company.ein #=> "34-8488813"
212
-
213
- Faker::Company.duns_number #=> "08-341-3736"
214
-
215
- # Get a random company logo url in PNG format.
216
- Faker::Company.logo #=> "https://pigment.github.com/fake-logos/logos/medium/color/5.png"
217
-
218
- Faker::Company.swedish_organisation_number #=> "7718797652"
219
-
220
- # Generate an Australian Business Number
221
- Faker::Company.australian_business_number #=> "81137773602"
222
-
223
- # Get a random profession
224
- Faker::Company.profession #=> "firefighter"
225
-
226
- ```
227
-
228
- ###Faker::Date
229
- ---------------------
230
-
231
- ```ruby
232
- # Random date between dates
233
- Faker::Date.between(2.days.ago, Date.today) #=> "Wed, 24 Sep 2014"
234
-
235
- # Random date between dates except for certain date
236
- Faker::Date.between_except(1.year.ago, 1.year.from_now, Date.today) #=> "Wed, 24 Sep 2014"
237
-
238
- # Random date in the future (up to maximum of N days)
239
- Faker::Date.forward(23) # => "Fri, 03 Oct 2014"
240
-
241
- # Random date in the past (up to maximum of N days)
242
- Faker::Date.backward(14) #=> "Fri, 19 Sep 2014"
243
- ```
244
-
245
- ###Faker::Internet
246
- ---------------
247
-
248
- ```ruby
249
- # Optional argument name=nil
250
- Faker::Internet.email #=> "eliza@mann.net"
251
-
252
- Faker::Internet.email('Nancy') #=> "nancy@terry.biz"
253
-
254
- # Optional argument name=nil
255
- Faker::Internet.free_email #=> "freddy@gmail.com"
256
-
257
- Faker::Internet.free_email('Nancy') #=> "nancy@yahoo.com"
258
-
259
- # Optional argument name=nil
260
- Faker::Internet.safe_email #=> "christelle@example.org"
261
-
262
- Faker::Internet.safe_email('Nancy') #=> "nancy@example.net"
263
-
264
- # Optional arguments specifier=nil, separators=%w(. _)
265
- Faker::Internet.user_name #=> "alexie"
266
-
267
- Faker::Internet.user_name('Nancy') #=> "nancy"
268
-
269
- Faker::Internet.user_name('Nancy Johnson', %w(. _ -)) #=> "johnson-nancy"
270
-
271
- # Optional arguments: min_length=8, max_length=16
272
- Faker::Internet.password #=> "vg5msvy1uerg7"
273
-
274
- Faker::Internet.password(8) #=> "yfgjik0hgzdqs0"
275
-
276
- Faker::Internet.password(10, 20) #=> "eoc9shwd1hwq4vbgfw"
277
-
278
- Faker::Internet.password(10, 20, true) #=> "3k5qS15aNmG"
279
-
280
- Faker::Internet.password(10, 20, true, true) #=> "*%NkOnJsH4"
281
-
282
- Faker::Internet.domain_name #=> "effertz.info"
283
-
284
- Faker::Internet.fix_umlauts('äöüß') #=> "aeoeuess"
285
-
286
- Faker::Internet.domain_word #=> "haleyziemann"
287
-
288
- Faker::Internet.domain_suffix #=> "info"
289
-
290
- Faker::Internet.ip_v4_address #=> "24.29.18.175"
291
-
292
- # Private IP range according to RFC 1918 and 127.0.0.0/8 and 169.254.0.0/16.
293
- Faker::Internet.private_ip_v4_address #=> "10.0.0.1"
294
-
295
- # Guaranteed not to be in the ip range from the private_ip_v4_address method.
296
- Faker::Internet.public_ip_v4_address #=> "24.29.18.175"
297
-
298
- Faker::Internet.ip_v4_cidr #=> "24.29.18.175/21"
299
-
300
- Faker::Internet.ip_v6_address #=> "ac5f:d696:3807:1d72:2eb5:4e81:7d2b:e1df"
301
-
302
- Faker::Internet.ip_v6_cidr #=> "ac5f:d696:3807:1d72:2eb5:4e81:7d2b:e1df/78"
303
-
304
- # Optional argument prefix=''
305
- Faker::Internet.mac_address #=> "e6:0d:00:11:ed:4f"
306
- Faker::Internet.mac_address('55:44:33') #=> "55:44:33:02:1d:9b"
307
-
308
- # Optional arguments: host=domain_name, path="/#{user_name}"
309
- Faker::Internet.url #=> "http://thiel.com/chauncey_simonis"
310
- Faker::Internet.url('example.com') #=> "http://example.com/clotilde.swift"
311
- Faker::Internet.url('example.com', '/foobar.html') #=> "http://example.com/foobar.html"
312
-
313
- # Optional arguments: words=nil, glue=nil
314
- Faker::Internet.slug #=> "pariatur_laudantium"
315
- Faker::Internet.slug('foo bar') #=> "foo.bar"
316
- Faker::Internet.slug('foo bar', '-') #=> "foo-bar"
317
-
318
-
319
- ```
320
-
321
- ###Faker::File
322
- ---------------
323
- ```ruby
324
- Faker::File.extension #=> "mp3"
325
- Faker::File.mime_type #=> "application/pdf"
326
- # Optional arguments: dir, name, extension, directory_separator
327
- Faker::File.file_name('path/to') #=> "path/to/something_random.jpg"
328
- Faker::File.file_name('foo/bar', 'baz') #=> "foo/bar/baz.zip"
329
- Faker::File.file_name('foo/bar', 'baz', 'doc') #=> "foo/bar/baz.doc"
330
- Faker::File.file_name('foo/bar', 'baz', 'mp3', '\') #=> "foo\bar\baz.mp3"
331
- ```
332
-
333
- ###Faker::Lorem
334
- ---------------
335
-
336
- ```ruby
337
-
338
- Faker::Lorem.word #=> "repellendus"
339
-
340
- # Optional arguments: num=3, supplemental=false (words from a supplementary list of Lorem-like words)
341
- Faker::Lorem.words #=> ["dolores", "adipisci", "nesciunt"]
342
- Faker::Lorem.words(4) #=> ["culpa", "recusandae", "aut", "omnis"]
343
- Faker::Lorem.words(4, true) #=> ["colloco", "qui", "vergo", "deporto"]
344
-
345
- # Optional arguments: char_count=255
346
- Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5wrj85fefue0y7y6m56b6omquh7br7dhqijwlawejpl765nb1716idmp3xnfo85v349pzy2o9rir23y2qhflwr71c1585fnynguiphkjm8p0vktwitcsm16lny7jzp9t4drwav3qmhz4yjq4k04x14gl6p148hulyqioo72tf8nwrxxcclfypz2lc58lsibgfe5w5p0xv95peafjjmm2frkhdc6duoky0aha"
347
- Faker::Lorem.characters(10) #=> "ang9cbhoa8"
348
-
349
- # Optional arguments: word_count=4, supplemental=false, random_words_to_add=6
350
- Faker::Lorem.sentence #=> "Dolore illum animi et neque accusantium."
351
- Faker::Lorem.sentence(3) #=> "Commodi qui minus deserunt sed vero quia."
352
- Faker::Lorem.sentence(3, true) #=> "Inflammatio denego necessitatibus caelestis autus illum."
353
- Faker::Lorem.sentence(3, false, 4) #=> "Aut voluptatem illum fugit ut sit."
354
- Faker::Lorem.sentence(3, true, 4) #=> "Accusantium tantillus dolorem timor."
355
-
356
- # Optional arguments: sentence_count=3, supplemental=false
357
- Faker::Lorem.sentences #=> ["Vero earum commodi soluta.", "Quaerat fuga cumque et vero eveniet omnis ut.", "Cumque sit dolor ut est consequuntur."]
358
- Faker::Lorem.sentences(1) #=> ["Ut perspiciatis explicabo possimus doloribus enim quia."]
359
- Faker::Lorem.sentences(1, true) #=> ["Quis capillus curo ager veritatis voro et ipsum."]
360
-
361
- # Optional arguments: sentence_count=3, supplemental=false, random_sentences_to_add=3
362
- Faker::Lorem.paragraph #=> "Neque dicta enim quasi. Qui corrupti est quisquam. Facere animi quod aut. Qui nulla consequuntur consectetur sapiente."
363
- Faker::Lorem.paragraph(2) #=> "Illo qui voluptas. Id sit quaerat enim aut cupiditate voluptates dolorum. Porro necessitatibus numquam dolor quia earum."
364
- Faker::Lorem.paragraph(2, true) #=> "Cedo vero adipisci. Theatrum crustulum coaegresco tonsor crastinus stabilis. Aliqua crur consequatur amor una tolero sum."
365
- Faker::Lorem.paragraph(2, false, 4) #=> "Neque aut et nemo aut incidunt voluptates. Dolore cum est sint est. Vitae assumenda porro odio dolores fugiat. Est voluptatum quia rerum."
366
- Faker::Lorem.paragraph(2, true, 4) #=> "Vomito unde uxor annus. Et patior utilis sursum."
367
-
368
- # Optional arguments: paragraph_count=3, supplemental=false
369
- Faker::Lorem.paragraphs #=> ["Dolores quis quia ad quo voluptates. Maxime delectus totam numquam. Necessitatibus vel atque qui dolore.", "Id neque nemo. Dolores iusto facere est ad. Accusamus ipsa dolor ut.", "Et officiis ut hic. Sunt asperiores minus distinctio debitis ipsa dolor. Minima eos deleniti."]
370
- Faker::Lorem.paragraphs(1) #=> ["Labore voluptas sequi. Ratione nulla eaque quia molestiae fugit. At quam laboriosam aut ut dignissimos."]
371
- Faker::Lorem.paragraphs(1, true) #=> ["Depulso animi cunctatio amicitia adficio. Vester viduo qui despirmatio voluptas. Validus laudantium adopto ut agnitio venustas. Aer arcus odio esse."]
372
-
373
- ```
374
-
375
- ###Faker::Name
376
- --------------
377
-
378
- ```ruby
379
-
380
- Faker::Name.name #=> "Tyshawn Johns Sr."
381
-
382
- Faker::Name.name_with_middle #=> "Aditya Elton Douglas"
383
-
384
- Faker::Name.first_name #=> "Kaci"
385
-
386
- Faker::Name.last_name #=> "Ernser"
387
-
388
- Faker::Name.prefix #=> "Mr."
389
-
390
- Faker::Name.suffix #=> "IV"
391
-
392
- Faker::Name.title #=> "Legacy Creative Director"
393
-
394
- ```
395
-
396
- ###Faker::Avatar
397
- ----------------
398
-
399
- ```ruby
400
-
401
- Faker::Avatar.image #=> "https://robohash.org/sitsequiquia.png?size=300x300"
402
-
403
- Faker::Avatar.image("my-own-slug") #=> "https://robohash.org/my-own-slug.png?size=300x300"
404
-
405
- Faker::Avatar.image("my-own-slug", "50x50") #=> "https://robohash.org/my-own-slug.png?size=50x50"
406
-
407
- Faker::Avatar.image("my-own-slug", "50x50", "jpg") #=> "https://robohash.org/my-own-slug.jpg?size=50x50"
408
-
409
- Faker::Avatar.image("my-own-slug", "50x50", "bmp") #=> "https://robohash.org/my-own-slug.bmp?size=50x50"
410
-
411
- Faker::Avatar.image("my-own-slug", "50x50", "bmp", "set1", "bg1") #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1"
412
- ```
413
-
414
- ###Faker::Number
415
- ----------------
416
-
417
- ```ruby
418
-
419
- # Required parameter: digits
420
- Faker::Number.number(10) #=> "1968353479"
421
-
422
- # Required parameter: l_digits
423
- Faker::Number.decimal(2) #=> "11.88"
424
-
425
- Faker::Number.decimal(2, 3) #=> "18.843"
426
-
427
- # Required parameter: digits
428
- Faker::Number.hexadecimal(3) #=> "e74"
429
-
430
- Faker::Number.between(1, 10) #=> 7
431
-
432
- Faker::Number.positive #=> 235.59238499107653
433
-
434
- Faker::Number.negative #=> -4480.042585669558
435
-
436
- Faker::Number.digit #=> "1"
437
-
438
- ```
439
-
440
- ###Faker::Boolean
441
- ----------------
442
-
443
- ```ruby
444
-
445
- # Optional parameter: true_ratio=0.5
446
- Faker::Boolean.boolean #=> true
447
-
448
- Faker::Boolean.boolean(0.2) #=> false
449
-
450
- ```
451
-
452
- ###Faker::PhoneNumber
453
- ---------------------
454
-
455
- Phone numbers may be in any of the following formats:
456
-
457
- * 333-333-3333
458
- * (333) 333-3333
459
- * 1-333-333-3333
460
- * 333.333.3333
461
- * 333-333-3333
462
- * 333-333-3333 x3333
463
- * (333) 333-3333 x3333
464
- * 1-333-333-3333 x3333
465
- * 333.333.3333 x3333
466
-
467
- (Don't let the example output below fool you - any format can be returned at random.)
468
-
469
- ```ruby
470
-
471
- Faker::PhoneNumber.phone_number #=> "397.693.1309"
472
-
473
- Faker::PhoneNumber.cell_phone #=> "(186)285-7925"
474
-
475
- # NOTE NOTE NOTE NOTE
476
- # For the 'US only' methods below, first you must do the following:
477
- Faker::Config.locale = 'en-US'
478
-
479
- # US only
480
- Faker::PhoneNumber.area_code #=> "201"
481
-
482
- # US only
483
- Faker::PhoneNumber.exchange_code #=> "208"
484
-
485
- # Optional parameter: length=4
486
- Faker::PhoneNumber.subscriber_number #=> "3873"
487
-
488
- Faker::PhoneNumber.subscriber_number(2) #=> "39"
489
-
490
- Faker::PhoneNumber.extension #=> "3764"
491
-
492
- ```
493
-
494
- ###Faker::Time
495
- ---------------------
496
-
497
- ```ruby
498
- # Random date between dates
499
- Faker::Time.between(DateTime.now - 1, DateTime.now) #=> "2014-09-18 12:30:59 -0700"
500
-
501
- # Random date between dates (within specified part of the day)
502
- # You can install the as-duration gem to facilitate time manipulation like 45.minutes + 2.hours
503
- # (not needed if you already have activesupport, which is included with Rails)
504
- require 'as-duration'
505
- Faker::Time.between(2.days.ago, Date.today, :all) #=> "2014-09-19 07:03:30 -0700"
506
- Faker::Time.between(2.days.ago, Date.today, :day) #=> "2014-09-18 16:28:13 -0700"
507
- Faker::Time.between(2.days.ago, Date.today, :night) #=> "2014-09-20 19:39:38 -0700"
508
- Faker::Time.between(2.days.ago, Date.today, :morning) #=> "2014-09-19 08:07:52 -0700"
509
- Faker::Time.between(2.days.ago, Date.today, :afternoon) #=> "2014-09-18 12:10:34 -0700"
510
- Faker::Time.between(2.days.ago, Date.today, :evening) #=> "2014-09-19 20:21:03 -0700"
511
- Faker::Time.between(2.days.ago, Date.today, :midnight) #=> "2014-09-20 00:40:14 -0700"
512
-
513
- # Random time in the future (up to maximum of N days)
514
- Faker::Time.forward(23, :morning) # => "2014-09-26 06:54:47 -0700"
515
-
516
- # Random time in the past (up to maximum of N days)
517
- Faker::Time.backward(14, :evening) #=> "2014-09-17 19:56:33 -0700"
518
- ```
519
-
520
- ###Faker::Hacker
521
- ---------------------
522
- Are you having trouble writing tech-savvy dialogue for your latest screenplay?
523
- Worry not! Hollywood-grade technical talk is ready to fill out any form where you need to look smart.
524
-
525
- ```ruby
526
- # Full Phrase
527
- Faker::Hacker.say_something_smart #=> "Try to compress the SQL interface, maybe it will program the back-end hard drive!"
528
-
529
- # Short technical abbreviations
530
- Faker::Hacker.abbreviation #=> "RAM"
531
-
532
- # Hacker centric adjectives
533
- Faker::Hacker.adjective #=> "open-source"
534
-
535
- # Only the best hacker related nouns
536
- Faker::Hacker.noun #=> "bandwidth"
537
-
538
- # Actions that hackers take
539
- Faker::Hacker.verb #=> "bypass"
540
-
541
- # Verbs that end in -ing
542
- Faker::Hacker.ingverb #=> "synthesizing"
543
- ```
544
-
545
- ###Faker::Crypto
546
- ---------------------
547
-
548
- ```ruby
549
-
550
- Faker::Crypto.md5 #=> "6b5ed240042e8a65c55ddb826c3408e6"
551
-
552
- Faker::Crypto.sha1 #=> "4e99e31c51eef8b2d290e709f757f92e558a503f"
553
-
554
- Faker::Crypto.sha256 #=> "51e4dbb424cd9db1ec5fb989514f2a35652ececef33f21c8dd1fd61bb8e3929d"
555
-
556
- ```
557
-
558
- ###Faker::App
559
- -----------------
560
-
561
- ```ruby
562
-
563
- Faker::App.name #=> "Treeflex"
564
-
565
- Faker::App.version #=> "0.7.9"
566
-
567
- Faker::App.author #=> "Daphne Swift"
568
-
569
- ```
570
-
571
- ###Faker::SlackEmoji
572
- -----------------
573
-
574
- ```ruby
575
-
576
- # Random Slack Emoji from people category
577
- Faker::SlackEmoji.people #=> ":sleepy:"
578
-
579
- # Random Slack Emoji from nature category
580
- Faker::SlackEmoji.nature #=> ":chestnut:"
581
-
582
- # Random Slack Emoji from food and drink category
583
- Faker::SlackEmoji.food_and_drink #=> ":tangerine:"
584
-
585
- # Random Slack Emoji from celebration category
586
- Faker::SlackEmoji.celebration #=> ":ribbon:"
587
-
588
- # Random Slack Emoji from activity category
589
- Faker::SlackEmoji.activity #=> ":performing_arts:"
590
-
591
- # Random Slack Emoji from travel and places category
592
- Faker::SlackEmoji.travel_and_places #=> ":truck:"
593
-
594
- # Random Slack Emoji from objects & symbols category
595
- Faker::SlackEmoji.objects_and_symbols #=> ":alarm_clock:"
596
-
597
- # Random Slack Emoji from custom category
598
- Faker::SlackEmoji.custom #=> ":suspect:"
599
-
600
- # Random Slack Emoji from any category
601
- Faker::SlackEmoji.emoji #=> ":last_quarter_moon:"
602
-
603
- ```
604
-
605
- ###Faker::Team
606
- -----------------
607
-
608
- ```ruby
609
-
610
- # Random Team Creature
611
- Faker::Team.creature #=> "gooses"
612
-
613
- # Random Team Name created from random US State (Faker::Address.state) prepended to a random Team Creature
614
- Faker::Team.name #=> "Oregon vixens"
615
-
616
- # Random Team State
617
- Faker::Team.state #=> "Oregon"
618
-
619
- # Random Team Sport
620
- Faker::Team.sport #=> "lacrosse"
621
-
622
- ```
623
-
624
- ###Faker::Book
625
- ------------------
626
-
627
- ```ruby
628
-
629
- # Random Book Title
630
- Faker::Book.title #=> "The Odd Sister"
631
-
632
- # Random Author
633
- Faker::Book.author #=> "Alysha Olsen"
634
-
635
- # Random Publisher
636
- Faker::Book.publisher #=> "Opus Reader"
637
-
638
- # Random Genre
639
- Faker::Book.genre #=> "Mystery"
640
-
641
- ```
642
-
643
- ###Faker::University
644
- ------------------
645
-
646
- ```ruby
647
-
648
- # Random University Name
649
- Faker::University.name #=> "South Texas College"
650
-
651
- ```
652
-
653
- ###Faker::Placeholdit
654
- ----------------
655
-
656
- ```ruby
657
-
658
- Faker::Placeholdit.image #=> "http://placehold.it/300x300.png/000"
659
-
660
- Faker::Placeholdit.image("50x50") #=> "http://placehold.it/50x50.png/000"
661
-
662
- Faker::Placeholdit.image("50x50", 'jpg') #=> "http://placehold.it/50x50.jpg/000"
663
-
664
- Faker::Placeholdit.image("50x50", 'gif', 'ffffff') #=> "http://placehold.it/50x50.gif/ffffff"
665
-
666
- Faker::Placeholdit.image("50x50", 'jpeg', 'ffffff', '000') #=> "http://placehold.it/50x50.jpeg/ffffff/000"
667
-
668
- Faker::Placeholdit.image("50x50", 'jpg', 'ffffff', '000', 'Some Custom Text') #=> "http://placehold.it/50x50.jpg/ffffff/000?text='Some Custom Text'"
669
-
670
- ```
671
-
672
- ###Faker::Hipster
673
- ----------------
674
- Adapted from [Hipster Ipsum](http://hipsum.co/)
675
-
676
- ```ruby
677
-
678
- Faker::Hipster.word #=> "irony"
679
-
680
- # Optional arguments: num=3, supplemental=false, spaces_allowed = false
681
- Faker::Hipster.words #=> ["pug", "pitchfork", "chia"]
682
- Faker::Hipster.words(4) #=> ["ugh", "cardigan", "poutine", "stumptown"]
683
- Faker::Hipster.words(4, true) #=> ["iste", "seitan", "normcore", "provident"]
684
- Faker::Hipster.words(4, true, true) #=> ["qui", "magni", "craft beer", "est"]
685
-
686
- # Optional arguments: word_count=4, supplemental=false, random_words_to_add=6
687
- Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it."
688
- Faker::Hipster.sentence(3) #=> "Pour-over swag godard."
689
- Faker::Hipster.sentence(3, true) #=> "Beard laboriosam sequi celiac."
690
- Faker::Hipster.sentence(3, false, 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit."
691
- Faker::Hipster.sentence(3, true, 4) #=> "Occaecati deleniti messenger bag meh crucifix autem."
692
-
693
- # Optional arguments: sentence_count=3, supplemental=false
694
- Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."]
695
- Faker::Hipster.sentences(1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."]
696
- Faker::Hipster.sentences(1, true) #=> ["Et sustainable optio aesthetic et."]
697
-
698
- # Optional arguments: sentence_count=3, supplemental=false, random_sentences_to_add=3
699
- Faker::Hipster.paragraph #=> "Migas fingerstache pbr&b tofu. Polaroid distillery typewriter echo tofu actually. Slow-carb fanny pack pickled direct trade scenester mlkshk plaid. Banjo venmo chambray cold-pressed typewriter. Fap skateboard intelligentsia."
700
- Faker::Hipster.paragraph(2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1."
701
- Faker::Hipster.paragraph(2, true) #=> "Typewriter iste ut viral kombucha voluptatem. Sint voluptates saepe. Direct trade irony chia excepturi yuccie. Biodiesel esse listicle et quam suscipit."
702
- Faker::Hipster.paragraph(2, false, 4) #=> "Selvage vhs chartreuse narwhal vinegar. Authentic vinyl truffaut carry vhs pop-up. Hammock everyday iphone locavore thundercats bitters vegan goth. Fashion axe banh mi shoreditch whatever artisan."
703
- Faker::Hipster.paragraph(2, true, 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics."
704
-
705
- # Optional arguments: paragraph_count=3, supplemental=false
706
- Faker::Hipster.paragraphs #=> ["Tilde microdosing blog cliche meggings. Intelligentsia five dollar toast forage yuccie. Master kitsch knausgaard. Try-hard everyday trust fund mumblecore.", "Normcore viral pickled. Listicle humblebrag swag tote bag. Taxidermy street hammock neutra butcher cred kale chips. Blog portland humblebrag trust fund irony.", "Single-origin coffee fixie cleanse tofu xoxo. Post-ironic tote bag ramps gluten-free locavore mumblecore hammock. Umami loko twee. Ugh kitsch before they sold out."]
707
- Faker::Hipster.paragraphs(1) #=> ["Skateboard cronut synth +1 fashion axe. Pop-up polaroid skateboard asymmetrical. Ennui fingerstache shoreditch before they sold out. Tattooed pitchfork ramps. Photo booth yr messenger bag raw denim bespoke locavore lomo synth."]
708
- Faker::Hipster.paragraphs(1, true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."]
709
- ```
710
-
711
- ###Faker::Superhero
712
- ------------------
713
-
714
- ```ruby
715
-
716
- # Random Superhero name
717
- Faker::Superhero.name #=> "Magnificent Shatterstar"
718
-
719
- # Random Superhero power
720
- Faker::Superhero.power #=> "Photokinesis"
721
- ```
722
-
723
-
724
- ###Faker::StarWars
725
- ----------------
726
-
727
- ```ruby
728
- Faker::StarWars.character #=> "Anakin Skywalker"
729
-
730
- Faker::StarWars.droid #=> "C-3PO"
731
-
732
- Faker::StarWars.planet #=> "Tatooine"
733
-
734
- Faker::StarWars.quote #=> "Aren’t you a little short for a Stormtrooper?"
735
-
736
- Faker::StarWars.specie #=> "Gungan"
737
-
738
- Faker::StarWars.vehicle #=> "Sandcrawler"
739
- ```
740
-
741
- ###Faker::Beer
742
- ----------------
743
-
744
- ```ruby
745
- Faker::Beer.name #=> "Hercules Double IPA"
746
-
747
- Faker::Beer.style #=> "Belgian Strong Ale"
748
-
749
- Faker::Beer.hop #=> "Equinox"
750
-
751
- Faker::Beer.yeast #=> "2278 - Czech Pils"
752
-
753
- Faker::Beer.malts #=> "Rye malt"
754
-
755
- Faker::Beer.ibu #=> "40 IBU"
756
-
757
- Faker::Beer.alcohol #=> "6.3%"
758
-
759
- Faker::Beer.blg #=> "18.5°Blg"
760
- ```
761
-
762
- ###Faker::ChuckNorris
763
- ----------------
764
-
765
- ```ruby
766
- Faker::ChuckNorris.fact #=> "Chuck Norris can solve the Towers of Hanoi in one move."
767
- ```
768
-
769
- ###Faker::Educator
770
- -------------------
89
+ ### Ensuring unique values
771
90
 
91
+ Prefix your method call with `unique`. For example:
772
92
  ```ruby
773
- Faker::Educator.university #=> "Mallowtown Technical College"
774
-
775
- Faker::Educator.secondary_school #=> "Iceborough Secodary College"
776
-
777
- Faker::Educator.course #=> "Associate Degree in Criminology"
778
-
779
- Faker::Educator.campus #=> "Vertapple Campus"
93
+ Faker::Name.unique.name # This will return a unique name every time it is called
780
94
  ```
781
95
 
782
- ###Faker::Space
783
- ----------------
784
-
785
- ```ruby
786
- # Random planet from our Solar System
787
- Faker::Space.planet #=> "Venus"
788
-
789
- # Random moon from our Solar System
790
- Faker::Space.moon #=> "Europa"
791
-
792
- # Random galaxy
793
- Faker::Space.galaxy #=> "Andromeda"
794
-
795
- # Random nebula name
796
- Faker::Space.nebula #=> "Triffid Nebula"
797
-
798
- # Random star cluster
799
- Faker::Space.star_cluster #=> "Messier 70"
800
-
801
- # Random constellation
802
- Faker::Space.constellation #=> "Orion"
803
-
804
- # Random star
805
- Faker::Space.star #=> "Proxima Centauri"
806
-
807
- # Random national space agency
808
- Faker::Space.agency #=> "Japan Aerospace Exploration Agency"
809
-
810
- # Random space agency abbreviation
811
- Faker::Space.agency_abv #=> "NASA"
812
-
813
- # Random spacecraft name (limited to NASA)
814
- Faker::Space.nasa_space_craft #=> "Endeavour"
815
-
816
- # Random private space company title
817
- Faker::Space.company #=> "SpaceX"
818
-
819
- # Random unit of stellar distance with number
820
- Faker::Space.distance_measurement #=> "15 parsecs"
821
- ```
822
-
823
-
824
- ###Faker::Music
825
- -------------------
826
-
827
- ```ruby
828
- Faker::Music.key #=> "C"
96
+ ## Customization
829
97
 
830
- Faker::Music.instrument #=> "Ukelele"
831
- ```
832
-
833
- ###Faker::Vehicle
834
- ------------------
835
-
836
- ```ruby
837
-
838
- # Generate vehicle identification number
839
- Faker::Vehicle.vin #=> "LLDWXZLG77VK2LUUF"
840
-
841
- # Random vehicle manufacturer
842
- Faker::Vehicle.manufacture #=> "JAGUAR CARS LTD"
843
- ```
844
-
845
- ###Faker::GameOfThrones
846
- ----------------
847
-
848
- ```ruby
849
- Faker::GameOfThrones.character #=> "Tyrion Lannister"
850
-
851
- Faker::GameOfThrones.house #=> "Stark"
852
-
853
- Faker::GameOfThrones.city #=> "Lannisport"
854
- ```
855
-
856
- ###Faker::Pokemon
857
- ----------------
858
-
859
- ```ruby
860
- Faker::Pokemon.name #=> "Pikachu"
861
-
862
- Faker::Pokemon.location #=> "Pallet Town"
863
- ```
864
-
865
- Customization
866
- ------------
867
98
  Since you may want to make addresses and other types of data look different
868
99
  depending on where in the world you are (US postal codes vs. UK postal codes,
869
100
  for example), Faker uses the I18n gem to store strings (like state names) and
@@ -889,14 +120,14 @@ en-au-ocker:
889
120
 
890
121
  ```
891
122
 
892
- Contributing
893
- ------------
123
+ ## Contributing
124
+
894
125
  See [CONTRIBUTING.md](https://github.com/stympy/faker/blob/master/CONTRIBUTING.md).
895
126
 
896
- Contact
897
- -------
127
+ ## Contact
128
+
898
129
  Comments and feedback are welcome. Send an email to Benjamin Curtis via the [google group](http://groups.google.com/group/ruby-faker).
899
130
 
900
- License
901
- -------
131
+ ## License
132
+
902
133
  This code is free to use under the terms of the MIT license.