avataree 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,6 @@ h1. Avataree
2
2
 
3
3
  Ruby DSL for Gravatar profile and images.
4
4
 
5
- Can be used in Sinatra, Rails or Standalone.
6
-
7
5
  h2. What is it?
8
6
 
9
7
  Again I'll repeat that it's a "Ruby DSL for "Gravatar":http://en.gravatar.com profile and images."
@@ -25,6 +25,15 @@ require 'digest/md5'
25
25
 
26
26
  module Helper
27
27
 
28
+ class << self
29
+ attr_accessor :secure_url_services, :url_services
30
+ end
31
+
32
+ def self.included(base)
33
+ self.secure_url_services = "https://secure.gravatar.com/"
34
+ self.url_services = "http://www.gravatar.com/"
35
+ end
36
+
28
37
  #makes MD5 hash of given email
29
38
  def make_digest(email)
30
39
  Digest::MD5.hexdigest(email)
@@ -28,7 +28,7 @@ module Avataree
28
28
  include Helper
29
29
 
30
30
  #image path for gravatar if not defined?
31
- IMAGES_PATH = "http://www.gravatar.com/avatar/" unless const_defined?("IMAGES_PATH")
31
+ # IMAGES_PATH = "http://www.gravatar.com/avatar/" unless const_defined?("IMAGES_PATH")
32
32
 
33
33
  #this method returns resulted path to be requested to gravatar. takes all argument as a hash
34
34
  #options:
@@ -51,9 +51,10 @@ module Avataree
51
51
 
52
52
  def gravatar_image_path(email, options = {})
53
53
  email = make_digest(email)
54
+ services_url = (options[:secure] ? Helper.secure_url_services : Helper.url_services) and options.delete(:secure)
54
55
  email<<".#{options[:extension]}" and options.delete(:extension) if options[:extension]
55
56
  params = options.to_param unless options.empty?
56
- resulted_path = IMAGES_PATH.dup << email
57
+ resulted_path = [services_url, "avatar/", email].join("")
57
58
  [resulted_path, params].compact.join("?")
58
59
  end
59
60
  alias_method :gravatar, :gravatar_image_path
@@ -29,11 +29,11 @@ module Avataree
29
29
  module Profile
30
30
 
31
31
  #image path for gravatar if not defined?
32
- PROFILE_PATH = "http://www.gravatar.com/" unless const_defined?("PROFILE_PATH")
32
+ # PROFILE_PATH = "http://www.gravatar.com/" unless const_defined?("PROFILE_PATH")
33
33
 
34
- #this method returns hash full of information provided by Gravatar.
35
- #This hash may contain
36
- #Email address marked up with class=email (only available via JS/client-side parsing due to spam-protection measures)
34
+ # this method returns hash full of information provided by Gravatar.
35
+ # This hash may contain
36
+ # Email address marked up with class=email (only available via JS/client-side parsing due to spam-protection measures)
37
37
  # IM accounts (some values only available via JS/client-side parsing due to spam-protection measures)
38
38
  # Phone numbers
39
39
  # Verified accounts
@@ -41,10 +41,11 @@ module Avataree
41
41
  # Personal Links
42
42
  # Image (main Gravatar)
43
43
  def gravatar_profile(email, options = {})
44
+ services_url = (options[:secure] ? Helper.secure_url_services : Helper.url_services) and options.delete(:secure)
44
45
  email = make_digest(email)
45
46
  email << ".json"
46
47
  params = options.to_param unless options.empty?
47
- resulted_path = PROFILE_PATH.dup << email
48
+ resulted_path = services_url << email
48
49
  path = [resulted_path, params].compact.join("?")
49
50
  begin
50
51
  JSON.parse(open(path).read)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avataree
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bagwan Pankaj (a.k.a modulo9)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-17 00:00:00 +05:30
18
+ date: 2011-01-05 00:00:00 +05:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency