Module: Avataree::ProfileServices

Defined in:
lib/avataree/profile.rb

Instance Method Summary collapse

Instance Method Details

#gravatar_profile(email, options = {}) ⇒ Object

options: secure takes boolean values to use https or not :default => false this method returns hash full of information provided by Gravatar. This hash may contain Email address marked up with class=email (only available via JS/client-side parsing due to spam-protection measures) IM accounts (some values only available via JS/client-side parsing due to spam-protection measures) Phone numbers Verified accounts Name Personal Links Image (main Gravatar)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/avataree/profile.rb', line 42

def gravatar_profile(email, options = {})
  services_url = (options[:secure] ? Helper.secure_url_services : Helper.url_services) and options.delete(:secure)
  email = make_digest(email)
  email << ".json"
  params = options.to_param unless options.empty?
  resulted_path = [services_url, email].join
  path = [resulted_path, params].compact.join("?")
  begin
    JSON.parse(open(path).read)
  rescue => e
    {"error" => "unable to parse", "description" => "either no such user is found on gravatar using
       provided email or some server side error. do check it out.", "errorTrace" => "#{e}"}
  end
end