public
Created

vcard_generator.rb

  • Download Gist
vcard_generator.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.