Module: Faker::InternetSE

Extended by:
InternetSE, ModuleUtils
Includes:
Internet
Included in:
InternetSE
Defined in:
lib/ffakerer/internet_se.rb

Constant Summary collapse

BYTE =
k((0..255).to_a.map { |n| n.to_s })
HOSTS =
k %w(gmail.com yahoo.com hotmail.com spray.se passagen.se)
DOMAIN_SUFFIXES =
k %w(se nu com)
DISPOSABLE_HOSTS =
k %w(mailinator.com suremail.info spamherelots.com binkmail.com safetymail.info)

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#company_name_single_wordObject



81
82
83
# File 'lib/ffakerer/internet_se.rb', line 81

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.



19
20
21
# File 'lib/ffakerer/internet_se.rb', line 19

def disposable_email(name = nil)
  "#{user_name(name)}@#{DISPOSABLE_HOSTS.rand}"
end

#domain_nameObject



70
71
72
# File 'lib/ffakerer/internet_se.rb', line 70

def domain_name
  "#{domain_word}.#{domain_suffix}"
end

#domain_suffixObject



85
86
87
# File 'lib/ffakerer/internet_se.rb', line 85

def domain_suffix
  DOMAIN_SUFFIXES.rand
end

#domain_wordObject



74
75
76
77
78
79
# File 'lib/ffakerer/internet_se.rb', line 74

def domain_word
  company_name_single_word.tap { |dw|
    dw.gsub!(/\W/, '')
    dw.downcase!
  }
end

#email(name = nil) ⇒ Object



12
13
14
# File 'lib/ffakerer/internet_se.rb', line 12

def email(name = nil)
  "#{user_name(name)}@#{domain_name}"
end

#free_email(name = nil) ⇒ Object



23
24
25
# File 'lib/ffakerer/internet_se.rb', line 23

def free_email(name = nil)
  "#{user_name(name)}@#{HOSTS.rand}"
end

#http_urlObject



93
94
95
# File 'lib/ffakerer/internet_se.rb', line 93

def http_url
  uri("http")
end

#ip_v4_addressObject



97
98
99
# File 'lib/ffakerer/internet_se.rb', line 97

def ip_v4_address
  (1..4).map { BYTE.random_pick(1) }.join(".")
end

#join_to_user_name(array_parts) ⇒ Object



64
65
66
67
68
# File 'lib/ffakerer/internet_se.rb', line 64

def join_to_user_name(array_parts)
  join_char = ArrayUtils.rand(%w(. _))
  array_parts.map!(&:downcase)
  array_parts.join(join_char)
end

#login_user_nameObject

Used to fake login names were dot is not allowed



28
29
30
# File 'lib/ffakerer/internet_se.rb', line 28

def 
  user_name.gsub('.','')
end

#uri(protocol) ⇒ Object



89
90
91
# File 'lib/ffakerer/internet_se.rb', line 89

def uri(protocol)
  "#{protocol}://#{domain_name}"
end

#user_name(name = nil) ⇒ Object

Mostly used for email creation



33
34
35
36
# File 'lib/ffakerer/internet_se.rb', line 33

def user_name(name = nil)
  return user_name_from_name(name) if name
  user_name_random
end

#user_name_from_name(name) ⇒ Object



59
60
61
62
# File 'lib/ffakerer/internet_se.rb', line 59

def user_name_from_name(name)
  array_parts = ArrayUtils.shuffle(name.scan(/\w+/))
  join_to_user_name(array_parts)
end

#user_name_randomObject



38
39
40
41
42
43
44
45
# File 'lib/ffakerer/internet_se.rb', line 38

def user_name_random
  variant = rand(2)
  case variant
  when 0 then user_name_variant_short
  when 1 then user_name_variant_long
  else        user_name_variant_short
  end
end

#user_name_variant_longObject



47
48
49
50
51
# File 'lib/ffakerer/internet_se.rb', line 47

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_shortObject



53
54
55
56
57
# File 'lib/ffakerer/internet_se.rb', line 53

def user_name_variant_short
  array_parts = [ NameSE.first_name ]
  array_parts.map!{ |word| word.gsub(/\W/, '') }
  join_to_user_name(array_parts)
end