Skip to content
Create a gist now

Instantly share code, notes, and snippets.

vcard_generator.rb
require 'rubygems'
require 'vpim'
require 'faker'
Faker::Config.locale = 'en-gb'
File.open('contacts.vcf', 'w') do |file|
1000.times do
fakename = [Faker::Name.last_name, Faker::Name.first_name]
card = Vpim::Vcard::Maker.make2 do |vcard|
vcard.name { |name|
name.family = fakename[0]
name.given = fakename[1]
}
vcard.add_email(Faker::Internet.email(fakename[1])) { |email|
email.preferred = true
}
vcard.add_tel(Faker::Base.numerify('01### ### ###')) { |tel|
tel.location = %w(work)
tel.preferred = true
}
vcard.add_tel(Faker::Base.numerify('078## ### ###')) { |tel|
tel.location = %w(work cell)
}
vcard.add_addr { |address|
address.street = Faker::Address.street_address
address.locality = Faker::Address.city
address.country = Faker::Address.uk_country
address.postalcode = Faker::Address.uk_postcode
}
vcard.org = Faker::Company.name
end
file.write(card)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.