Module: FFaker::InternetSE

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

Constant Summary collapse

BYTE =
[*'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

Methods included from ModuleUtils

const_missing, k, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Methods included from Internet

#mac, #password, #safe_email

Instance Method Details

#company_name_single_wordObject


84
85
86
# File 'lib/ffaker/internet_se.rb', line 84

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_nameObject


73
74
75
# File 'lib/ffaker/internet_se.rb', line 73

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

#domain_suffixObject


88
89
90
# File 'lib/ffaker/internet_se.rb', line 88

def domain_suffix
  fetch_sample(DOMAIN_SUFFIXES)
end

#domain_wordObject


77
78
79
80
81
82
# File 'lib/ffaker/internet_se.rb', line 77

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_urlObject


96
97
98
# File 'lib/ffaker/internet_se.rb', line 96

def http_url
  uri('http')
end

#ip_v4_addressObject


100
101
102
# File 'lib/ffaker/internet_se.rb', line 100

def ip_v4_address
  (1..4).map { fetch_sample(BYTE) }.join('.')
end

#join_to_user_name(array_parts) ⇒ Object


68
69
70
71
# File 'lib/ffaker/internet_se.rb', line 68

def join_to_user_name(array_parts)
  join_char = fetch_sample(%w[. _])
  array_parts.map(&:downcase).join(join_char)
end

#login_user_nameObject

Used to fake login names were dot is not allowed


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

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

#slug(words = nil, glue = nil) ⇒ Object


104
105
106
107
108
# File 'lib/ffaker/internet_se.rb', line 104

def slug(words = nil, glue = nil)
  glue ||= fetch_sample(SLUG_DELIMITERS)

  (words || FFaker::Lorem.words(2).join(' ')).gsub(' ', glue).downcase
end

#uri(protocol) ⇒ Object


92
93
94
# File 'lib/ffaker/internet_se.rb', line 92

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

#user_name(name = nil) ⇒ Object

Mostly used for email creation


39
40
41
42
# 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


63
64
65
66
# File 'lib/ffaker/internet_se.rb', line 63

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

#user_name_randomObject


44
45
46
47
48
49
# File 'lib/ffaker/internet_se.rb', line 44

def user_name_random
  case rand(0..1)
  when 0 then user_name_variant_short
  when 1 then user_name_variant_long
  end
end

#user_name_variant_longObject


51
52
53
54
55
# File 'lib/ffaker/internet_se.rb', line 51

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


57
58
59
60
61
# File 'lib/ffaker/internet_se.rb', line 57

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