Last active
December 14, 2015 03:09
-
-
Save prathamesh-sonpatki/5019349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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