Last active
June 29, 2022 12:25
-
-
Save matthutchinson/823e0584d2c7475ae41819b1b14fb354 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require "faker" | |
num_vcards = ARGV[0].to_i || 1 | |
def random_vcard | |
fname = Faker::Name.first_name | |
lname = Faker::Name.last_name | |
<<~VCARD | |
BEGIN:VCARD | |
VERSION:3.0 | |
N:#{lname};#{fname};;; | |
FN:#{fname} #{lname} | |
ORG:#{Faker::Company.name}; | |
TITLE:#{Faker::Superhero.name} | |
EMAIL;type=INTERNET;type=WORK;type=pref:#{Faker::Internet.email} | |
TEL;type=WORK;type=pref:+1 617 555 1212 | |
TEL;type=WORK:+1 (617) 555-1234 | |
TEL;type=CELL:+1 781 555 1212 | |
TEL;type=HOME:+1 202 555 1212 | |
item1.ADR;type=WORK:;;2 Enterprise Avenue;Worktown;NY;01111;USA | |
item1.X-ABADR:us | |
item2.ADR;type=HOME;type=pref:;;3 Acacia Avenue;Hometown;MA;02222;USA | |
item2.X-ABADR:us | |
NOTE:#{Faker::TvShows::Seinfeld.quote} | |
item3.URL;type=pref:http\://#{Faker::Internet.domain_name} | |
item3.X-ABLabel:_$!<HomePage>!$_ | |
item4.URL:http\://#{Faker::Internet.domain_name} | |
item4.X-ABLabel:FOAF | |
CATEGORIES:Work,Test group | |
X-ABUID:5AD380FD-B2DE-4261-BA99-DE1D1DB52FBE\:ABPerson | |
END:VCARD | |
VCARD | |
end | |
File.open("vcards-#{num_vcards}.vcf", "w") do |vcard_file| | |
1.upto(num_vcards) do | |
vcard_file << random_vcard | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment