Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This example code might help your users get up and running #35

Open
rugyoga opened this issue Jul 28, 2011 · 0 comments
Open

This example code might help your users get up and running #35

rugyoga opened this issue Jul 28, 2011 · 0 comments

Comments

@rugyoga
Copy link

rugyoga commented Jul 28, 2011

require 'gdata'
require 'contacts'

service, login, password = ARGV[0], ARGV[1], ARGV[2]
accepted = %w(aol gmail hotmail plaxo yahoo)
if accepted.include? service
  mapped = Contacts.new(service, login, password).contacts.inject( {} ){ |xs, x| (xs[x[0]] ||= []) << x[1] unless x[1].nil?; xs}.to_a.map{ |name, emails| [name.downcase, emails.uniq.sort]}.sort
  print mapped.map{ |name, emails| "#{name}: #{emails.join(',')}" }.join( "\n" ) + "\n"
else
  print "Sorry I don't know how to access '#{service}'. It has to be one of: #{accepted.join(', ')}\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant