avataree 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +0 -2
- data/lib/avataree/helper.rb +9 -0
- data/lib/avataree/image.rb +3 -2
- data/lib/avataree/profile.rb +6 -5
- metadata +4 -4
data/README.textile
CHANGED
data/lib/avataree/helper.rb
CHANGED
@@ -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)
|
data/lib/avataree/image.rb
CHANGED
@@ -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 =
|
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
|
data/lib/avataree/profile.rb
CHANGED
@@ -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 =
|
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 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:
|
18
|
+
date: 2011-01-05 00:00:00 +05:30
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|