Created
October 23, 2010 09:18
-
-
Save maricris-sn/641988 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
## Controller for Blackbook fix [ruby] | |
if (request.post?) or (!params["contact_type"].nil?) | |
#get contacts | |
@contacts = [] | |
@type = params["contact_type"] | |
if ["gmail", "yahoo", "hotmail", "aol"].include?(params["contact_type"]) | |
begin | |
username = "#{params["username"]}@#{params["contact_type"]}.com" | |
pass = "#{params["password"]}" | |
@bl = Blackbook.get(:username => username, :password => pass) | |
@bl.each do |item| | |
unless item.blank? | |
if params["contact_type"].eql?("hotmail") | |
if item[:email].blank? and !item[:name][/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/].nil? | |
item[:email] = item[:name] | |
item[:name] = "" | |
end | |
end | |
@clean_email = item[:email][/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/] | |
@contacts << [item[:name], @clean_email] unless @clean_email.blank? | |
end | |
end | |
@contacts = process_contacts unless @contacts.blank? | |
flash[:warning] = nil unless flash[:warning].nil? | |
#do something | |
rescue Exception => ex | |
flash[:warning] = ex | |
#do something | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment