module FFaker::InternetSE

Constants

BYTE
DISPOSABLE_HOSTS
DOMAIN_SUFFIXES
HOSTS
SLUG_DELIMITERS

Public Instance Methods

company_name_single_word() click to toggle source
# File lib/ffaker/internet_se.rb, line 82
def company_name_single_word
  CompanySE.name.split(' ').first
end
disposable_email(name = nil) click to toggle source

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.

# File lib/ffaker/internet_se.rb, line 25
def disposable_email(name = nil)
  "#{user_name(name)}@#{fetch_sample(DISPOSABLE_HOSTS)}"
end
domain_name() click to toggle source
# File lib/ffaker/internet_se.rb, line 71
def domain_name
  "#{domain_word}.#{domain_suffix}"
end
domain_suffix() click to toggle source
# File lib/ffaker/internet_se.rb, line 86
def domain_suffix
  fetch_sample(DOMAIN_SUFFIXES)
end
domain_word() click to toggle source
# 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) click to toggle source
# File lib/ffaker/internet_se.rb, line 18
def email(name = nil)
  +"#{user_name(name)}@#{domain_name}"
end
free_email(name = nil) click to toggle source
# File lib/ffaker/internet_se.rb, line 29
def free_email(name = nil)
  "#{user_name(name)}@#{fetch_sample(HOSTS)}"
end
http_url() click to toggle source
# File lib/ffaker/internet_se.rb, line 94
def http_url
  uri('http')
end
ip_v4_address() click to toggle source
# 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) click to toggle source
# 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() click to toggle source

Used to fake login names were dot is not allowed

# File lib/ffaker/internet_se.rb, line 34
def login_user_name
  user_name.tr('.', '')
end
slug(words = nil, glue = nil) click to toggle source
# 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) click to toggle source
# File lib/ffaker/internet_se.rb, line 90
def uri(protocol)
  "#{protocol}://#{domain_name}"
end
user_name(name = nil) click to toggle source

Mostly used for email creation

# 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) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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