Module: Faker::Internet
Constant Summary
collapse
- BYTE =
k((0..255).to_a.map { |n| n.to_s })
- HOSTS =
k %w(gmail.com yahoo.com hotmail.com)
- DISPOSABLE_HOSTS =
k %w(mailinator.com suremail.info spamherelots.com binkmail.com safetymail.info)
- DOMAIN_SUFFIXES =
k %w(co.uk com us ca biz info name)
Instance Method Summary
collapse
const_missing, k, underscore
Instance Method Details
#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.
14
15
16
|
# File 'lib/ffakerer/internet.rb', line 14
def disposable_email(name = nil)
[ user_name(name), DISPOSABLE_HOSTS.rand ].join('@')
end
|
#domain_name ⇒ Object
40
41
42
|
# File 'lib/ffakerer/internet.rb', line 40
def domain_name
"#{domain_word}.#{domain_suffix}"
end
|
#domain_suffix ⇒ Object
51
52
53
|
# File 'lib/ffakerer/internet.rb', line 51
def domain_suffix
DOMAIN_SUFFIXES.rand
end
|
#domain_word ⇒ Object
44
45
46
47
48
49
|
# File 'lib/ffakerer/internet.rb', line 44
def domain_word
dw = Company.name.split(' ').first
dw.gsub!(/\W/, '')
dw.downcase!
dw
end
|
#email(name = nil) ⇒ Object
8
9
10
|
# File 'lib/ffakerer/internet.rb', line 8
def email(name = nil)
[ user_name(name), domain_name ].join('@')
end
|
#free_email(name = nil) ⇒ Object
18
19
20
|
# File 'lib/ffakerer/internet.rb', line 18
def free_email(name = nil)
"#{user_name(name)}@#{HOSTS.rand}"
end
|
#http_url ⇒ Object
59
60
61
|
# File 'lib/ffakerer/internet.rb', line 59
def http_url
uri("http")
end
|
#ip_v4_address ⇒ Object
63
64
65
|
# File 'lib/ffakerer/internet.rb', line 63
def ip_v4_address
(1..4).map { BYTE.random_pick(1) }.join(".")
end
|
#uri(protocol) ⇒ Object
55
56
57
|
# File 'lib/ffakerer/internet.rb', line 55
def uri(protocol)
"#{protocol}://#{domain_name}"
end
|
#user_name(name = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ffakerer/internet.rb', line 22
def user_name(name = nil)
if name
parts = ArrayUtils.shuffle(name.scan(/\w+/)).join(ArrayUtils.rand(%w(. _)))
parts.downcase!
parts
else
case rand(2)
when 0
Name.first_name.gsub(/\W/, '').downcase
when 1
parts = [ Name.first_name, Name.last_name ].each {|n| n.gsub!(/\W/, '') }
parts = parts.join ArrayUtils.rand(%w(. _))
parts.downcase!
parts
end
end
end
|