Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecate safe_email and free_email methods #2841

Merged
merged 7 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions doc/default/internet.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
# Faker::Internet

### About faker-ruby transition to be RFC 2606 compliant

faker-ruby is transitioning to no longer generating real email and url addresses.

The migration plan is:
- First step:
- change `email` and `domain_name` to be RFC 2606 compliant. Both now generate safe values by default using the Reserved Top Level DNS Names: `example` and `test`. To maintain backwards compatibility and give users the option to use non-safe domains at their own risk, custom domains are allowed.
- add deprecation message for `free_email` and `safe_email` users to switch to `email` instead.
- Second step (after October 2023):
- remove deprecated generators and locales.

To give users time, once the first step is released, users will have until October 2023 to make the necessary changes.

```ruby
# Keyword arguments: name, username, email, password, domain_name, user_agent, uuid etc...
Faker::Internet.user #=> { username: 'alexie', email: 'trudie@grant.test' }
Expand All @@ -25,15 +12,6 @@ Faker::Internet.email(name: 'Janelle Santiago', separators: ['+']) #=> "janelle+
Faker::Internet.email(domain: 'gmail.com') #=> "foo@gmail.com"
Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'test') #=> "sam-smith@test.test"

# Keyword arguments: name
Faker::Internet.free_email #=> "freddy@gmail.com"
Faker::Internet.free_email(name: 'Nancy') #=> "nancy@yahoo.com"

# Generates an RFC 2606 compliant fake email, which means it will never deliver successfully
# Keyword arguments: name
Faker::Internet.safe_email #=> "christelle@example.org"
Faker::Internet.safe_email(name: 'Nancy') #=> "nancy@example.net"

# Keyword arguments: specifier, separators
Faker::Internet.username #=> "alexie"
Faker::Internet.username(specifier: 'Nancy') #=> "nancy"
Expand Down
38 changes: 0 additions & 38 deletions lib/faker/default/internet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Internet < Base
].each(&:freeze).freeze

class << self
extend Gem::Deprecate

##
# Returns the email address
#
Expand Down Expand Up @@ -50,42 +48,6 @@ def email(name: nil, separators: nil, domain: nil)
construct_email(sanitized_local_part, generate_domain)
end

##
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove extend Gem::Deprecate from line 18 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx! fix: 68f26b5

# Returns the email address with domain either gmail.com, yahoo.com or hotmail.com
#
# @return [String]
#
# @param name [String]
#
# @example
# Faker::Internet.free_email #=> "samsmith@gmail.com"
# Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com"
def free_email(name: nil)
construct_email(
sanitize_email_local_part(username(specifier: name)),
fetch('internet.free_email')
)
end
deprecate :free_email, :email, 2023, 10

##
# Returns the email address with fixed domain name as 'example'
#
# @return [String]
#
# @param name [String]
#
# @example
# Faker::Internet.safe_email #=> "samsmith@example.com"
# Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net"
def safe_email(name: nil)
construct_email(
sanitize_email_local_part(username(specifier: name)),
"example.#{sample(%w[org com net])}"
)
end
deprecate :safe_email, :email, 2023, 10

##
# Returns the username
#
Expand Down
1 change: 0 additions & 1 deletion lib/locales/bg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ bg:
default_country: [България]
default_country_code: ["BG"]
internet:
free_email: [abv.bg, mail.bg, dir.bg, gmail.com, yahoo.com, hotmail.com]
domain_suffix: [com, bg, info, бг, net, org]

name:
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/de-AT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,6 @@ de-AT:
- "#{Name.last_name}-#{Name.last_name}"
- "#{Name.last_name}, #{Name.last_name} und #{Name.last_name}"
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
domain_suffix:
- com
- info
Expand Down
8 changes: 0 additions & 8 deletions lib/locales/de-CH.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3505,14 +3505,6 @@ de-CH:
- "#{half_wind_azimuth}"
- "#{quarter_wind_azimuth}"
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
- gmx.de
- web.de
- mail.de
- freenet.de
domain_suffix:
- ch
- com
Expand Down
8 changes: 0 additions & 8 deletions lib/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1510,14 +1510,6 @@ de:
- "#{half_wind_azimuth}"
- "#{quarter_wind_azimuth}"
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
- gmx.de
- web.de
- mail.de
- freenet.de
domain_suffix:
- com
- info
Expand Down
1 change: 0 additions & 1 deletion lib/locales/ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ ee:
- "#{suffix} #{Name.last_name}"

internet:
free_email: [gmail.com, yahoo.com, hotmail.com]
domain_suffix: [com, com.ee, ee, net, org]

name:
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/en-CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ en-CA:
default_country_code:
- CA
internet:
free_email:
- gmail.com
- yahoo.ca
- hotmail.com
domain_suffix:
- ca
- com
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/en-IND.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,6 @@ en-IND:
default_country_code:
- IN
internet:
free_email:
- gmail.com
- yahoo.co.in
- hotmail.com
domain_suffix:
- in
- com
Expand Down
5 changes: 0 additions & 5 deletions lib/locales/en-NEP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ en-NEP:
default_country:
- Nepal
internet:
free_email:
- worldlink.com.np
- gmail.com
- yahoo.com
- hotmail.com
domain_suffix:
- np
- com
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/en-PAK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ en-PAK:
default_country_code:
- PK
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
domain_suffix:
- pk
- com
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/en/internet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ en:
safe_domain_suffix:
- example
- test
free_email:
- gmail.com
- yahoo.com
- hotmail.com
slug:
- report
- appointment
Expand Down
1 change: 0 additions & 1 deletion lib/locales/es-MX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ es-MX:
- "#{University.prefix} #{Address.state} #{University.suffix}"

internet:
free_email: [gmail.com, yahoo.com, hotmail.com, prodigy.net.mx]
domain_suffix: [com, com.mx, mx, info, me, org, org.mx]

name:
Expand Down
1 change: 0 additions & 1 deletion lib/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ es:


internet:
free_email: [gmail.com, yahoo.com, hotmail.com]
domain_suffix: [com, es, info, com.es, org]

name:
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/fr-CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ fr-CA:
default_country_code:
- CA
internet:
free_email:
- gmail.com
- yahoo.ca
- hotmail.com
domain_suffix:
- ca
- com
Expand Down
1 change: 0 additions & 1 deletion lib/locales/fr-CH.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ fr-CH:
- ["synergies", "web-readiness", "paradigms", "markets", "partnerships", "infrastructures", "platforms", "initiatives", "channels", "eyeballs", "communities", "ROI", "solutions", "e-tailers", "e-services", "action-items", "portals", "niches", "technologies", "content", "vortals", "supply-chains", "convergence", "relationships", "architectures", "interfaces", "e-markets", "e-commerce", "systems", "bandwidth", "infomediaries", "models", "mindshare", "deliverables", "users", "schemas", "networks", "applications", "metrics", "e-business", "functionalities", "experiences", "web services", "methodologies"]

internet:
free_email: [gmail.com, yahoo.ch, hotmail.ch]
domain_suffix: [com, net, biz, ch, li, at, ch, ch]

lorem:
Expand Down
1 change: 0 additions & 1 deletion lib/locales/fr/internet.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
fr:
faker:
internet:
free_email: [gmail.com, yahoo.fr, hotmail.fr]
domain_suffix: [com, fr, eu, info, name, net, org, immo, paris, alsace, bzh]
8 changes: 0 additions & 8 deletions lib/locales/hy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2290,14 +2290,6 @@ hy:
- սանտիլիտր
- լիտր
internet:
free_email:
- freenet.am
- namag.net
- yandex.ru
- mail.ru
- gmail.com
- yahoo.com
- hotmail.com
domain_suffix:
- am
- com
Expand Down
7 changes: 0 additions & 7 deletions lib/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -845,13 +845,6 @@ it:
- "#{Name.last_name}-#{Name.last_name} #{suffix}"
- "#{Name.last_name}, #{Name.last_name} e #{Name.last_name} #{suffix}"
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
- email.it
- libero.it
- yahoo.it
domain_suffix:
- com
- com
Expand Down
1 change: 0 additions & 1 deletion lib/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ ko:
binary_types: ['여성', '남성']

internet:
free_email: [gmail.com, yahoo.co.kr, hanmail.net, naver.com]
domain_suffix: [co.kr, com, biz, info, ne.kr, net, or.kr, org]

lorem:
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/lt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ lt:
- VŠĮ
- MB
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
domain_suffix:
- lt
- com
Expand Down
1 change: 0 additions & 1 deletion lib/locales/lv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ lv:
- "#{suffix} #{Name.last_name}"

internet:
free_email: [gmail.com, yahoo.com, hotmail.com]
domain_suffix: [com, lv, net, org]

name:
Expand Down
1 change: 0 additions & 1 deletion lib/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ nl:
suffix: [BV, V.O.F., Group, en Zonen]

internet:
free_email: [gmail.com, yahoo.com, hotmail.nl, live.nl, outlook.com, kpnmail.nl]
domain_suffix: [nl, com, net, org]

lorem:
Expand Down
1 change: 0 additions & 1 deletion lib/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pl:
- "#{Name.last_name}, #{Name.last_name} and #{Name.last_name}"

internet:
free_email: [gmail.com, yahoo.com, hotmail.com, wp.pl, onet.pl, interia.pl]
domain_suffix: [com, pl, com.pl, net, org]

lorem:
Expand Down
6 changes: 0 additions & 6 deletions lib/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5737,12 +5737,6 @@ pt-BR:
- "#{University.prefix} #{Name.last_name} #{University.suffix}"
- "#{University.prefix} #{Name.last_name}"
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
- live.com
- bol.com.br
domain_suffix:
- br
- com
Expand Down
6 changes: 0 additions & 6 deletions lib/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,6 @@ pt:
- "#{Name.last_name}-#{Name.last_name}"
- "#{Name.last_name}, #{Name.last_name} e #{Name.last_name}"
internet:
free_email:
- gmail.com
- yahoo.com
- hotmail.com
- live.com
- bol.com.br
domain_suffix:
- pt
- com
Expand Down
7 changes: 0 additions & 7 deletions lib/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,6 @@ ru:
- "#{postcode} #{default_country}, #{city}, #{street_address}"
- "#{postcode} #{default_country}, #{city}, #{street_address} #{secondary_address}"
internet:
free_email:
- yandex.ru
- ya.ru
- mail.ru
- gmail.com
- yahoo.com
- hotmail.com
domain_suffix:
- com
- ru
Expand Down
4 changes: 0 additions & 4 deletions lib/locales/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2322,10 +2322,6 @@ sk:
- "#{Name.last_name} #{suffix}"
- "#{Name.man_last_name} a #{Name.man_last_name} #{suffix}"
internet:
free_email:
- gmail.com
- zoznam.sk
- azet.sk
domain_suffix:
- sk
- com
Expand Down
2 changes: 0 additions & 2 deletions lib/locales/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ tr:
- "#{first_name} #{last_name} #{last_name}"

internet:
free_email: [gmail.com, hotmail.com.tr, yandex.com.tr]
domain_suffix: [co, com, com.tr, net, org]
safe_email: ['mesela.com']

phone_number:
formats: ["90-###-###-####", "90.###.###.####", "90 ### ### ####", "90##########"]
Expand Down
8 changes: 0 additions & 8 deletions lib/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,6 @@ uk:
default_country_code:
- UA
internet:
free_email:
- ukr.net
- ex.ua
- e-mail.ua
- i.ua
- meta.ua
- yandex.ua
- gmail.com
domain_suffix:
- cherkassy.ua
- cherkasy.ua
Expand Down
Loading