Class: Synthra::Types::TechnologyInternet::Email

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/technology_internet/communication.rb

Overview

Email type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



34
35
36
# File 'lib/synthra/types/technology_internet/communication.rb', line 34

def generate_edge(rng, context, args)
  ["", "a@b", "user@", "@domain", "user@domain"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



38
39
40
# File 'lib/synthra/types/technology_internet/communication.rb', line 38

def generate_invalid(rng, context, args)
  ["notanemail", "@missing.local", "missing@", "double@@at.com", "spaces in@email.com", nil, 123].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ String

Generate a random email address

Uses Faker::Internet to generate realistic email addresses.

Examples:

generate_random(rng, {})
# => "maria.garcia@example.com"

Parameters:

  • rng (Generator::RNG)

    random number generator (not directly used)

  • args (Hash)

    type arguments (not used for basic email)

Returns:

  • (String)

    generated email address



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/synthra/types/technology_internet/communication.rb', line 20

def generate_random(rng, context, args)
  adapter = faker_adapter(context)
  if adapter
    adapter.email

  else
    Faker::Internet.email
  end

rescue StandardError
  "#{rng.sample(['user', 'test', 'admin'])}@#{rng.sample(['example.com', 'test.com', 'demo.com'])}"
end