faker 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -3
- data/README.md +45 -0
- data/lib/faker.rb +37 -75
- data/lib/faker/address.rb +12 -7
- data/lib/faker/app.rb +1 -5
- data/lib/faker/bank.rb +1 -0
- data/lib/faker/bitcoin.rb +1 -1
- data/lib/faker/code.rb +1 -1
- data/lib/faker/coffee.rb +29 -0
- data/lib/faker/color.rb +2 -2
- data/lib/faker/commerce.rb +1 -2
- data/lib/faker/company.rb +38 -6
- data/lib/faker/compass.rb +65 -0
- data/lib/faker/dessert.rb +19 -0
- data/lib/faker/dr_who.rb +34 -0
- data/lib/faker/dragon_ball.rb +9 -0
- data/lib/faker/family_guy.rb +17 -0
- data/lib/faker/fillmurray.rb +2 -2
- data/lib/faker/finance.rb +1 -1
- data/lib/faker/food.rb +4 -0
- data/lib/faker/funny_name.rb +43 -0
- data/lib/faker/hacker.rb +1 -1
- data/lib/faker/hey_arnold.rb +17 -0
- data/lib/faker/hipster.rb +3 -3
- data/lib/faker/hitchhikers_guide_to_the_galaxy.rb +33 -0
- data/lib/faker/hobbit.rb +21 -0
- data/lib/faker/how_i_met_your_mother.rb +21 -0
- data/lib/faker/id_number.rb +3 -7
- data/lib/faker/internet.rb +20 -14
- data/lib/faker/league_of_legends.rb +29 -0
- data/lib/faker/lorem.rb +5 -5
- data/lib/faker/lovecraft.rb +73 -0
- data/lib/faker/markdown.rb +66 -0
- data/lib/faker/matz.rb +9 -0
- data/lib/faker/music.rb +2 -2
- data/lib/faker/number.rb +6 -6
- data/lib/faker/omniauth.rb +77 -29
- data/lib/faker/overwatch.rb +17 -0
- data/lib/faker/phone_number.rb +2 -10
- data/lib/faker/pokemon.rb +5 -1
- data/lib/faker/rick_and_morty.rb +17 -0
- data/lib/faker/robin.rb +9 -0
- data/lib/faker/rupaul.rb +11 -0
- data/lib/faker/shakespeare.rb +4 -4
- data/lib/faker/simpsons.rb +22 -0
- data/lib/faker/star_trek.rb +21 -0
- data/lib/faker/star_wars.rb +9 -9
- data/lib/faker/time.rb +2 -2
- data/lib/faker/twitter.rb +114 -43
- data/lib/faker/vehicle.rb +3 -3
- data/lib/faker/version.rb +1 -1
- data/lib/faker/zelda.rb +4 -0
- data/lib/locales/bg.yml +41 -0
- data/lib/locales/de.yml +45 -1
- data/lib/locales/en-IND.yml +2 -2
- data/lib/locales/en-MS.yml +39 -0
- data/lib/locales/en.yml +301 -38
- data/lib/locales/en/README.md +13 -0
- data/lib/locales/en/address.yml +37 -0
- data/lib/locales/en/dr_who.yml +74 -0
- data/lib/locales/en/family_guy.yml +7 -0
- data/lib/locales/en/internet.yml +21 -0
- data/lib/locales/en/lovecraft.yml +9 -0
- data/lib/locales/en/rick_and_morty.yml +6 -0
- data/lib/locales/fr.yml +5 -1
- data/lib/locales/nl.yml +26 -26
- data/lib/locales/pt-BR.yml +1 -1
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce6b1bbab7b37adf4a653fd7c9a2e6a02b0b39bb
|
4
|
+
data.tar.gz: 116053913adbf2b6a7cbc98ff0c59a8153fb2964
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a824be63a5e4b73b1866b8e3b6805182a547eb95b254ed46784c4ad56a8f2e5680ec9d930099173a95530753666d51774a0d2ffdd915092838ce2b914399da27
|
7
|
+
data.tar.gz: 61dcc7403fd9797c9ff5dea2d3c7f6b727b19d87d4f78fbc27fd64f137598616b0eb5448d908ed5dda7fc3c9a965d57d8eb74c1c0540c3132ccc0d1e713b4a5e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,93 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v1.
|
3
|
+
## [v1.8.0](https://github.com/stympy/faker/tree/v1.8.0) (2017-07-09)
|
4
|
+
[Full Changelog](https://github.com/stympy/faker/compare/v1.7.3...v1.8.0)
|
5
|
+
|
6
|
+
**Changes**
|
7
|
+
|
8
|
+
- The default translation file, `en.yml`, is now being split into
|
9
|
+
multiple translation files, with one translation file per class. See
|
10
|
+
the [locale README](./lib/locales/en/README.md) for more info.
|
11
|
+
|
12
|
+
**Closed issues:**
|
13
|
+
|
14
|
+
- Zelda Location [\#968](https://github.com/stympy/faker/issues/968)
|
15
|
+
- Real passwords / passphrases [\#962](https://github.com/stympy/faker/issues/962)
|
16
|
+
- Generating fake link \[Feature Request\] [\#955](https://github.com/stympy/faker/issues/955)
|
17
|
+
- Clean-up Robin's "Holy Steam Valve" quote [\#948](https://github.com/stympy/faker/issues/948)
|
18
|
+
- Faker::Time.between produces times out of range [\#894](https://github.com/stympy/faker/issues/894)
|
19
|
+
- \[Feature Request\] Add User Agent strings [\#880](https://github.com/stympy/faker/issues/880)
|
20
|
+
- Faker::Omniauth is not deterministic and breaking the build [\#876](https://github.com/stympy/faker/issues/876)
|
21
|
+
- undefined method `name =' or undefined method ` =' [\#871](https://github.com/stympy/faker/issues/871)
|
22
|
+
- Faker::French Suggestion [\#869](https://github.com/stympy/faker/issues/869)
|
23
|
+
- Documentation not correct for Faker::Color.hsl\_color and hsla\_color [\#866](https://github.com/stympy/faker/issues/866)
|
24
|
+
- Faker::PhoneNumber.area\_code and .exchange\_code returning nil [\#861](https://github.com/stympy/faker/issues/861)
|
25
|
+
- Faker::RickAndMorty not available in v1.7.3 from RubyGems [\#851](https://github.com/stympy/faker/issues/851)
|
26
|
+
- Adding Faker to Create in controller, possible? [\#842](https://github.com/stympy/faker/issues/842)
|
27
|
+
- Faker 1.7.3 uses Ruby 2 features [\#825](https://github.com/stympy/faker/issues/825)
|
28
|
+
- Fillmurry = error [\#823](https://github.com/stympy/faker/issues/823)
|
29
|
+
- Base\#numerify generating phone numbers and other number fields with a weird format [\#741](https://github.com/stympy/faker/issues/741)
|
30
|
+
- Markdown/HTML Support [\#630](https://github.com/stympy/faker/issues/630)
|
31
|
+
- Update WIKI and clean README [\#588](https://github.com/stympy/faker/issues/588)
|
32
|
+
- Can't overwrite locale elements using the .yml file [\#424](https://github.com/stympy/faker/issues/424)
|
33
|
+
- Faker::Lorem.paragraph raises I18n::MissingTranslationData without manual locale override [\#278](https://github.com/stympy/faker/issues/278)
|
34
|
+
- Generate unique values [\#251](https://github.com/stympy/faker/issues/251)
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- Add Faker::Address.community [\#969](https://github.com/stympy/faker/pull/969) ([landongrindheim](https://github.com/landongrindheim))
|
39
|
+
- Added Faker::Food.dish [\#967](https://github.com/stympy/faker/pull/967) ([aomega08](https://github.com/aomega08))
|
40
|
+
- Add translations for Malaysia [\#965](https://github.com/stympy/faker/pull/965) ([alienxp03](https://github.com/alienxp03))
|
41
|
+
- Adds some new dutch names to the locales [\#961](https://github.com/stympy/faker/pull/961) ([stefanvermaas](https://github.com/stefanvermaas))
|
42
|
+
- French traduction for Faker::Pokemon [\#960](https://github.com/stympy/faker/pull/960) ([Dakurei](https://github.com/Dakurei))
|
43
|
+
- Add characters to the RickAndMorty database [\#958](https://github.com/stympy/faker/pull/958) ([roninCode](https://github.com/roninCode))
|
44
|
+
- \[Resolved\] Internet domain word issue [\#957](https://github.com/stympy/faker/pull/957) ([SagareGanesh](https://github.com/SagareGanesh))
|
45
|
+
- Pokemon\#moves [\#954](https://github.com/stympy/faker/pull/954) ([joel-g](https://github.com/joel-g))
|
46
|
+
- Remove extraneous text from Robin quote [\#953](https://github.com/stympy/faker/pull/953) ([jsteel](https://github.com/jsteel))
|
47
|
+
- Added Simpsons. [\#950](https://github.com/stympy/faker/pull/950) ([RaimundHuebel](https://github.com/RaimundHuebel))
|
48
|
+
- add default task test for rake [\#923](https://github.com/stympy/faker/pull/923) ([stephengroat](https://github.com/stephengroat))
|
49
|
+
- Use the latest Rubies on Travis CI [\#920](https://github.com/stympy/faker/pull/920) ([hisas](https://github.com/hisas))
|
50
|
+
- Add meaningful error message when country code not found [\#916](https://github.com/stympy/faker/pull/916) ([mrstebo](https://github.com/mrstebo))
|
51
|
+
- Add Faker::HitchhikersGuideToTheGalaxy [\#914](https://github.com/stympy/faker/pull/914) ([pedroCervi](https://github.com/pedroCervi))
|
52
|
+
- Add Funny Name [\#912](https://github.com/stympy/faker/pull/912) ([jsonreeder](https://github.com/jsonreeder))
|
53
|
+
- Fix pt-BR city suffix [\#896](https://github.com/stympy/faker/pull/896) ([marcelo-leal](https://github.com/marcelo-leal))
|
54
|
+
- Adds League of Legends summoner spells, masteries and rank [\#892](https://github.com/stympy/faker/pull/892) ([DonkeyFish456](https://github.com/DonkeyFish456))
|
55
|
+
- fix typo in test file [\#890](https://github.com/stympy/faker/pull/890) ([akintner](https://github.com/akintner))
|
56
|
+
- Hobbit characters, locations, & quotes [\#889](https://github.com/stympy/faker/pull/889) ([ski-climb](https://github.com/ski-climb))
|
57
|
+
- Added Omniauth Github faker [\#888](https://github.com/stympy/faker/pull/888) ([ahmed-taj](https://github.com/ahmed-taj))
|
58
|
+
- Add locations to Faker::Zelda [\#885](https://github.com/stympy/faker/pull/885) ([thejonanshow](https://github.com/thejonanshow))
|
59
|
+
- add all setup and files for star trek faker [\#884](https://github.com/stympy/faker/pull/884) ([akintner](https://github.com/akintner))
|
60
|
+
- improve german cell phone numbers [\#882](https://github.com/stympy/faker/pull/882) ([timoschilling](https://github.com/timoschilling))
|
61
|
+
- Add How I Met Your Mother [\#879](https://github.com/stympy/faker/pull/879) ([jdconrad89](https://github.com/jdconrad89))
|
62
|
+
- Add League of Legends [\#878](https://github.com/stympy/faker/pull/878) ([Dpalazzari](https://github.com/Dpalazzari))
|
63
|
+
- Add Faker::Robin [\#868](https://github.com/stympy/faker/pull/868) ([leanucci](https://github.com/leanucci))
|
64
|
+
- Fixed hsla and hsla\_color documentation. [\#867](https://github.com/stympy/faker/pull/867) ([mrstebo](https://github.com/mrstebo))
|
65
|
+
- Add links to doc in README [\#865](https://github.com/stympy/faker/pull/865) ([taleh007](https://github.com/taleh007))
|
66
|
+
- Added bg locale [\#858](https://github.com/stympy/faker/pull/858) ([ppopov1357](https://github.com/ppopov1357))
|
67
|
+
- Add Faker::Overwatch [\#857](https://github.com/stympy/faker/pull/857) ([tomdracz](https://github.com/tomdracz))
|
68
|
+
- Add Faker::HeyArnold [\#855](https://github.com/stympy/faker/pull/855) ([MatthewDG](https://github.com/MatthewDG))
|
69
|
+
- Fix India Postal Code format [\#853](https://github.com/stympy/faker/pull/853) ([dv2](https://github.com/dv2))
|
70
|
+
- Fix typo in music.md [\#852](https://github.com/stympy/faker/pull/852) ([martinbjeldbak](https://github.com/martinbjeldbak))
|
71
|
+
- Fixed regex pattern in TestLocale::test\_regex. [\#849](https://github.com/stympy/faker/pull/849) ([karlwilbur](https://github.com/karlwilbur))
|
72
|
+
- Faker::Compass [\#848](https://github.com/stympy/faker/pull/848) ([karlwilbur](https://github.com/karlwilbur))
|
73
|
+
- en.yml: demographic, demonym: add missing double quote before Fijian [\#847](https://github.com/stympy/faker/pull/847) ([PascalSchumacher](https://github.com/PascalSchumacher))
|
74
|
+
- Update Zelda with Breath of the Wild [\#846](https://github.com/stympy/faker/pull/846) ([lauramosher](https://github.com/lauramosher))
|
75
|
+
- add RuPaul quotes [\#845](https://github.com/stympy/faker/pull/845) ([raphaeleidus](https://github.com/raphaeleidus))
|
76
|
+
- Add example for Faker::Date.birthday [\#844](https://github.com/stympy/faker/pull/844) ([janpieper](https://github.com/janpieper))
|
77
|
+
- Adds Coffee [\#840](https://github.com/stympy/faker/pull/840) ([nathanjh](https://github.com/nathanjh))
|
78
|
+
- WIP add dragon ball characters to faker [\#839](https://github.com/stympy/faker/pull/839) ([Cdunagan05](https://github.com/Cdunagan05))
|
79
|
+
- Update README.md [\#836](https://github.com/stympy/faker/pull/836) ([jbkimble](https://github.com/jbkimble))
|
80
|
+
- Truncate Twitter screen\_name length [\#834](https://github.com/stympy/faker/pull/834) ([abraham](https://github.com/abraham))
|
81
|
+
- Improve Faker::Twitter compatibility [\#831](https://github.com/stympy/faker/pull/831) ([abraham](https://github.com/abraham))
|
82
|
+
- doc: Add Internet.name length optional arguments [\#830](https://github.com/stympy/faker/pull/830) ([li-xinyang](https://github.com/li-xinyang))
|
83
|
+
- Matz [\#829](https://github.com/stympy/faker/pull/829) ([denys281](https://github.com/denys281))
|
84
|
+
- Add norwegian organization number [\#827](https://github.com/stympy/faker/pull/827) ([leifcr](https://github.com/leifcr))
|
85
|
+
- \[Resolved\] Fillmurray image Fixnum match issue [\#824](https://github.com/stympy/faker/pull/824) ([SagareGanesh](https://github.com/SagareGanesh))
|
86
|
+
- Rick and morty [\#821](https://github.com/stympy/faker/pull/821) ([JessCodes](https://github.com/JessCodes))
|
87
|
+
- Fix i18n file load issue [\#811](https://github.com/stympy/faker/pull/811) ([jacknoble](https://github.com/jacknoble))
|
88
|
+
- Create a Dessert faker [\#791](https://github.com/stympy/faker/pull/791) ([susiirwin](https://github.com/susiirwin))
|
89
|
+
|
90
|
+
## [v1.7.3](https://github.com/stympy/faker/tree/v1.7.3) (2017-02-05)
|
4
91
|
[Full Changelog](https://github.com/stympy/faker/compare/v1.7.2...v1.7.3)
|
5
92
|
|
6
93
|
**Closed issues:**
|
@@ -162,7 +249,7 @@
|
|
162
249
|
- Added default country check to en-PAK unit tests [\#652](https://github.com/stympy/faker/pull/652) ([Newman101](https://github.com/Newman101))
|
163
250
|
- Added even method to Luhn algorithm [\#650](https://github.com/stympy/faker/pull/650) ([Newman101](https://github.com/Newman101))
|
164
251
|
- Add more names to pt-BR [\#649](https://github.com/stympy/faker/pull/649) ([haggen](https://github.com/haggen))
|
165
|
-
- Add Nigerian locale to locales [\#647](https://github.com/stympy/faker/pull/647) ([
|
252
|
+
- Add Nigerian locale to locales [\#647](https://github.com/stympy/faker/pull/647) ([oluosiname](https://github.com/oluosiname))
|
166
253
|
- Refactor Luhn Checksum [\#619](https://github.com/stympy/faker/pull/619) ([Newman101](https://github.com/Newman101))
|
167
254
|
- Added en-SG unit tests [\#618](https://github.com/stympy/faker/pull/618) ([Newman101](https://github.com/Newman101))
|
168
255
|
- Improved de-AT unit tests [\#614](https://github.com/stympy/faker/pull/614) ([Newman101](https://github.com/Newman101))
|
@@ -366,4 +453,4 @@
|
|
366
453
|
* Initial release
|
367
454
|
|
368
455
|
|
369
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
456
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -13,6 +13,7 @@ development.
|
|
13
13
|
|
14
14
|
* While Faker generates data at random, returned values are not guaranteed to be unique by default.
|
15
15
|
You must explicity specify when you require unique values, see [details](#ensuring-unique-values).
|
16
|
+
Values also can be deterministic if you use the deterministic feature, see [details](#deterministic-random)
|
16
17
|
* This is the `master` branch of Faker and may contain changes that are not yet released.
|
17
18
|
Please refer the README of your version for the available methods.
|
18
19
|
List of all versions is [available here](https://github.com/stympy/faker/releases).
|
@@ -35,13 +36,19 @@ Contents
|
|
35
36
|
- [Faker::Cat](doc/cat.md)
|
36
37
|
- [Faker::ChuckNorris](doc/chuck_norris.md)
|
37
38
|
- [Faker::Code](doc/code.md)
|
39
|
+
- [Faker::Coffee](doc/coffee.md)
|
38
40
|
- [Faker::Color](doc/color.md)
|
39
41
|
- [Faker::Commerce](doc/commerce.md)
|
40
42
|
- [Faker::Company](doc/company.md)
|
43
|
+
- [Faker::Compass](doc/compass.md)
|
41
44
|
- [Faker::Crypto](doc/crypto.md)
|
42
45
|
- [Faker::Date](doc/date.md)
|
43
46
|
- [Faker::Demographic](doc/demographic.md)
|
47
|
+
- [Faker::Dessert](doc/dessert.md)
|
48
|
+
- [Faker::DragonBall](doc/dragon_ball.md)
|
49
|
+
- [Faker::DrWho](doc/dr_who.md)
|
44
50
|
- [Faker::Educator](doc/educator.md)
|
51
|
+
- [Faker::FamilyGuy](doc/family_guy.md)
|
45
52
|
- [Faker::File](doc/file.md)
|
46
53
|
- [Faker::Fillmurray](doc/fillmurray.md)
|
47
54
|
- [Faker::Food](doc/food.md)
|
@@ -49,21 +56,36 @@ Contents
|
|
49
56
|
- [Faker::GameOfThrones](doc/game_of_thrones.md)
|
50
57
|
- [Faker::Hacker](doc/hacker.md)
|
51
58
|
- [Faker::HarryPotter](doc/harry_potter.md)
|
59
|
+
- [Faker::HeyArnold](doc/hey_arnold.md)
|
52
60
|
- [Faker::Hipster](doc/hipster.md)
|
61
|
+
- [Faker::Hobbit](doc/hobbit.md)
|
62
|
+
- [Faker::HowIMetYourMother](doc/how_i_met_your_mother.md)
|
63
|
+
- [Faker::HitchhikersGuideToTheGalaxy](doc/hitchhikers_guide_to_the_galaxy.md)
|
53
64
|
- [Faker::Internet](doc/internet.md)
|
65
|
+
- [Faker::Job](doc/job.md)
|
66
|
+
- [Faker::LeagueOfLegends](doc/league_of_legends.md)
|
54
67
|
- [Faker::LordOfTheRings](doc/lord_of_the_rings.md)
|
55
68
|
- [Faker::LoremPixel](doc/lorem_pixel.md)
|
56
69
|
- [Faker::Lorem](doc/lorem.md)
|
70
|
+
- [Faker::Lovecraft](doc/lovecraft.md)
|
71
|
+
- [Faker::Markdown](doc/markdown.md)
|
72
|
+
- [Faker::Matz](doc/matz.md)
|
57
73
|
- [Faker::Music](doc/music.md)
|
58
74
|
- [Faker::Name](doc/name.md)
|
59
75
|
- [Faker::Number](doc/number.md)
|
60
76
|
- [Faker::Omniauth](doc/omniauth.md)
|
77
|
+
- [Faker::Overwatch](doc/overwatch.md)
|
61
78
|
- [Faker::PhoneNumber](doc/phone_number.md)
|
62
79
|
- [Faker::Placeholdit](doc/placeholdit.md)
|
63
80
|
- [Faker::Pokemon](doc/pokemon.md)
|
81
|
+
- [Faker::RickAndMorty](doc/rick_and_morty.md)
|
82
|
+
- [Faker::Robin](doc/robin.md)
|
64
83
|
- [Faker::RockBand](doc/rock_band.md)
|
84
|
+
- [Faker::RuPaul](doc/rupaul.md)
|
85
|
+
- [Faker::Simpsons](doc/simpsons.md)
|
65
86
|
- [Faker::SlackEmoji](doc/slack_emoji.md)
|
66
87
|
- [Faker::Space](doc/space.md)
|
88
|
+
- [Faker::StarTrek](doc/star_trek.md)
|
67
89
|
- [Faker::StarWars](doc/star_wars.md)
|
68
90
|
- [Faker::Superhero](doc/superhero.md)
|
69
91
|
- [Faker::Team](doc/team.md)
|
@@ -107,6 +129,29 @@ that have been returned, for example between tests.
|
|
107
129
|
Faker::Name.unique.clear # Clears used values for Faker::Name
|
108
130
|
Faker::UniqueGenerator.clear # Clears used values for all generators
|
109
131
|
```
|
132
|
+
It is also possible to add a random number to the end of faker data to increase the
|
133
|
+
likelihood of unique data being generated. For example:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
Faker::Name.unique + ((1..1000).to_a).sample
|
137
|
+
```
|
138
|
+
|
139
|
+
### Deterministic Random
|
140
|
+
|
141
|
+
Faker supports seeding of its pseudo-random number generator (PRNG) to provide deterministic output of repeated method calls.
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
Faker::Config.random = Random.new(42)
|
145
|
+
Faker::Company.bs #=> "seize collaborative mindshare"
|
146
|
+
Faker::Company.bs #=> "engage strategic platforms"
|
147
|
+
Faker::Config.random = Random.new(42)
|
148
|
+
Faker::Company.bs #=> "seize collaborative mindshare"
|
149
|
+
Faker::Company.bs #=> "engage strategic platforms"
|
150
|
+
|
151
|
+
Faker::Config.random = nil # seeds the PRNG using default entropy sources
|
152
|
+
Faker::Config.random.seed #=> 185180369676275068918401850258677722187
|
153
|
+
Faker::Company.bs #=> "cultivate viral synergies"
|
154
|
+
```
|
110
155
|
|
111
156
|
## Customization
|
112
157
|
|
data/lib/faker.rb
CHANGED
@@ -12,15 +12,19 @@ require 'set' # Fixes a bug in i18n 0.6.11
|
|
12
12
|
if I18n.respond_to?(:enforce_available_locales=)
|
13
13
|
I18n.enforce_available_locales = true
|
14
14
|
end
|
15
|
-
I18n.load_path += Dir[File.join(mydir, 'locales', '
|
15
|
+
I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
|
16
|
+
I18n.reload! if I18n.backend.initialized?
|
16
17
|
|
17
18
|
|
18
19
|
module Faker
|
19
20
|
class Config
|
20
21
|
@locale = nil
|
22
|
+
@random = nil
|
21
23
|
|
22
24
|
class << self
|
23
25
|
attr_writer :locale
|
26
|
+
attr_writer :random
|
27
|
+
|
24
28
|
def locale
|
25
29
|
@locale || I18n.locale
|
26
30
|
end
|
@@ -29,6 +33,9 @@ module Faker
|
|
29
33
|
@locale
|
30
34
|
end
|
31
35
|
|
36
|
+
def random
|
37
|
+
@random || Random::DEFAULT
|
38
|
+
end
|
32
39
|
end
|
33
40
|
end
|
34
41
|
|
@@ -44,7 +51,7 @@ module Faker
|
|
44
51
|
end
|
45
52
|
|
46
53
|
def letterify(letter_string)
|
47
|
-
letter_string.gsub(/\?/) { ULetters
|
54
|
+
letter_string.gsub(/\?/) { sample(ULetters) }
|
48
55
|
end
|
49
56
|
|
50
57
|
def bothify(string)
|
@@ -75,21 +82,20 @@ module Faker
|
|
75
82
|
re.
|
76
83
|
gsub(/^\/?\^?/, '').gsub(/\$?\/?$/, ''). # Ditch the anchors
|
77
84
|
gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}'). # All {2} become {2,2} and ? become {0,1}
|
78
|
-
gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) {|match| $1 * Array(Range.new($2.to_i, $3.to_i))
|
79
|
-
gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) {|match| $1 * Array(Range.new($2.to_i, $3.to_i))
|
80
|
-
gsub(/(\\?.)\{(\d+),(\d+)\}/) {|match| $1 * Array(Range.new($2.to_i, $3.to_i))
|
81
|
-
gsub(/\((.*?)\)/) {|match| match.gsub(/[\(\)]/, '').split('|')
|
82
|
-
gsub(/\[([^\]]+)\]/) {|match| match.gsub(/(\w\-\w)/) {|range| Array(Range.new(*range.split('-')))
|
83
|
-
gsub(/\[([^\]]+)\]/) {|match| $1.split('')
|
84
|
-
gsub('\d') {|match| Numbers
|
85
|
-
gsub('\w') {|match| Letters
|
85
|
+
gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) {|match| $1 * sample(Array(Range.new($2.to_i, $3.to_i))) }. # [12]{1,2} becomes [12] or [12][12]
|
86
|
+
gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) {|match| $1 * sample(Array(Range.new($2.to_i, $3.to_i))) }. # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
|
87
|
+
gsub(/(\\?.)\{(\d+),(\d+)\}/) {|match| $1 * sample(Array(Range.new($2.to_i, $3.to_i))) }. # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
|
88
|
+
gsub(/\((.*?)\)/) {|match| sample(match.gsub(/[\(\)]/, '').split('|')) }. # (this|that) becomes 'this' or 'that'
|
89
|
+
gsub(/\[([^\]]+)\]/) {|match| match.gsub(/(\w\-\w)/) {|range| sample(Array(Range.new(*range.split('-')))) } }. # All A-Z inside of [] become C (or X, or whatever)
|
90
|
+
gsub(/\[([^\]]+)\]/) {|match| sample($1.split('')) }. # All [ABC] become B (or A or C)
|
91
|
+
gsub('\d') {|match| sample(Numbers) }.
|
92
|
+
gsub('\w') {|match| sample(Letters) }
|
86
93
|
end
|
87
94
|
|
88
95
|
# Helper for the common approach of grabbing a translation
|
89
96
|
# with an array of values and selecting one of them.
|
90
97
|
def fetch(key)
|
91
|
-
fetched = translate("faker.#{key}")
|
92
|
-
fetched = fetched.sample if fetched.respond_to?(:sample)
|
98
|
+
fetched = sample(translate("faker.#{key}"))
|
93
99
|
if fetched && fetched.match(/^\//) and fetched.match(/\/$/) # A regex
|
94
100
|
regexify(fetched)
|
95
101
|
else
|
@@ -113,7 +119,8 @@ module Faker
|
|
113
119
|
# into method calls that can be used to generate a
|
114
120
|
# formatted translation: e.g., "#{first_name} #{last_name}".
|
115
121
|
def parse(key)
|
116
|
-
fetch(key)
|
122
|
+
fetched = fetch(key)
|
123
|
+
parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map {|prefix, kls, meth, etc|
|
117
124
|
# If the token had a class Prefix (e.g., Name.first_name)
|
118
125
|
# grab the constant, otherwise use self
|
119
126
|
cls = kls ? Faker.const_get(kls.chop) : self
|
@@ -128,7 +135,9 @@ module Faker
|
|
128
135
|
|
129
136
|
# And tack on spaces, commas, etc. left over in the string
|
130
137
|
text += etc.to_s
|
131
|
-
}
|
138
|
+
}
|
139
|
+
# If the fetched key couldn't be parsed, then fallback to numerify
|
140
|
+
parts.any? ? parts.join : numerify(fetched)
|
132
141
|
end
|
133
142
|
|
134
143
|
# Call I18n.translate with our configured locale if no
|
@@ -171,7 +180,7 @@ module Faker
|
|
171
180
|
|
172
181
|
# Use the alternate form of translate to get a nil rather than a "missing translation" string
|
173
182
|
if translation = translate(:faker)[@flexible_key][m]
|
174
|
-
translation
|
183
|
+
sample(translation)
|
175
184
|
else
|
176
185
|
super
|
177
186
|
end
|
@@ -186,70 +195,23 @@ module Faker
|
|
186
195
|
def unique(max_retries = 10_000)
|
187
196
|
@unique_generator ||= UniqueGenerator.new(self, max_retries)
|
188
197
|
end
|
198
|
+
|
199
|
+
def sample(list)
|
200
|
+
list.respond_to?(:sample) ? list.sample(random: Faker::Config.random) : list
|
201
|
+
end
|
202
|
+
|
203
|
+
def shuffle(list)
|
204
|
+
list.shuffle(random: Faker::Config.random)
|
205
|
+
end
|
206
|
+
|
207
|
+
def rand(max = nil)
|
208
|
+
max ? Faker::Config.random.rand(max) : Faker::Config.random.rand
|
209
|
+
end
|
189
210
|
end
|
190
211
|
end
|
191
212
|
end
|
192
213
|
|
193
|
-
|
194
|
-
require 'faker/cat'
|
195
|
-
require 'faker/code'
|
196
|
-
require 'faker/color'
|
197
|
-
require 'faker/company'
|
198
|
-
require 'faker/university'
|
199
|
-
require 'faker/finance'
|
200
|
-
require 'faker/internet'
|
201
|
-
require 'faker/file'
|
202
|
-
require 'faker/lorem'
|
203
|
-
require 'faker/name'
|
204
|
-
require 'faker/team'
|
205
|
-
require 'faker/phone_number'
|
206
|
-
require 'faker/business'
|
207
|
-
require 'faker/commerce'
|
208
|
-
require 'faker/version'
|
209
|
-
require 'faker/number'
|
210
|
-
require 'faker/bitcoin'
|
211
|
-
require 'faker/avatar'
|
212
|
-
require 'faker/placeholdit'
|
213
|
-
require 'faker/date'
|
214
|
-
require 'faker/time'
|
215
|
-
require 'faker/number'
|
216
|
-
require 'faker/hacker'
|
217
|
-
require 'faker/app'
|
218
|
-
require 'faker/id_number'
|
219
|
-
require 'faker/slack_emoji'
|
220
|
-
require 'faker/book'
|
221
|
-
require 'faker/hipster'
|
222
|
-
require 'faker/shakespeare'
|
223
|
-
require 'faker/superhero'
|
224
|
-
require 'faker/beer'
|
225
|
-
require 'faker/boolean'
|
226
|
-
require 'faker/star_wars'
|
227
|
-
require 'faker/chuck_norris'
|
228
|
-
require 'faker/crypto'
|
229
|
-
require 'faker/educator'
|
230
|
-
require 'faker/space'
|
231
|
-
require 'faker/yoda'
|
232
|
-
require 'faker/music'
|
233
|
-
require 'faker/artist'
|
234
|
-
require 'faker/vehicle'
|
235
|
-
require 'faker/game_of_thrones'
|
236
|
-
require 'faker/pokemon'
|
237
|
-
require 'faker/food'
|
238
|
-
require 'faker/lorem_pixel'
|
239
|
-
require 'faker/esport'
|
240
|
-
require 'faker/bank'
|
241
|
-
require 'faker/ancient'
|
242
|
-
require 'faker/twin_peaks'
|
243
|
-
require 'faker/lord_of_the_rings'
|
244
|
-
require 'faker/rock_band'
|
245
|
-
require 'faker/fillmurray'
|
246
|
-
require 'faker/job'
|
247
|
-
require 'faker/demographic'
|
248
|
-
require 'faker/zelda'
|
249
|
-
require 'faker/omniauth'
|
250
|
-
require 'faker/twitter'
|
251
|
-
require 'faker/harry_potter'
|
252
|
-
require 'faker/friends'
|
214
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'faker','*.rb')).each {|f| require f }
|
253
215
|
|
254
216
|
require 'extensions/array'
|
255
217
|
require 'extensions/symbol'
|
data/lib/faker/address.rb
CHANGED
@@ -23,6 +23,10 @@ module Faker
|
|
23
23
|
bothify(fetch('address.building_number'))
|
24
24
|
end
|
25
25
|
|
26
|
+
def community
|
27
|
+
parse('address.community')
|
28
|
+
end
|
29
|
+
|
26
30
|
def zip_code(state_abbreviation = '')
|
27
31
|
return bothify(fetch('address.postcode')) if state_abbreviation === ''
|
28
32
|
|
@@ -38,13 +42,14 @@ module Faker
|
|
38
42
|
alias_method :zip, :zip_code
|
39
43
|
alias_method :postcode, :zip_code
|
40
44
|
|
41
|
-
def street_suffix;
|
42
|
-
def city_suffix;
|
43
|
-
def city_prefix;
|
44
|
-
def state_abbr;
|
45
|
-
def state;
|
46
|
-
def country;
|
47
|
-
def country_code;
|
45
|
+
def street_suffix; fetch('address.street_suffix'); end
|
46
|
+
def city_suffix; fetch('address.city_suffix'); end
|
47
|
+
def city_prefix; fetch('address.city_prefix'); end
|
48
|
+
def state_abbr; fetch('address.state_abbr'); end
|
49
|
+
def state; fetch('address.state'); end
|
50
|
+
def country; fetch('address.country'); end
|
51
|
+
def country_code; fetch('address.country_code'); end
|
52
|
+
def country_code_long; fetch('address.country_code_long'); end
|
48
53
|
|
49
54
|
def latitude
|
50
55
|
((rand * 180) - 90).to_s
|
data/lib/faker/app.rb
CHANGED
data/lib/faker/bank.rb
CHANGED
@@ -13,6 +13,7 @@ module Faker
|
|
13
13
|
|
14
14
|
def iban(bank_country_code="GB")
|
15
15
|
details = iban_details.find { |country| country["bank_country_code"] == bank_country_code.upcase }
|
16
|
+
raise ArgumentError, "Could not find iban details for #{bank_country_code}" unless details
|
16
17
|
bcc = details["bank_country_code"] + 2.times.map{ rand(10) }.join
|
17
18
|
ilc = (0...details["iban_letter_code"].to_i).map{ (65 + rand(26)).chr }.join
|
18
19
|
ib = details["iban_digits"].to_i.times.map{ rand(10) }.join
|