Module: FFaker::InternetSE
Constant Summary
collapse
- BYTE =
Array('0'..'255').freeze
- HOSTS =
%w[gmail.com yahoo.com hotmail.com spray.se passagen.se].freeze
- DOMAIN_SUFFIXES =
%w[se nu com].freeze
- DISPOSABLE_HOSTS =
%w[
mailinator.com suremail.info spamherelots.com binkmail.com safetymail.info
].freeze
- SLUG_DELIMITERS =
%w[- _ .].freeze
Constants included
from Internet
FFaker::Internet::MAC_LIMIT, FFaker::Internet::SAFE_DOMAIN_SUFFIXES
Instance Method Summary
collapse
const_missing, k, luhn_check, underscore, unique
#fetch_sample, #rand, #shuffle
Methods included from Internet
#mac, #password, #safe_email
Instance Method Details
#company_name_single_word ⇒ Object
82
83
84
|
# File 'lib/ffaker/internet_se.rb', line 82
def company_name_single_word
CompanySE.name.split(' ').first
end
|
#disposable_email(name = nil) ⇒ Object
Returns an email address of an online disposable email service (like tempinbox.com). you can really send an email to these addresses an access it by going to the service web pages.
25
26
27
|
# File 'lib/ffaker/internet_se.rb', line 25
def disposable_email(name = nil)
"#{user_name(name)}@#{fetch_sample(DISPOSABLE_HOSTS)}"
end
|
#domain_name ⇒ Object
71
72
73
|
# File 'lib/ffaker/internet_se.rb', line 71
def domain_name
"#{domain_word}.#{domain_suffix}"
end
|
#domain_suffix ⇒ Object
86
87
88
|
# File 'lib/ffaker/internet_se.rb', line 86
def domain_suffix
fetch_sample(DOMAIN_SUFFIXES)
end
|
#domain_word ⇒ Object
75
76
77
78
79
80
|
# File 'lib/ffaker/internet_se.rb', line 75
def domain_word
company_name_single_word.tap do |dw|
dw.gsub!(/\W/, '')
dw.downcase!
end
end
|
#email(name = nil) ⇒ Object
18
19
20
|
# File 'lib/ffaker/internet_se.rb', line 18
def email(name = nil)
+"#{user_name(name)}@#{domain_name}"
end
|
#free_email(name = nil) ⇒ Object
29
30
31
|
# File 'lib/ffaker/internet_se.rb', line 29
def free_email(name = nil)
"#{user_name(name)}@#{fetch_sample(HOSTS)}"
end
|
#http_url ⇒ Object
94
95
96
|
# File 'lib/ffaker/internet_se.rb', line 94
def http_url
uri('http')
end
|
#ip_v4_address ⇒ Object
98
99
100
|
# File 'lib/ffaker/internet_se.rb', line 98
def ip_v4_address
(1..4).map { fetch_sample(BYTE) }.join('.')
end
|
#join_to_user_name(array_parts) ⇒ Object
66
67
68
69
|
# File 'lib/ffaker/internet_se.rb', line 66
def join_to_user_name(array_parts)
join_char = fetch_sample(%w[. _])
array_parts.map(&:downcase).join(join_char)
end
|
#login_user_name ⇒ Object
Used to fake login names were dot is not allowed
34
35
36
|
# File 'lib/ffaker/internet_se.rb', line 34
def login_user_name
user_name.tr('.', '')
end
|
#slug(words = nil, glue = nil) ⇒ Object
102
103
104
105
106
|
# File 'lib/ffaker/internet_se.rb', line 102
def slug(words = nil, glue = nil)
glue ||= fetch_sample(SLUG_DELIMITERS)
(words || FFaker::Lorem.words(2).join(' ')).gsub(' ', glue).downcase
end
|
#uri(protocol) ⇒ Object
90
91
92
|
# File 'lib/ffaker/internet_se.rb', line 90
def uri(protocol)
"#{protocol}://#{domain_name}"
end
|
#user_name(name = nil) ⇒ Object
Mostly used for email creation
39
40
41
42
43
|
# File 'lib/ffaker/internet_se.rb', line 39
def user_name(name = nil)
return user_name_from_name(name) if name
user_name_random
end
|
#user_name_from_name(name) ⇒ Object
61
62
63
64
|
# File 'lib/ffaker/internet_se.rb', line 61
def user_name_from_name(name)
array_parts = shuffle(name.scan(/\w+/))
join_to_user_name(array_parts)
end
|
#user_name_random ⇒ Object
45
46
47
|
# File 'lib/ffaker/internet_se.rb', line 45
def user_name_random
rand(0..1).zero? ? user_name_variant_short : user_name_variant_long
end
|
#user_name_variant_long ⇒ Object
49
50
51
52
53
|
# File 'lib/ffaker/internet_se.rb', line 49
def user_name_variant_long
array_parts = [NameSE.first_name, NameSE.last_name]
array_parts.map! { |word| word.gsub(/\W/, '') }
join_to_user_name(array_parts)
end
|
#user_name_variant_short ⇒ Object
55
56
57
58
59
|
# File 'lib/ffaker/internet_se.rb', line 55
def user_name_variant_short
array_parts = [NameSE.first_name]
array_parts.map! { |word| word.gsub(/\W/, '') }
join_to_user_name(array_parts)
end
|