Skip to content

Instantly share code, notes, and snippets.

@prathamesh-sonpatki
Last active December 14, 2015 03:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prathamesh-sonpatki/5019349 to your computer and use it in GitHub Desktop.
Save prathamesh-sonpatki/5019349 to your computer and use it in GitHub Desktop.
# Fake email id generator for Gmail
# These emails will come to real email id you have provided to this script
require 'csv'
def generate_fake_emails(email, count = 1)
result = []
username, domain = email.split('@')
count.times do |c|
result << "#{username}+#{c+1}@#{domain}"
end
result
end
def create_csv(emails)
CSV.open('email_ids.csv', 'w') do |csv|
csv << ["Email"]
emails.each { |e| csv << [e] }
end
end
puts "Enter real email id"
email = gets
puts "How many fake emails you want?"
count = gets.to_i
fake_emails = generate_fake_emails(email, count)
create_csv(fake_emails)
puts "email_ids.csv generated with #{count} fake email ids"
require_relative './fake_email_generator'
describe "Fake Email Generator" do
it "creates fake email id's from a real email id" do
generate_fake_emails("abc@def.com").should == ["abc+1@def.com"]
generate_fake_emails("abc@def.com", 2).should == ["abc+1@def.com", "abc+2@def.com"]
generate_fake_emails("test@def.com", 0).should == [])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment