mirror of
https://github.com/askn/faker.git
synced 2023-08-10 21:13:01 +03:00
add separators to Internet.user_name
This commit is contained in:
parent
099dce6fc3
commit
ae08268c78
@ -62,6 +62,7 @@ Faker::Internet.safe_email
|
|||||||
Faker::Internet.safe_email("Nancy")
|
Faker::Internet.safe_email("Nancy")
|
||||||
Faker::Internet.user_name
|
Faker::Internet.user_name
|
||||||
Faker::Internet.user_name("Nancy")
|
Faker::Internet.user_name("Nancy")
|
||||||
|
Faker::Internet.user_name("Nancy Johnson", %w(. _ -))
|
||||||
|
|
||||||
Faker::Internet.domain_name
|
Faker::Internet.domain_name
|
||||||
Faker::Internet.domain_word
|
Faker::Internet.domain_word
|
||||||
|
@ -38,6 +38,7 @@ puts Faker::Internet.safe_email("Nancy")
|
|||||||
|
|
||||||
puts Faker::Internet.user_name
|
puts Faker::Internet.user_name
|
||||||
puts Faker::Internet.user_name("Nancy")
|
puts Faker::Internet.user_name("Nancy")
|
||||||
|
puts Faker::Internet.user_name("Nancy Johnson", %w(. _ -))
|
||||||
|
|
||||||
puts Faker::Internet.domain_name
|
puts Faker::Internet.domain_name
|
||||||
puts Faker::Internet.domain_word
|
puts Faker::Internet.domain_word
|
||||||
|
@ -12,14 +12,14 @@ module Faker
|
|||||||
[user_name(name), "example." + %w(org com net).shuffle.first].join("@")
|
[user_name(name), "example." + %w(org com net).shuffle.first].join("@")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.user_name(name = nil)
|
def self.user_name(name = nil, separators = %w(. _))
|
||||||
return name.scan(/\w+/).shuffle.map(&.[0]).join(%w(. _).sample).downcase if name
|
return name.scan(/\w+/).shuffle.map(&.[0]).join(separators.sample).downcase if name
|
||||||
[
|
[
|
||||||
->{ Name.first_name.gsub(/\W/, "").downcase },
|
->{ Name.first_name.gsub(/\W/, "").downcase },
|
||||||
->{
|
->{
|
||||||
[Name.first_name, Name.last_name].map { |n|
|
[Name.first_name, Name.last_name].map { |n|
|
||||||
n.gsub(/\W/, "")
|
n.gsub(/\W/, "")
|
||||||
}.join(".").downcase
|
}.join(separators.sample).downcase
|
||||||
},
|
},
|
||||||
].sample.call
|
].sample.call
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user