faker 1.8.7 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1423 -6
- data/History.md +4 -4
- data/License.txt +2 -2
- data/README.md +301 -126
- data/bin/faker +5 -0
- data/lib/faker.rb +150 -61
- data/lib/faker/blockchain/aeternity.rb +70 -0
- data/lib/faker/blockchain/bitcoin.rb +60 -0
- data/lib/faker/blockchain/ethereum.rb +26 -0
- data/lib/faker/blockchain/tezos.rb +135 -0
- data/lib/faker/books/book.rb +61 -0
- data/lib/faker/books/culture_series.rb +83 -0
- data/lib/faker/books/dune.rb +132 -0
- data/lib/faker/books/lovecraft.rb +280 -0
- data/lib/faker/creature/animal.rb +22 -0
- data/lib/faker/creature/cat.rb +50 -0
- data/lib/faker/creature/dog.rb +115 -0
- data/lib/faker/creature/horse.rb +37 -0
- data/lib/faker/default/address.rb +368 -0
- data/lib/faker/default/alphanumeric.rb +73 -0
- data/lib/faker/default/ancient.rb +59 -0
- data/lib/faker/default/app.rb +77 -0
- data/lib/faker/default/appliance.rb +33 -0
- data/lib/faker/default/artist.rb +20 -0
- data/lib/faker/default/avatar.rb +60 -0
- data/lib/faker/default/bank.rb +207 -0
- data/lib/faker/default/barcode.rb +165 -0
- data/lib/faker/default/beer.rb +113 -0
- data/lib/faker/default/blood.rb +48 -0
- data/lib/faker/default/boolean.rb +26 -0
- data/lib/faker/default/bossa_nova.rb +33 -0
- data/lib/faker/default/business.rb +50 -0
- data/lib/faker/default/camera.rb +46 -0
- data/lib/faker/default/cannabis.rb +135 -0
- data/lib/faker/default/chile_rut.rb +98 -0
- data/lib/faker/default/chuck_norris.rb +25 -0
- data/lib/faker/default/code.rb +282 -0
- data/lib/faker/default/coffee.rb +82 -0
- data/lib/faker/default/coin.rb +33 -0
- data/lib/faker/default/color.rb +79 -0
- data/lib/faker/default/commerce.rb +143 -0
- data/lib/faker/default/company.rb +581 -0
- data/lib/faker/default/compass.rb +202 -0
- data/lib/faker/default/computer.rb +63 -0
- data/lib/faker/default/construction.rb +83 -0
- data/lib/faker/default/cosmere.rb +138 -0
- data/lib/faker/default/crypto.rb +48 -0
- data/lib/faker/default/crypto_coin.rb +94 -0
- data/lib/faker/default/currency.rb +46 -0
- data/lib/faker/default/date.rb +186 -0
- data/lib/faker/default/dc_comics.rb +70 -0
- data/lib/faker/default/demographic.rb +98 -0
- data/lib/faker/default/dessert.rb +48 -0
- data/lib/faker/default/device.rb +85 -0
- data/lib/faker/default/driving_licence.rb +131 -0
- data/lib/faker/default/drone.rb +332 -0
- data/lib/faker/default/educator.rb +102 -0
- data/lib/faker/default/electrical_components.rb +48 -0
- data/lib/faker/default/esport.rb +72 -0
- data/lib/faker/default/faker_adjective.rb +35 -0
- data/lib/faker/default/file.rb +100 -0
- data/lib/faker/default/fillmurray.rb +45 -0
- data/lib/faker/default/finance.rb +89 -0
- data/lib/faker/default/food.rb +113 -0
- data/lib/faker/default/funny_name.rb +90 -0
- data/lib/faker/default/gender.rb +46 -0
- data/lib/faker/default/greek_philosophers.rb +33 -0
- data/lib/faker/default/hacker.rb +103 -0
- data/lib/faker/default/hipster.rb +194 -0
- data/lib/faker/default/house.rb +33 -0
- data/lib/faker/default/id_number.rb +279 -0
- data/lib/faker/default/industry_segments.rb +61 -0
- data/lib/faker/default/internet.rb +584 -0
- data/lib/faker/default/internet_http.rb +48 -0
- data/lib/faker/default/invoice.rb +136 -0
- data/lib/faker/default/job.rb +61 -0
- data/lib/faker/default/json.rb +143 -0
- data/lib/faker/default/kpop.rb +85 -0
- data/lib/faker/default/lorem.rb +306 -0
- data/lib/faker/default/lorem_flickr.rb +138 -0
- data/lib/faker/default/lorem_pixel.rb +70 -0
- data/lib/faker/default/markdown.rb +175 -0
- data/lib/faker/default/marketing.rb +22 -0
- data/lib/faker/default/measurement.rb +207 -0
- data/lib/faker/default/military.rb +98 -0
- data/lib/faker/default/mountain.rb +33 -0
- data/lib/faker/default/name.rb +156 -0
- data/lib/faker/default/nation.rb +76 -0
- data/lib/faker/default/nato_phonetic_alphabet.rb +20 -0
- data/lib/faker/default/nhs.rb +57 -0
- data/lib/faker/default/number.rb +289 -0
- data/lib/faker/default/omniauth.rb +461 -0
- data/lib/faker/default/phone_number.rb +137 -0
- data/lib/faker/default/placeholdit.rb +63 -0
- data/lib/faker/default/programming_language.rb +33 -0
- data/lib/faker/default/relationship.rb +91 -0
- data/lib/faker/default/restaurant.rb +63 -0
- data/lib/faker/default/science.rb +46 -0
- data/lib/faker/default/slack_emoji.rb +124 -0
- data/lib/faker/default/source.rb +76 -0
- data/lib/faker/default/south_africa.rb +141 -0
- data/lib/faker/default/space.rb +191 -0
- data/lib/faker/default/string.rb +66 -0
- data/lib/faker/default/stripe.rb +142 -0
- data/lib/faker/default/subscription.rb +70 -0
- data/lib/faker/default/superhero.rb +72 -0
- data/lib/faker/default/team.rb +74 -0
- data/lib/faker/default/time.rb +179 -0
- data/lib/faker/default/twitter.rb +223 -0
- data/lib/faker/default/types.rb +182 -0
- data/lib/faker/default/university.rb +75 -0
- data/lib/faker/default/vehicle.rb +342 -0
- data/lib/faker/default/verb.rb +72 -0
- data/lib/faker/default/world_cup.rb +86 -0
- data/lib/faker/fantasy/tolkien.rb +67 -0
- data/lib/faker/games/clash_of_clans.rb +48 -0
- data/lib/faker/games/control.rb +113 -0
- data/lib/faker/games/dnd.rb +136 -0
- data/lib/faker/games/dota.rb +80 -0
- data/lib/faker/games/elder_scrolls.rb +139 -0
- data/lib/faker/games/fallout.rb +62 -0
- data/lib/faker/games/game.rb +48 -0
- data/lib/faker/games/half_life.rb +48 -0
- data/lib/faker/games/heroes.rb +61 -0
- data/lib/faker/games/heroes_of_the_storm.rb +72 -0
- data/lib/faker/games/league_of_legends.rb +87 -0
- data/lib/faker/games/minecraft.rb +113 -0
- data/lib/faker/games/myst.rb +74 -0
- data/lib/faker/games/overwatch.rb +48 -0
- data/lib/faker/games/pokemon.rb +48 -0
- data/lib/faker/games/sonic_the_hedgehog.rb +48 -0
- data/lib/faker/games/street_fighter.rb +61 -0
- data/lib/faker/games/super_mario.rb +48 -0
- data/lib/faker/games/super_smash_bros.rb +35 -0
- data/lib/faker/games/touhou.rb +75 -0
- data/lib/faker/games/warhammer_fantasy.rb +74 -0
- data/lib/faker/games/witcher.rb +87 -0
- data/lib/faker/games/world_of_warcraft.rb +60 -0
- data/lib/faker/games/zelda.rb +62 -0
- data/lib/faker/japanese_media/conan.rb +48 -0
- data/lib/faker/japanese_media/doraemon.rb +48 -0
- data/lib/faker/japanese_media/dragon_ball.rb +48 -0
- data/lib/faker/japanese_media/naruto.rb +61 -0
- data/lib/faker/japanese_media/one_piece.rb +87 -0
- data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
- data/lib/faker/japanese_media/sword_art_online.rb +61 -0
- data/lib/faker/movies/back_to_the_future.rb +49 -0
- data/lib/faker/movies/departed.rb +49 -0
- data/lib/faker/movies/ghostbusters.rb +49 -0
- data/lib/faker/movies/harry_potter.rb +87 -0
- data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +106 -0
- data/lib/faker/movies/hobbit.rb +62 -0
- data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
- data/lib/faker/movies/lebowski.rb +48 -0
- data/lib/faker/movies/lord_of_the_rings.rb +49 -0
- data/lib/faker/movies/movie.rb +33 -0
- data/lib/faker/movies/princess_bride.rb +36 -0
- data/lib/faker/movies/room.rb +63 -0
- data/lib/faker/movies/star_wars.rb +273 -0
- data/lib/faker/movies/v_for_vendetta.rb +50 -0
- data/lib/faker/music/grateful_dead.rb +37 -0
- data/lib/faker/music/hiphop.rb +48 -0
- data/lib/faker/music/music.rb +133 -0
- data/lib/faker/music/opera.rb +298 -0
- data/lib/faker/music/pearl_jam.rb +50 -0
- data/lib/faker/music/phish.rb +48 -0
- data/lib/faker/music/prince.rb +64 -0
- data/lib/faker/music/rock_band.rb +34 -0
- data/lib/faker/music/rush.rb +37 -0
- data/lib/faker/music/show.rb +49 -0
- data/lib/faker/music/umphreys_mcgee.rb +22 -0
- data/lib/faker/quotes/chiquito.rb +80 -0
- data/lib/faker/quotes/quote.rb +111 -0
- data/lib/faker/quotes/rajnikanth.rb +27 -0
- data/lib/faker/quotes/shakespeare.rb +111 -0
- data/lib/faker/sports/basketball.rb +61 -0
- data/lib/faker/sports/football.rb +74 -0
- data/lib/faker/sports/volleyball.rb +74 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +37 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
- data/lib/faker/tv_shows/bojack_horseman.rb +51 -0
- data/lib/faker/tv_shows/breaking_bad.rb +37 -0
- data/lib/faker/tv_shows/buffy.rb +89 -0
- data/lib/faker/tv_shows/community.rb +38 -0
- data/lib/faker/tv_shows/dr_who.rb +115 -0
- data/lib/faker/tv_shows/dumb_and_dumber.rb +51 -0
- data/lib/faker/tv_shows/family_guy.rb +51 -0
- data/lib/faker/tv_shows/final_space.rb +51 -0
- data/lib/faker/tv_shows/friends.rb +50 -0
- data/lib/faker/tv_shows/futurama.rb +65 -0
- data/lib/faker/tv_shows/game_of_thrones.rb +77 -0
- data/lib/faker/tv_shows/hey_arnold.rb +50 -0
- data/lib/faker/tv_shows/how_i_met_your_mother.rb +64 -0
- data/lib/faker/tv_shows/michael_scott.rb +26 -0
- data/lib/faker/tv_shows/new_girl.rb +38 -0
- data/lib/faker/tv_shows/parks_and_rec.rb +37 -0
- data/lib/faker/tv_shows/rick_and_morty.rb +51 -0
- data/lib/faker/tv_shows/ru_paul.rb +37 -0
- data/lib/faker/tv_shows/seinfeld.rb +51 -0
- data/lib/faker/tv_shows/silicon_valley.rb +118 -0
- data/lib/faker/tv_shows/simpsons.rb +65 -0
- data/lib/faker/tv_shows/south_park.rb +38 -0
- data/lib/faker/tv_shows/star_trek.rb +63 -0
- data/lib/faker/tv_shows/stargate.rb +51 -0
- data/lib/faker/tv_shows/stranger_things.rb +38 -0
- data/lib/faker/tv_shows/suits.rb +37 -0
- data/lib/faker/tv_shows/the_expanse.rb +63 -0
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +64 -0
- data/lib/faker/tv_shows/the_it_crowd.rb +64 -0
- data/lib/faker/tv_shows/the_thick_of_it.rb +51 -0
- data/lib/faker/tv_shows/twin_peaks.rb +51 -0
- data/lib/faker/tv_shows/venture_bros.rb +65 -0
- data/lib/faker/version.rb +3 -1
- data/lib/helpers/base58.rb +22 -0
- data/lib/helpers/char.rb +31 -35
- data/lib/helpers/unique_generator.rb +28 -2
- data/lib/locales/README.md +8 -9
- data/lib/locales/ar.yml +102 -0
- data/lib/locales/bg.yml +5 -2
- data/lib/locales/ca-CAT.yml +1 -1
- data/lib/locales/ca.yml +2 -4
- data/lib/locales/da-DK.yml +10 -6
- data/lib/locales/de-AT.yml +12 -3
- data/lib/locales/de-CH.yml +1696 -1
- data/lib/locales/de.yml +19 -9
- data/lib/locales/ee.yml +61 -0
- data/lib/locales/en-AU.yml +50 -8
- data/lib/locales/en-CA.yml +27 -2
- data/lib/locales/en-GB.yml +2 -1
- data/lib/locales/en-IND.yml +5 -2
- data/lib/locales/en-MS.yml +8 -1
- data/lib/locales/en-NEP.yml +6 -3
- data/lib/locales/en-NG.yml +2 -0
- data/lib/locales/en-NZ.yml +140 -17
- data/lib/locales/en-PAK.yml +4 -2
- data/lib/locales/en-SG.yml +6 -1
- data/lib/locales/en-TH.yml +360 -0
- data/lib/locales/en-US.yml +37 -9
- data/lib/locales/en-ZA.yml +114 -17
- data/lib/locales/en-au-ocker.yml +2 -1
- data/lib/locales/en.yml +0 -1
- data/lib/locales/en/address.yml +501 -3
- data/lib/locales/en/adjective.yml +179 -0
- data/lib/locales/en/animal.yml +6 -0
- data/lib/locales/en/appliance.yml +5 -0
- data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
- data/lib/locales/en/bank.yml +275 -60
- data/lib/locales/en/barcode.yml +24 -0
- data/lib/locales/en/basketball.yml +99 -0
- data/lib/locales/en/beer.yml +2 -1
- data/lib/locales/en/big_bang_theory.yml +38 -0
- data/lib/locales/en/blood.yml +13 -0
- data/lib/locales/en/bojack_horseman.yml +6 -0
- data/lib/locales/en/buffy.yml +260 -0
- data/lib/locales/en/camera.yml +611 -0
- data/lib/locales/en/cannabis.yml +13 -0
- data/lib/locales/en/cat.yml +5 -4
- data/lib/locales/en/chiquito.yml +64 -0
- data/lib/locales/en/clash_of_clan.yml +101 -0
- data/lib/locales/en/coin.yml +6 -0
- data/lib/locales/en/color.yml +1 -1
- data/lib/locales/en/community.yml +33 -0
- data/lib/locales/en/company.yml +3 -2
- data/lib/locales/en/computer.yml +36 -0
- data/lib/locales/en/conan.yml +171 -0
- data/lib/locales/en/construction.yml +425 -0
- data/lib/locales/en/control.yml +247 -0
- data/lib/locales/en/cosmere.yml +57 -0
- data/lib/locales/en/crypto_coin.yml +25 -0
- data/lib/locales/en/culture_series.yml +307 -0
- data/lib/locales/en/currency.yml +6 -0
- data/lib/locales/en/dc_comics.yml +52 -0
- data/lib/locales/en/demographic.yml +218 -5
- data/lib/locales/en/departed.yml +50 -0
- data/lib/locales/en/dessert.yml +3 -3
- data/lib/locales/en/device.yml +115 -0
- data/lib/locales/en/dnd.yml +451 -0
- data/lib/locales/en/dog.yml +9 -9
- data/lib/locales/en/doraemon.yml +286 -0
- data/lib/locales/en/dota.yml +573 -0
- data/lib/locales/en/dr_who.yml +6 -2
- data/lib/locales/en/dragon_ball.yml +243 -1
- data/lib/locales/en/driving_license.yml +181 -0
- data/lib/locales/en/drone.yml +95 -0
- data/lib/locales/en/dumb_and_dumber.yml +1 -1
- data/lib/locales/en/dune.yml +401 -131
- data/lib/locales/en/educator.yml +76 -6
- data/lib/locales/en/elder_scrolls.yml +583 -5
- data/lib/locales/en/electrical_components.yml +6 -0
- data/lib/locales/en/esport.yml +5 -5
- data/lib/locales/en/fallout.yml +313 -134
- data/lib/locales/en/final_space.yml +37 -0
- data/lib/locales/en/finance.yml +116 -0
- data/lib/locales/en/food.yml +6 -2
- data/lib/locales/en/football.yml +8 -0
- data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
- data/lib/locales/en/friends.yml +3 -3
- data/lib/locales/en/futurama.yml +344 -0
- data/lib/locales/en/game.yml +283 -0
- data/lib/locales/en/gender.yml +6 -0
- data/lib/locales/en/ghostbusters.yml +91 -0
- data/lib/locales/en/grateful_dead.yml +48 -0
- data/lib/locales/en/greek_philosophers.yml +26 -0
- data/lib/locales/en/half_life.yml +88 -0
- data/lib/locales/en/harry_potter.yml +2 -1
- data/lib/locales/en/heroes.yml +411 -0
- data/lib/locales/en/heroes_of_the_storm.yml +134 -0
- data/lib/locales/en/horse.yml +6 -0
- data/lib/locales/en/house.yml +5 -0
- data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
- data/lib/locales/en/industry_segments.yml +7 -0
- data/lib/locales/en/invoice.yml +6 -0
- data/lib/locales/en/jack_handey.yml +54 -0
- data/lib/locales/en/job.yml +2 -2
- data/lib/locales/en/kpop.yml +3 -3
- data/lib/locales/en/league_of_legends.yml +287 -7
- data/lib/locales/en/lebowski.yml +1 -1
- data/lib/locales/en/lorem.yml +6 -0
- data/lib/locales/en/marketing.yml +4 -0
- data/lib/locales/en/michael_scott.yml +45 -0
- data/lib/locales/en/military.yml +182 -0
- data/lib/locales/en/minecraft.yml +663 -0
- data/lib/locales/en/mountain.yml +158 -0
- data/lib/locales/en/movie.yml +192 -1
- data/lib/locales/en/music.yml +451 -1
- data/lib/locales/en/myst.yml +104 -0
- data/lib/locales/en/name.yml +15 -14
- data/lib/locales/en/naruto.yml +231 -0
- data/lib/locales/en/nation.yml +11 -0
- data/lib/locales/en/nato_phonetic_alphabet.yml +4 -0
- data/lib/locales/en/new_girl.yml +40 -0
- data/lib/locales/en/one_piece.yml +2 -2
- data/lib/locales/en/opera.yml +340 -0
- data/lib/locales/en/overwatch.yml +2652 -33
- data/lib/locales/en/parks_and_rec.yml +7 -0
- data/lib/locales/en/pearl_jam.yml +213 -0
- data/lib/locales/en/phish.yml +395 -0
- data/lib/locales/en/phone_number.yml +2 -1
- data/lib/locales/en/pokemon.yml +419 -5
- data/lib/locales/en/prince.yml +227 -0
- data/lib/locales/en/princess_bride.yml +5 -0
- data/lib/locales/en/programming_language.yml +2 -1
- data/lib/locales/en/quote.yml +695 -0
- data/lib/locales/en/rajnikanth.yml +77 -0
- data/lib/locales/en/relationship.yml +10 -0
- data/lib/locales/en/restaurant.yml +129 -0
- data/lib/locales/en/rock_band.yml +1 -0
- data/lib/locales/en/room.yml +68 -0
- data/lib/locales/en/rupaul.yml +51 -21
- data/lib/locales/en/rush.yml +32 -0
- data/lib/locales/en/science.yml +1 -0
- data/lib/locales/en/seinfeld.yml +2 -1
- data/lib/locales/en/shakespeare.yml +23 -26
- data/lib/locales/en/show.yml +597 -0
- data/lib/locales/en/silicon_valley.yml +1 -0
- data/lib/locales/en/simpsons.yml +668 -0
- data/lib/locales/en/sonic_the_hedgehog.yml +410 -0
- data/lib/locales/en/source.yml +46 -0
- data/lib/locales/en/south_park.yml +5 -0
- data/lib/locales/en/space.yml +3 -2
- data/lib/locales/en/star_trek.yml +1 -1
- data/lib/locales/en/star_wars.yml +568 -210
- data/lib/locales/en/stargate.yml +1 -2
- data/lib/locales/en/stranger_thing.yml +36 -0
- data/lib/locales/en/street_fighter.yml +1524 -0
- data/lib/locales/en/stripe.yml +42 -0
- data/lib/locales/en/studio_ghibli.yml +107 -0
- data/lib/locales/en/subscription.yml +8 -0
- data/lib/locales/en/suits.yml +45 -0
- data/lib/locales/en/super_mario.yml +58 -0
- data/lib/locales/en/super_smash_bros.yml +220 -0
- data/lib/locales/en/sword_art_online.yml +334 -0
- data/lib/locales/en/team.yml +1 -1
- data/lib/locales/en/the_expanse.yml +7 -0
- data/lib/locales/en/the_it_crowd.yml +155 -0
- data/lib/locales/en/tolkien.yml +2453 -0
- data/lib/locales/en/touhou.yml +839 -0
- data/lib/locales/en/vehicle.yml +77 -49
- data/lib/locales/en/verbs.yml +8 -0
- data/lib/locales/en/volleyball.yml +501 -0
- data/lib/locales/en/warhammer_fantasy.yml +582 -0
- data/lib/locales/en/witcher.yml +391 -8
- data/lib/locales/en/world_cup.yml +271 -0
- data/lib/locales/en/world_of_warcraft.yml +124 -5
- data/lib/locales/en/zelda.yml +964 -5
- data/lib/locales/es-AR.yml +4603 -0
- data/lib/locales/es-MX.yml +17 -1
- data/lib/locales/es.yml +75 -1
- data/lib/locales/fa.yml +6 -0
- data/lib/locales/fi-FI.yml +12 -6
- data/lib/locales/fr-CA.yml +107 -0
- data/lib/locales/fr-CH.yml +78 -0
- data/lib/locales/fr.yml +65 -12
- data/lib/locales/he.yml +2 -0
- data/lib/locales/hy.yml +411 -0
- data/lib/locales/id.yml +7 -2
- data/lib/locales/it.yml +15 -3
- data/lib/locales/ja.yml +86 -15
- data/lib/locales/ko.yml +96 -2
- data/lib/locales/lv.yml +55 -0
- data/lib/locales/nb-NO.yml +15 -6
- data/lib/locales/nl.yml +13 -4
- data/lib/locales/no.yml +7 -0
- data/lib/locales/pl.yml +12 -1
- data/lib/locales/pt-BR.yml +624 -17
- data/lib/locales/pt.yml +16 -6
- data/lib/locales/ru.yml +6 -2
- data/lib/locales/sk.yml +21 -13
- data/lib/locales/sv.yml +15 -7
- data/lib/locales/th.yml +380 -0
- data/lib/locales/tr.yml +14 -0
- data/lib/locales/uk.yml +17 -4
- data/lib/locales/vi.yml +7 -2
- data/lib/locales/zh-CN.yml +4 -4
- data/lib/locales/zh-TW.yml +3 -1
- metadata +448 -127
- data/lib/extensions/array.rb +0 -22
- data/lib/extensions/symbol.rb +0 -9
- data/lib/faker/address.rb +0 -67
- data/lib/faker/ancient.rb +0 -21
- data/lib/faker/app.rb +0 -23
- data/lib/faker/aqua_teen_hunger_force.rb +0 -9
- data/lib/faker/artist.rb +0 -9
- data/lib/faker/avatar.rb +0 -15
- data/lib/faker/back_to_the_future.rb +0 -17
- data/lib/faker/bank.rb +0 -37
- data/lib/faker/beer.rb +0 -40
- data/lib/faker/bitcoin.rb +0 -48
- data/lib/faker/book.rb +0 -23
- data/lib/faker/boolean.rb +0 -9
- data/lib/faker/bossa_nova.rb +0 -13
- data/lib/faker/breaking_bad.rb +0 -16
- data/lib/faker/business.rb +0 -22
- data/lib/faker/cat.rb +0 -19
- data/lib/faker/chuck_norris.rb +0 -11
- data/lib/faker/code.rb +0 -147
- data/lib/faker/coffee.rb +0 -29
- data/lib/faker/color.rb +0 -30
- data/lib/faker/commerce.rb +0 -64
- data/lib/faker/company.rb +0 -162
- data/lib/faker/compass.rb +0 -65
- data/lib/faker/crypto.rb +0 -19
- data/lib/faker/date.rb +0 -80
- data/lib/faker/demographic.rb +0 -35
- data/lib/faker/dessert.rb +0 -19
- data/lib/faker/dog.rb +0 -39
- data/lib/faker/dr_who.rb +0 -34
- data/lib/faker/dragon_ball.rb +0 -9
- data/lib/faker/dumb_and_dumber.rb +0 -17
- data/lib/faker/dune.rb +0 -54
- data/lib/faker/educator.rb +0 -23
- data/lib/faker/elder_scrolls.rb +0 -21
- data/lib/faker/esport.rb +0 -25
- data/lib/faker/fallout.rb +0 -21
- data/lib/faker/family_guy.rb +0 -17
- data/lib/faker/file.rb +0 -24
- data/lib/faker/fillmurray.rb +0 -14
- data/lib/faker/finance.rb +0 -28
- data/lib/faker/food.rb +0 -25
- data/lib/faker/friends.rb +0 -17
- data/lib/faker/funny_name.rb +0 -43
- data/lib/faker/game_of_thrones.rb +0 -25
- data/lib/faker/hacker.rb +0 -45
- data/lib/faker/harry_potter.rb +0 -25
- data/lib/faker/hey_arnold.rb +0 -17
- data/lib/faker/hipster.rb +0 -59
- data/lib/faker/hitchhikers_guide_to_the_galaxy.rb +0 -33
- data/lib/faker/hobbit.rb +0 -21
- data/lib/faker/how_i_met_your_mother.rb +0 -21
- data/lib/faker/id_number.rb +0 -36
- data/lib/faker/internet.rb +0 -178
- data/lib/faker/job.rb +0 -16
- data/lib/faker/kpop.rb +0 -29
- data/lib/faker/league_of_legends.rb +0 -29
- data/lib/faker/lebowski.rb +0 -17
- data/lib/faker/lord_of_the_rings.rb +0 -13
- data/lib/faker/lorem.rb +0 -68
- data/lib/faker/lorem_pixel.rb +0 -21
- data/lib/faker/lovecraft.rb +0 -73
- data/lib/faker/markdown.rb +0 -67
- data/lib/faker/matz.rb +0 -9
- data/lib/faker/measurement.rb +0 -127
- data/lib/faker/most_interesting_man_in_the_world.rb +0 -9
- data/lib/faker/movie.rb +0 -9
- data/lib/faker/music.rb +0 -33
- data/lib/faker/name.rb +0 -46
- data/lib/faker/number.rb +0 -86
- data/lib/faker/omniauth.rb +0 -340
- data/lib/faker/one_piece.rb +0 -29
- data/lib/faker/overwatch.rb +0 -17
- data/lib/faker/phone_number.rb +0 -44
- data/lib/faker/placeholdit.rb +0 -20
- data/lib/faker/pokemon.rb +0 -17
- data/lib/faker/programming_language.rb +0 -13
- data/lib/faker/rick_and_morty.rb +0 -17
- data/lib/faker/robin.rb +0 -9
- data/lib/faker/rock_band.rb +0 -9
- data/lib/faker/rupaul.rb +0 -15
- data/lib/faker/science.rb +0 -15
- data/lib/faker/seinfeld.rb +0 -13
- data/lib/faker/shakespeare.rb +0 -40
- data/lib/faker/silicon_valley.rb +0 -33
- data/lib/faker/simpsons.rb +0 -22
- data/lib/faker/slack_emoji.rb +0 -43
- data/lib/faker/space.rb +0 -58
- data/lib/faker/star_trek.rb +0 -21
- data/lib/faker/star_wars.rb +0 -102
- data/lib/faker/stargate.rb +0 -17
- data/lib/faker/superhero.rb +0 -25
- data/lib/faker/team.rb +0 -24
- data/lib/faker/the_fresh_prince_of_bel_air.rb +0 -17
- data/lib/faker/the_thick_of_it.rb +0 -17
- data/lib/faker/time.rb +0 -51
- data/lib/faker/twin_peaks.rb +0 -17
- data/lib/faker/twitter.rb +0 -172
- data/lib/faker/types.rb +0 -93
- data/lib/faker/umphreys_mcgee.rb +0 -9
- data/lib/faker/university.rb +0 -28
- data/lib/faker/v_for_vendetta.rb +0 -17
- data/lib/faker/vehicle.rb +0 -39
- data/lib/faker/venture_bros.rb +0 -21
- data/lib/faker/witcher.rb +0 -29
- data/lib/faker/world_of_warcraft.rb +0 -13
- data/lib/faker/yoda.rb +0 -10
- data/lib/faker/zelda.rb +0 -22
- data/lib/locales/en/hobbit.yml +0 -19
- data/lib/locales/en/lord_of_the_rings.yml +0 -5
- data/lib/locales/en/matz.yml +0 -28
- data/lib/locales/en/most_interesting_man_in_the_world.yml +0 -106
- data/lib/locales/en/robin.yml +0 -4
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class House < Base
|
5
|
+
class << self
|
6
|
+
##
|
7
|
+
# Produces the name of a piece of furniture.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::House.furniture #=> "chair"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.2
|
15
|
+
def furniture
|
16
|
+
fetch('house.furniture')
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Produces the name of a room in a house.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::House.room #=> "kitchen"
|
26
|
+
#
|
27
|
+
# @faker.version 1.9.2
|
28
|
+
def room
|
29
|
+
fetch('house.rooms')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,279 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class IDNumber < Base
|
5
|
+
CHECKS = 'TRWAGMYFPDXBNJZSQVHLCKE'
|
6
|
+
INVALID_SSN = [
|
7
|
+
/0{3}-\d{2}-\d{4}/,
|
8
|
+
/\d{3}-0{2}-\d{4}/,
|
9
|
+
/\d{3}-\d{2}-0{4}/,
|
10
|
+
/666-\d{2}-\d{4}/,
|
11
|
+
/9\d{2}-\d{2}-\d{4}/
|
12
|
+
].freeze
|
13
|
+
ZA_RACE_DIGIT = '8'
|
14
|
+
ZA_CITIZENSHIP_DIGITS = %w[0 1].freeze
|
15
|
+
BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/.freeze
|
16
|
+
BRAZILIAN_ID_FROM = 10_000_000
|
17
|
+
BRAZILIAN_ID_TO = 99_999_999
|
18
|
+
|
19
|
+
CHILEAN_MODULO = 11
|
20
|
+
|
21
|
+
class << self
|
22
|
+
##
|
23
|
+
# Produces a random valid US Social Security number.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# Faker::IDNumber.valid #=> "552-56-3593"
|
29
|
+
#
|
30
|
+
# @faker.version 1.6.0
|
31
|
+
def valid
|
32
|
+
_translate('valid')
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Produces a random invalid US Social Security number.
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# Faker::IDNumber.invalid #=> "311-72-0000"
|
42
|
+
#
|
43
|
+
# @faker.version 1.6.0
|
44
|
+
def invalid
|
45
|
+
_translate('invalid')
|
46
|
+
end
|
47
|
+
|
48
|
+
def ssn_valid
|
49
|
+
ssn = regexify(/[0-8]\d{2}-\d{2}-\d{4}/)
|
50
|
+
# We could still have all 0s in one segment or another
|
51
|
+
INVALID_SSN.any? { |regex| regex =~ ssn } ? ssn_valid : ssn
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Produces a random Spanish citizen identifier (DNI).
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# Faker::IDNumber.spanish_citizen_number #=> "53290236-H"
|
61
|
+
#
|
62
|
+
# @faker.version 1.9.0
|
63
|
+
def spanish_citizen_number
|
64
|
+
num = Faker::Number.number(digits: 8)
|
65
|
+
mod = num.to_i % 23
|
66
|
+
check = CHECKS[mod]
|
67
|
+
"#{num}-#{check}"
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Produces a random Spanish foreign born citizen identifier (NIE).
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# Faker::IDNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y"
|
77
|
+
#
|
78
|
+
# @faker.version 1.9.0
|
79
|
+
def spanish_foreign_citizen_number
|
80
|
+
code = 'XYZ'
|
81
|
+
digits = Faker::Number.number(digits: 7)
|
82
|
+
prefix = code[rand(code.length)]
|
83
|
+
prefix_val = 'XYZ'.index(prefix).to_s
|
84
|
+
mod = "#{prefix_val}#{digits}".to_i % 23
|
85
|
+
check = CHECKS[mod]
|
86
|
+
"#{prefix}-#{digits}-#{check}"
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Produces a random valid South African ID Number.
|
91
|
+
#
|
92
|
+
# @return [String]
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# Faker::IDNumber.south_african_id_number #=> "8105128870184"
|
96
|
+
# Faker::IDNumber.valid_south_african_id_number #=> "8105128870184"
|
97
|
+
#
|
98
|
+
# @faker.version 1.9.2
|
99
|
+
def valid_south_african_id_number
|
100
|
+
id_number = [
|
101
|
+
Faker::Date.birthday.strftime('%y%m%d'),
|
102
|
+
Faker::Number.number(digits: 4),
|
103
|
+
ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random),
|
104
|
+
ZA_RACE_DIGIT
|
105
|
+
].join
|
106
|
+
|
107
|
+
[id_number, south_african_id_checksum_digit(id_number)].join
|
108
|
+
end
|
109
|
+
|
110
|
+
alias south_african_id_number valid_south_african_id_number
|
111
|
+
|
112
|
+
##
|
113
|
+
# Produces a random invalid South African ID Number.
|
114
|
+
#
|
115
|
+
# @return [String]
|
116
|
+
#
|
117
|
+
# @example
|
118
|
+
# Faker::IDNumber.invalid_south_african_id_number #=> "1642972065088"
|
119
|
+
#
|
120
|
+
# @faker.version 1.9.2
|
121
|
+
def invalid_south_african_id_number
|
122
|
+
invalid_date_of_birth = [
|
123
|
+
Faker::Number.number(digits: 2),
|
124
|
+
Faker::Number.between(from: 13, to: 99),
|
125
|
+
Faker::Number.between(from: 32, to: 99)
|
126
|
+
].map(&:to_s).join
|
127
|
+
|
128
|
+
id_number = [
|
129
|
+
invalid_date_of_birth,
|
130
|
+
Faker::Number.number(digits: 4),
|
131
|
+
ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random),
|
132
|
+
ZA_RACE_DIGIT
|
133
|
+
].join
|
134
|
+
|
135
|
+
[id_number, south_african_id_checksum_digit(id_number)].join
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Produces a random Brazilian Citizen Number (CPF).
|
140
|
+
#
|
141
|
+
# @param formatted [Boolean] Specifies if the number is formatted with dividers.
|
142
|
+
# @return [String]
|
143
|
+
#
|
144
|
+
# @example
|
145
|
+
# Faker::IDNumber.brazilian_citizen_number #=> "53540542221"
|
146
|
+
# Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21"
|
147
|
+
#
|
148
|
+
# @faker.version 1.9.2
|
149
|
+
def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
|
150
|
+
warn_for_deprecated_arguments do |keywords|
|
151
|
+
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
152
|
+
end
|
153
|
+
|
154
|
+
digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/)
|
155
|
+
first_digit = brazilian_citizen_number_checksum_digit(digits)
|
156
|
+
second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit)
|
157
|
+
number = [digits, first_digit, second_digit].join
|
158
|
+
formatted ? format('%s.%s.%s-%s', *number.scan(/\d{2,3}/).flatten) : number
|
159
|
+
end
|
160
|
+
|
161
|
+
alias brazilian_cpf brazilian_citizen_number
|
162
|
+
|
163
|
+
##
|
164
|
+
# Produces a random Brazilian ID Number (RG).
|
165
|
+
#
|
166
|
+
# @param formatted [Boolean] Specifies if the number is formatted with dividers.
|
167
|
+
# @return [String]
|
168
|
+
#
|
169
|
+
# @example
|
170
|
+
# Faker::IDNumber.brazilian_id #=> "493054029"
|
171
|
+
# Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9"
|
172
|
+
#
|
173
|
+
# @faker.version 2.1.2
|
174
|
+
def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
|
175
|
+
warn_for_deprecated_arguments do |keywords|
|
176
|
+
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
177
|
+
end
|
178
|
+
|
179
|
+
digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s
|
180
|
+
check_digit = brazilian_id_checksum_digit(digits)
|
181
|
+
number = [digits, check_digit].join
|
182
|
+
formatted ? format('%s.%s.%s-%s', *number.scan(BRAZILIAN_ID_FORMAT).flatten) : number
|
183
|
+
end
|
184
|
+
|
185
|
+
alias brazilian_rg brazilian_id
|
186
|
+
|
187
|
+
##
|
188
|
+
# Produces a random Chilean ID (Rut with 8 digits).
|
189
|
+
#
|
190
|
+
# @return [String]
|
191
|
+
#
|
192
|
+
# @example
|
193
|
+
# Faker::IDNumber.chilean_id #=> "15620613-K"
|
194
|
+
#
|
195
|
+
# @faker.version 2.1.2
|
196
|
+
def chilean_id
|
197
|
+
digits = Faker::Number.number(digits: 8)
|
198
|
+
verification_code = chilean_verification_code(digits)
|
199
|
+
|
200
|
+
"#{digits}-#{verification_code}"
|
201
|
+
end
|
202
|
+
|
203
|
+
private
|
204
|
+
|
205
|
+
def chilean_verification_code(digits)
|
206
|
+
# First digit is multiplied by 3, second by 2, and so on
|
207
|
+
multiplication_rule = [3, 2, 7, 6, 5, 4, 3, 2]
|
208
|
+
digits_splitted = digits.to_s.chars.map(&:to_i)
|
209
|
+
|
210
|
+
sum = digits_splitted.map.with_index { |digit, index| digit * multiplication_rule[index] }.reduce(:+)
|
211
|
+
|
212
|
+
modulo = sum.modulo(CHILEAN_MODULO)
|
213
|
+
difference = CHILEAN_MODULO - modulo
|
214
|
+
|
215
|
+
case difference
|
216
|
+
when 0..9
|
217
|
+
difference
|
218
|
+
when 10
|
219
|
+
'K'
|
220
|
+
when 11
|
221
|
+
0
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def south_african_id_checksum_digit(id_number)
|
226
|
+
value_parts = id_number.chars
|
227
|
+
even_digits = value_parts
|
228
|
+
.select
|
229
|
+
.with_index { |_, i| (i + 1).even? }
|
230
|
+
odd_digits_without_last_character = value_parts[0...-1]
|
231
|
+
.select
|
232
|
+
.with_index { |_, i| (i + 1).odd? }
|
233
|
+
|
234
|
+
sum_of_odd_digits = odd_digits_without_last_character.map(&:to_i).reduce(:+)
|
235
|
+
even_digits_times_two = (even_digits.join('').to_i * 2).to_s
|
236
|
+
sum_of_even_digits = even_digits_times_two.chars.map(&:to_i).reduce(:+)
|
237
|
+
|
238
|
+
total_sum = sum_of_odd_digits + sum_of_even_digits
|
239
|
+
|
240
|
+
((10 - (total_sum % 10)) % 10).to_s
|
241
|
+
end
|
242
|
+
|
243
|
+
def brazilian_citizen_number_checksum_digit(digits)
|
244
|
+
checksum = brazilian_document_checksum(digits)
|
245
|
+
brazilian_document_digit(checksum)
|
246
|
+
end
|
247
|
+
|
248
|
+
def brazilian_id_checksum_digit(digits)
|
249
|
+
checksum = brazilian_document_checksum(digits)
|
250
|
+
brazilian_document_digit(checksum, id: true)
|
251
|
+
end
|
252
|
+
|
253
|
+
def brazilian_document_checksum(digits)
|
254
|
+
digits.chars.each_with_index.inject(0) do |acc, (digit, i)|
|
255
|
+
acc + digit.to_i * (digits.size + 1 - i)
|
256
|
+
end * 10
|
257
|
+
end
|
258
|
+
|
259
|
+
def brazilian_document_digit(checksum, id: false)
|
260
|
+
remainder = checksum % 11
|
261
|
+
id ? brazilian_id_digit(remainder) : brazilian_citizen_number_digit(remainder)
|
262
|
+
end
|
263
|
+
|
264
|
+
def brazilian_citizen_number_digit(remainder)
|
265
|
+
remainder == 10 ? '0' : remainder.to_s
|
266
|
+
end
|
267
|
+
|
268
|
+
def brazilian_id_digit(remainder)
|
269
|
+
subtraction = 11 - remainder.to_i
|
270
|
+
digits = { 10 => 'X', 11 => '0' }
|
271
|
+
digits.include?(subtraction) ? digits[subtraction] : subtraction.to_s
|
272
|
+
end
|
273
|
+
|
274
|
+
def _translate(key)
|
275
|
+
parse("id_number.#{key}")
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class IndustrySegments < Base
|
5
|
+
flexible :industry_segments
|
6
|
+
|
7
|
+
class << self
|
8
|
+
##
|
9
|
+
# Produces the name of an industry.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::IndustrySegments.industry #=> "Basic Materials"
|
15
|
+
#
|
16
|
+
# @faker.version 1.9.2
|
17
|
+
def industry
|
18
|
+
fetch('industry_segments.industry')
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Produces the name of a super-sector of an industry.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::IndustrySegments.super_sector #=> "Basic Resources"
|
28
|
+
#
|
29
|
+
# @faker.version 1.9.2
|
30
|
+
def super_sector
|
31
|
+
fetch('industry_segments.super_sector')
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Produces the name of a sector of an industry.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Faker::IndustrySegments.sector #=> "Industrial Metals & Mining"
|
41
|
+
#
|
42
|
+
# @faker.version 1.9.2
|
43
|
+
def sector
|
44
|
+
fetch('industry_segments.sector')
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Produces the name of a subsector of an industry.
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# Faker::IndustrySegments.industry #=> "Basic Materials"
|
54
|
+
#
|
55
|
+
# @faker.version 1.9.2
|
56
|
+
def sub_sector
|
57
|
+
fetch('industry_segments.sub_sector')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,584 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class Internet < Base
|
5
|
+
class << self
|
6
|
+
##
|
7
|
+
# Returns the email address
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @param name [String]
|
12
|
+
# @param separators [Array]
|
13
|
+
# @param domain [String]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# Faker::Internet.email #=> "samsmith@faker.com"
|
17
|
+
# Faker::Internet.email(name: 'smith') #=> "smith@faker.com"
|
18
|
+
# Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "sam-smith@faker.com"
|
19
|
+
# Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'gmail') #=> "sam-smith@gmail.com"
|
20
|
+
def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil, domain: nil)
|
21
|
+
warn_for_deprecated_arguments do |keywords|
|
22
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
23
|
+
keywords << :separators if legacy_separators != NOT_GIVEN
|
24
|
+
end
|
25
|
+
|
26
|
+
local_part = if separators
|
27
|
+
username(specifier: name, separators: separators)
|
28
|
+
else
|
29
|
+
username(specifier: name)
|
30
|
+
end
|
31
|
+
|
32
|
+
sanitized_local_part = sanitize_email_local_part(local_part)
|
33
|
+
construct_email(sanitized_local_part, domain_name(domain: domain))
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Returns the email address with doamin either gmail.com, yahoo.com or hotmail.com
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
# @param name [String]
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
# Faker::Internet.free_email #=> "samsmith@gmail.com"
|
45
|
+
# Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com"
|
46
|
+
def free_email(legacy_name = NOT_GIVEN, name: nil)
|
47
|
+
warn_for_deprecated_arguments do |keywords|
|
48
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
49
|
+
end
|
50
|
+
|
51
|
+
construct_email(
|
52
|
+
sanitize_email_local_part(username(specifier: name)),
|
53
|
+
fetch('internet.free_email')
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Returns the email address with fixed domain name as 'example'
|
59
|
+
#
|
60
|
+
# @return [String]
|
61
|
+
#
|
62
|
+
# @param name [String]
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# Faker::Internet.safe_email #=> "samsmith@example.com"
|
66
|
+
# Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net"
|
67
|
+
def safe_email(legacy_name = NOT_GIVEN, name: nil)
|
68
|
+
warn_for_deprecated_arguments do |keywords|
|
69
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
70
|
+
end
|
71
|
+
|
72
|
+
construct_email(
|
73
|
+
sanitize_email_local_part(username(specifier: name)),
|
74
|
+
"example.#{sample(%w[org com net])}"
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Returns the username
|
80
|
+
#
|
81
|
+
# @return [String]
|
82
|
+
#
|
83
|
+
# @param specifier [Integer, Range] When int value passed it returns the username longer than specifier. Max value can be 10^6
|
84
|
+
# @param separator [Array]
|
85
|
+
#
|
86
|
+
# @wxample
|
87
|
+
# Faker::Internet.username(specifier: 10) #=> "lulu.goodwin"
|
88
|
+
# Faker::Internet.username(specifier: 5..10) #=> "morris"
|
89
|
+
# Faker::Internet.username(specifier: 5..10) #=> "berryberry"
|
90
|
+
# Faker::Internet.username(specifier: 20, separators: ['-']) #=> "nikki_sawaynnikki_saway"
|
91
|
+
def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
|
92
|
+
warn_for_deprecated_arguments do |keywords|
|
93
|
+
keywords << :specifier if legacy_specifier != NOT_GIVEN
|
94
|
+
keywords << :separators if legacy_separators != NOT_GIVEN
|
95
|
+
end
|
96
|
+
|
97
|
+
with_locale(:en) do
|
98
|
+
return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan)
|
99
|
+
|
100
|
+
case specifier
|
101
|
+
when Integer
|
102
|
+
# If specifier is Integer and has large value, Argument error exception is raised to overcome memory full error
|
103
|
+
raise ArgumentError, 'Given argument is too large' if specifier > 10**6
|
104
|
+
|
105
|
+
tries = 0 # Don't try forever in case we get something like 1_000_000.
|
106
|
+
result = nil
|
107
|
+
loop do
|
108
|
+
result = username(specifier: nil, separators: separators)
|
109
|
+
tries += 1
|
110
|
+
break unless result.length < specifier && tries < 7
|
111
|
+
end
|
112
|
+
return result * (specifier / result.length + 1) if specifier.positive?
|
113
|
+
when Range
|
114
|
+
tries = 0
|
115
|
+
result = nil
|
116
|
+
loop do
|
117
|
+
result = username(specifier: specifier.min, separators: separators)
|
118
|
+
tries += 1
|
119
|
+
break unless !specifier.include?(result.length) && tries < 7
|
120
|
+
end
|
121
|
+
return result[0...specifier.max]
|
122
|
+
end
|
123
|
+
|
124
|
+
sample([
|
125
|
+
Char.prepare(Name.first_name),
|
126
|
+
[Name.first_name, Name.last_name].map do |name|
|
127
|
+
Char.prepare(name)
|
128
|
+
end.join(sample(separators))
|
129
|
+
])
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# rubocop:disable Metrics/ParameterLists
|
134
|
+
|
135
|
+
##
|
136
|
+
# Produces a randomized string of characters suitable for passwords
|
137
|
+
#
|
138
|
+
# @param min_length [Integer] The minimum length of the password
|
139
|
+
# @param max_length [Integer] The maximum length of the password
|
140
|
+
# @param mix_case [Boolean] Toggles if uppercased letters are allowed. If true, at least one will be added.
|
141
|
+
# @param special_characters [Boolean] Toggles if special characters are allowed. If true, at least one will be added.
|
142
|
+
#
|
143
|
+
# @return [String]
|
144
|
+
#
|
145
|
+
# @example
|
146
|
+
# Faker::Internet.password #=> "Vg5mSvY1UeRg7"
|
147
|
+
# @example
|
148
|
+
# Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0"
|
149
|
+
# @example
|
150
|
+
# Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw"
|
151
|
+
# @example
|
152
|
+
# Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG"
|
153
|
+
# @example
|
154
|
+
# Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
|
155
|
+
#
|
156
|
+
# @faker.version 2.1.3
|
157
|
+
def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false)
|
158
|
+
warn_for_deprecated_arguments do |keywords|
|
159
|
+
keywords << :min_length if legacy_min_length != NOT_GIVEN
|
160
|
+
keywords << :max_length if legacy_max_length != NOT_GIVEN
|
161
|
+
keywords << :mix_case if legacy_mix_case != NOT_GIVEN
|
162
|
+
keywords << :special_characters if legacy_special_characters != NOT_GIVEN
|
163
|
+
end
|
164
|
+
|
165
|
+
min_alpha = mix_case && min_length > 1 ? 2 : 0
|
166
|
+
temp = Lorem.characters(number: min_length, min_alpha: min_alpha)
|
167
|
+
diff_length = max_length - min_length
|
168
|
+
|
169
|
+
if diff_length.positive?
|
170
|
+
diff_rand = rand(diff_length + 1)
|
171
|
+
temp += Lorem.characters(number: diff_rand)
|
172
|
+
end
|
173
|
+
|
174
|
+
if mix_case
|
175
|
+
alpha_count = 0
|
176
|
+
temp.chars.each_with_index do |char, index|
|
177
|
+
if char =~ /[[:alpha:]]/
|
178
|
+
temp[index] = char.upcase if alpha_count.even?
|
179
|
+
alpha_count += 1
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
if special_characters
|
185
|
+
chars = %w[! @ # $ % ^ & *]
|
186
|
+
rand(1..min_length).times do |i|
|
187
|
+
temp[i] = chars[rand(chars.length)]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
temp
|
192
|
+
end
|
193
|
+
# rubocop:enable Metrics/ParameterLists
|
194
|
+
|
195
|
+
##
|
196
|
+
# Returns the domain name
|
197
|
+
#
|
198
|
+
# @return [String]
|
199
|
+
#
|
200
|
+
# @param subdomain [Bool] If true passed adds a subdomain in response
|
201
|
+
# @param domain [String]
|
202
|
+
#
|
203
|
+
# @example
|
204
|
+
# Faker::Internet.domain_name #=> "test.net"
|
205
|
+
# Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io"
|
206
|
+
# Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com"
|
207
|
+
# Faker::Internet.domain_name(domain: 'faker') #=> "faker.org"
|
208
|
+
def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil)
|
209
|
+
warn_for_deprecated_arguments do |keywords|
|
210
|
+
keywords << :subdomain if legacy_subdomain != NOT_GIVEN
|
211
|
+
end
|
212
|
+
|
213
|
+
with_locale(:en) do
|
214
|
+
if domain
|
215
|
+
domain
|
216
|
+
.split('.')
|
217
|
+
.map { |domain_part| Char.prepare(domain_part) }
|
218
|
+
.tap do |domain_elements|
|
219
|
+
domain_elements << domain_suffix if domain_elements.length < 2
|
220
|
+
domain_elements.unshift(Char.prepare(domain_word)) if subdomain && domain_elements.length < 3
|
221
|
+
end.join('.')
|
222
|
+
else
|
223
|
+
[domain_word, domain_suffix].tap do |domain_elements|
|
224
|
+
domain_elements.unshift(Char.prepare(domain_word)) if subdomain
|
225
|
+
end.join('.')
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# rubocop:disable Style/AsciiComments
|
231
|
+
|
232
|
+
##
|
233
|
+
# Fixes ä, ö, ü, ß characters in string passed with ae, oe, ue, ss resp.
|
234
|
+
#
|
235
|
+
# @return [String]
|
236
|
+
#
|
237
|
+
# @param string [String]
|
238
|
+
#
|
239
|
+
# @example
|
240
|
+
# Faker::Internet.fix_umlauts #=> ""
|
241
|
+
# Faker::Internet.fix_umlauts(string: 'faker') #=> "faker"
|
242
|
+
# Faker::Internet.fix_umlauts(string: 'faküer') #=> "fakueer"
|
243
|
+
def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
|
244
|
+
warn_for_deprecated_arguments do |keywords|
|
245
|
+
keywords << :string if legacy_string != NOT_GIVEN
|
246
|
+
end
|
247
|
+
|
248
|
+
Char.fix_umlauts(string)
|
249
|
+
end
|
250
|
+
# rubocop:enable Style/AsciiComments
|
251
|
+
|
252
|
+
##
|
253
|
+
# Returns the domain word for internet
|
254
|
+
#
|
255
|
+
# @return [String]
|
256
|
+
#
|
257
|
+
# @example
|
258
|
+
# Faker::Internet.domain_word #=> "senger"
|
259
|
+
def domain_word
|
260
|
+
with_locale(:en) { Char.prepare(Company.name.split(' ').first) }
|
261
|
+
end
|
262
|
+
|
263
|
+
## Returns the domain suffix e.g. com, org, co, biz, info etc.
|
264
|
+
#
|
265
|
+
# @return [String]
|
266
|
+
#
|
267
|
+
# @wxample
|
268
|
+
# Faker::Internet.domain_suffix #=> "com"
|
269
|
+
# Faker::Internet.domain_suffix #=> "biz"
|
270
|
+
def domain_suffix
|
271
|
+
fetch('internet.domain_suffix')
|
272
|
+
end
|
273
|
+
|
274
|
+
##
|
275
|
+
# Returns the MAC address
|
276
|
+
#
|
277
|
+
# @return [String]
|
278
|
+
#
|
279
|
+
# @example
|
280
|
+
# Faker::Internet.mac_address #=> "74:d0:c9:22:95:12"
|
281
|
+
# Faker::Internet.mac_address(prefix: 'a') #=> "0a:91:ce:24:89:3b"
|
282
|
+
# Faker::Internet.mac_address(prefix: 'aa') #=> "aa:38:a0:3e:e8:41"
|
283
|
+
# Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
|
284
|
+
def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
|
285
|
+
warn_for_deprecated_arguments do |keywords|
|
286
|
+
keywords << :prefix if legacy_prefix != NOT_GIVEN
|
287
|
+
end
|
288
|
+
|
289
|
+
prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
|
290
|
+
address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
|
291
|
+
(prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
|
292
|
+
end
|
293
|
+
|
294
|
+
##
|
295
|
+
# Returns the IPv4 address
|
296
|
+
#
|
297
|
+
# @return [String]
|
298
|
+
#
|
299
|
+
# @example
|
300
|
+
# Faker::Internet.ip_v4_address #=> "97.117.128.93"
|
301
|
+
def ip_v4_address
|
302
|
+
[rand_in_range(0, 255), rand_in_range(0, 255),
|
303
|
+
rand_in_range(0, 255), rand_in_range(0, 255)].join('.')
|
304
|
+
end
|
305
|
+
|
306
|
+
##
|
307
|
+
# Returns the private IPv4 address
|
308
|
+
#
|
309
|
+
# @return [String]
|
310
|
+
#
|
311
|
+
# @example
|
312
|
+
# Faker::Internet.private_ip_v4_address #=> "127.120.80.42"
|
313
|
+
def private_ip_v4_address
|
314
|
+
addr = nil
|
315
|
+
loop do
|
316
|
+
addr = ip_v4_address
|
317
|
+
break if private_net_checker[addr]
|
318
|
+
end
|
319
|
+
addr
|
320
|
+
end
|
321
|
+
|
322
|
+
##
|
323
|
+
# Returns the public IPv4 address
|
324
|
+
#
|
325
|
+
# @return [String]
|
326
|
+
#
|
327
|
+
# @example
|
328
|
+
# Faker::Internet.public_ip_v4_address #=> "127.120.80.42"
|
329
|
+
def public_ip_v4_address
|
330
|
+
addr = nil
|
331
|
+
loop do
|
332
|
+
addr = ip_v4_address
|
333
|
+
break unless reserved_net_checker[addr]
|
334
|
+
end
|
335
|
+
addr
|
336
|
+
end
|
337
|
+
|
338
|
+
##
|
339
|
+
# Returns the private network regular expressions
|
340
|
+
#
|
341
|
+
# @return [Array]
|
342
|
+
#
|
343
|
+
# @example
|
344
|
+
# Faker::Internet.private_nets_regex #=> [/^10\./, /^100\.(6[4-9]|[7-9]\d|1[0-1]\d|12[0-7])\./, /^127\./, /^169\.254\./, /^172\.(1[6-9]|2\d|3[0-1])\./, /^192\.0\.0\./, /^192\.168\./, /^198\.(1[8-9])\./]
|
345
|
+
def private_nets_regex
|
346
|
+
[
|
347
|
+
/^10\./, # 10.0.0.0 - 10.255.255.255
|
348
|
+
/^100\.(6[4-9]|[7-9]\d|1[0-1]\d|12[0-7])\./, # 100.64.0.0 - 100.127.255.255
|
349
|
+
/^127\./, # 127.0.0.0 - 127.255.255.255
|
350
|
+
/^169\.254\./, # 169.254.0.0 - 169.254.255.255
|
351
|
+
/^172\.(1[6-9]|2\d|3[0-1])\./, # 172.16.0.0 - 172.31.255.255
|
352
|
+
/^192\.0\.0\./, # 192.0.0.0 - 192.0.0.255
|
353
|
+
/^192\.168\./, # 192.168.0.0 - 192.168.255.255
|
354
|
+
/^198\.(1[8-9])\./ # 198.18.0.0 - 198.19.255.255
|
355
|
+
]
|
356
|
+
end
|
357
|
+
|
358
|
+
##
|
359
|
+
# Returns lambda to check if address passed is private or not
|
360
|
+
#
|
361
|
+
# @return [Lambda]
|
362
|
+
#
|
363
|
+
# @example
|
364
|
+
# Faker::Internet.private_net_checker.call("127.120.80.42") #=> true
|
365
|
+
# Faker::Internet.private_net_checker.call("148.120.80.42") #=> false
|
366
|
+
def private_net_checker
|
367
|
+
->(addr) { private_nets_regex.any? { |net| net =~ addr } }
|
368
|
+
end
|
369
|
+
|
370
|
+
##
|
371
|
+
# Returns the reserved network regular expressions
|
372
|
+
#
|
373
|
+
# @return [Array]
|
374
|
+
#
|
375
|
+
# @example
|
376
|
+
# Faker::Internet.reserved_nets_regex #=> [/^0\./, /^192\.0\.2\./, /^192\.88\.99\./, /^198\.51\.100\./, /^203\.0\.113\./, /^(22[4-9]|23\d)\./, /^(24\d|25[0-5])\./]
|
377
|
+
def reserved_nets_regex
|
378
|
+
[
|
379
|
+
/^0\./, # 0.0.0.0 - 0.255.255.255
|
380
|
+
/^192\.0\.2\./, # 192.0.2.0 - 192.0.2.255
|
381
|
+
/^192\.88\.99\./, # 192.88.99.0 - 192.88.99.255
|
382
|
+
/^198\.51\.100\./, # 198.51.100.0 - 198.51.100.255
|
383
|
+
/^203\.0\.113\./, # 203.0.113.0 - 203.0.113.255
|
384
|
+
/^(22[4-9]|23\d)\./, # 224.0.0.0 - 239.255.255.255
|
385
|
+
/^(24\d|25[0-5])\./ # 240.0.0.0 - 255.255.255.254 and 255.255.255.255
|
386
|
+
]
|
387
|
+
end
|
388
|
+
|
389
|
+
##
|
390
|
+
# Returns lambda function to check address passed is reserverd or not
|
391
|
+
#
|
392
|
+
# @return [Lambda]
|
393
|
+
#
|
394
|
+
# @example
|
395
|
+
# Faker::Internet.reserved_net_checker.call('192.88.99.255') #=> true
|
396
|
+
# Faker::Internet.reserved_net_checker.call('192.88.199.255') #=> false
|
397
|
+
def reserved_net_checker
|
398
|
+
->(addr) { (private_nets_regex + reserved_nets_regex).any? { |net| net =~ addr } }
|
399
|
+
end
|
400
|
+
|
401
|
+
##
|
402
|
+
# Returns Ipv4 address with CIDR, range from 1 to 31
|
403
|
+
#
|
404
|
+
# @return [String]
|
405
|
+
#
|
406
|
+
# @example
|
407
|
+
# Faker::Internet.ip_v4_cidr #=> "129.162.99.74/16"
|
408
|
+
# Faker::Internet.ip_v4_cidr #=> "129.162.99.74/24"
|
409
|
+
def ip_v4_cidr
|
410
|
+
"#{ip_v4_address}/#{rand(1..31)}"
|
411
|
+
end
|
412
|
+
|
413
|
+
##
|
414
|
+
# Returns Ipv6 address
|
415
|
+
#
|
416
|
+
# @return [String]
|
417
|
+
#
|
418
|
+
# @example
|
419
|
+
# Faker::Internet.ip_v6_address #=> "7754:76d4:c7aa:7646:ea68:1abb:4055:4343"
|
420
|
+
def ip_v6_address
|
421
|
+
(1..8).map { rand(65_536).to_s(16) }.join(':')
|
422
|
+
end
|
423
|
+
|
424
|
+
##
|
425
|
+
# Returns Ipv6 address with CIDR, range between 1 to 127
|
426
|
+
#
|
427
|
+
# @return [String]
|
428
|
+
#
|
429
|
+
# @example
|
430
|
+
# Faker::Internet.ip_v6_cidr #=> "beca:9b99:4bb6:9712:af2f:516f:8507:96e1/99"
|
431
|
+
def ip_v6_cidr
|
432
|
+
"#{ip_v6_address}/#{rand(1..127)}"
|
433
|
+
end
|
434
|
+
|
435
|
+
# rubocop:disable Metrics/ParameterLists
|
436
|
+
|
437
|
+
##
|
438
|
+
# Returns URL
|
439
|
+
#
|
440
|
+
# @return [String]
|
441
|
+
#
|
442
|
+
# @param host [String]
|
443
|
+
# @param path [String]
|
444
|
+
# @param scheme [String]
|
445
|
+
#
|
446
|
+
# @example
|
447
|
+
# Faker::Internet.url #=> "http://sipes-okon.com/hung.macejkovic"
|
448
|
+
# Faker::Internet.url(host: 'faker') #=> "http://faker/shad"
|
449
|
+
# Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path"
|
450
|
+
# Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path"
|
451
|
+
def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
|
452
|
+
warn_for_deprecated_arguments do |keywords|
|
453
|
+
keywords << :host if legacy_host != NOT_GIVEN
|
454
|
+
keywords << :path if legacy_path != NOT_GIVEN
|
455
|
+
keywords << :scheme if legacy_scheme != NOT_GIVEN
|
456
|
+
end
|
457
|
+
|
458
|
+
"#{scheme}://#{host}#{path}"
|
459
|
+
end
|
460
|
+
# rubocop:enable Metrics/ParameterLists
|
461
|
+
|
462
|
+
##
|
463
|
+
# Returns unique string in URL
|
464
|
+
#
|
465
|
+
# @return [String]
|
466
|
+
#
|
467
|
+
# @param words [String] Comma or period separated words list
|
468
|
+
# @param glue [String] Separator to add between words passed, default used are '-' or '_'
|
469
|
+
#
|
470
|
+
# @example
|
471
|
+
# Faker::Internet.slug #=> "repudiandae-sed"
|
472
|
+
# Faker::Internet.slug(words: 'test, faker') #=> "test-faker"
|
473
|
+
# Faker::Internet.slug(words: 'test. faker') #=> "test-faker"
|
474
|
+
# Faker::Internet.slug(words: 'test. faker', glue: '$') #=> "test$faker"
|
475
|
+
def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
|
476
|
+
warn_for_deprecated_arguments do |keywords|
|
477
|
+
keywords << :words if legacy_words != NOT_GIVEN
|
478
|
+
keywords << :glue if legacy_glue != NOT_GIVEN
|
479
|
+
end
|
480
|
+
|
481
|
+
glue ||= sample(%w[- _])
|
482
|
+
(words || Faker::Lorem.words(number: 2).join(' ')).delete(',.').gsub(' ', glue).downcase
|
483
|
+
end
|
484
|
+
|
485
|
+
##
|
486
|
+
# Generates random token
|
487
|
+
#
|
488
|
+
# @return[String]
|
489
|
+
#
|
490
|
+
# @example
|
491
|
+
# Faker::Internet.device_token #=> "749f535671cf6b34d8e794d212d00c703b96274e07161b18b082d0d70ef1052f"
|
492
|
+
def device_token
|
493
|
+
shuffle(rand(16**64).to_s(16).rjust(64, '0').chars.to_a).join
|
494
|
+
end
|
495
|
+
|
496
|
+
##
|
497
|
+
# Generates the random browser identifier
|
498
|
+
#
|
499
|
+
# @return [String]
|
500
|
+
#
|
501
|
+
# @param vendor [String] Name of vendor, supported vendors are aol, chrome, firefox, internet_explorer, netscape, opera, safari
|
502
|
+
#
|
503
|
+
# @example
|
504
|
+
# Faker::Internet.user_agent #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
|
505
|
+
# Faker::Internet.user_agent(vendor: 'chrome') #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
|
506
|
+
# Faker::Internet.user_agent(vendor: 'safari') #=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"
|
507
|
+
# Faker::Internet.user_agent(vendor: 'faker') #=> "Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285"
|
508
|
+
def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
|
509
|
+
warn_for_deprecated_arguments do |keywords|
|
510
|
+
keywords << :vendor if legacy_vendor != NOT_GIVEN
|
511
|
+
end
|
512
|
+
|
513
|
+
agent_hash = translate('faker.internet.user_agent')
|
514
|
+
agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)]
|
515
|
+
sample(agents)
|
516
|
+
end
|
517
|
+
|
518
|
+
##
|
519
|
+
# Generated universally unique identifier
|
520
|
+
#
|
521
|
+
# @return [String]
|
522
|
+
#
|
523
|
+
# @example
|
524
|
+
# Faker::Internet.uuid #=> "8a6cdd40-6d78-4fdb-912b-190e3057197f"
|
525
|
+
def uuid
|
526
|
+
# borrowed from: https://github.com/ruby/ruby/blob/d48783bb0236db505fe1205d1d9822309de53a36/lib/securerandom.rb#L250
|
527
|
+
ary = Faker::Config.random.bytes(16).unpack('NnnnnN')
|
528
|
+
ary[2] = (ary[2] & 0x0fff) | 0x4000
|
529
|
+
ary[3] = (ary[3] & 0x3fff) | 0x8000
|
530
|
+
'%08x-%04x-%04x-%04x-%04x%08x' % ary # rubocop:disable Style/FormatString
|
531
|
+
end
|
532
|
+
|
533
|
+
##
|
534
|
+
# Produces a random string of alphabetic characters, (no digits)
|
535
|
+
#
|
536
|
+
# @param length [Integer] The length of the string to generate
|
537
|
+
# @param padding [Boolean] Toggles if a final equal '=' will be added.
|
538
|
+
# @param urlsafe [Boolean] Toggles charset to '-' and '_' instead of '+' and '/'.
|
539
|
+
#
|
540
|
+
# @return [String]
|
541
|
+
#
|
542
|
+
# @example
|
543
|
+
# Faker::Internet.base64
|
544
|
+
# #=> "r_hbZ2DSD-ZACzZT"
|
545
|
+
# @example
|
546
|
+
# Faker::Internet.base64(length: 4, padding: true, urlsafe: false)
|
547
|
+
# #=> "x1/R="
|
548
|
+
#
|
549
|
+
# @faker.version 2.11.0
|
550
|
+
def base64(length: 16, padding: false, urlsafe: true)
|
551
|
+
char_range = [
|
552
|
+
Array('0'..'9'),
|
553
|
+
Array('A'..'Z'),
|
554
|
+
Array('a'..'z'),
|
555
|
+
urlsafe ? %w[- _] : %w[+ /]
|
556
|
+
].flatten
|
557
|
+
s = Array.new(length) { sample(char_range) }.join
|
558
|
+
s += '=' if padding
|
559
|
+
s
|
560
|
+
end
|
561
|
+
|
562
|
+
alias user_name username
|
563
|
+
|
564
|
+
private
|
565
|
+
|
566
|
+
def sanitize_email_local_part(local_part)
|
567
|
+
char_range = [
|
568
|
+
Array('0'..'9'),
|
569
|
+
Array('A'..'Z'),
|
570
|
+
Array('a'..'z'),
|
571
|
+
"!#$%&'*+-/=?^_`{|}~.".split(//)
|
572
|
+
].flatten
|
573
|
+
|
574
|
+
local_part.split(//).map do |char|
|
575
|
+
char_range.include?(char) ? char : '#'
|
576
|
+
end.join
|
577
|
+
end
|
578
|
+
|
579
|
+
def construct_email(local_part, domain_name)
|
580
|
+
[local_part, domain_name].join('@')
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end
|