rb-gravatar 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rb-gravatar.rb +15 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f2d29385a6a31d0201c5dfc8d85cf11ff555b1
|
4
|
+
data.tar.gz: 5df574546c7fbcb1de066f8e6603fd54b2750bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00bcd20e14453c33de388ce3b1774be6e1f901cceb271155a70907a265ea284744dacd1b09cebdf75b3c0ec797820d2eb962dfed220c39ebb980f71cf5aed42e
|
7
|
+
data.tar.gz: 621518390532b89000310c7da02c1a25fef0015cf6ac46565689d6c3e9717014e37daeeb640718b3eaaa14d095f0e22eb0ad44877493748444e0d4dfaaf13ff9
|
data/lib/rb-gravatar.rb
CHANGED
@@ -2,10 +2,12 @@ require 'digest/md5'
|
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
class Gravatar
|
5
|
+
# Construct the Gravatar URI generically
|
5
6
|
def self.construct_resource(email_address, size, default)
|
6
7
|
if size < 1 || size > 2048
|
7
8
|
size = 64
|
8
9
|
end
|
10
|
+
|
9
11
|
parts = []
|
10
12
|
parts << "http://www.gravatar.com/avatar/"
|
11
13
|
parts << "#{Digest::MD5.hexdigest(email_address.downcase.strip)}"
|
@@ -18,12 +20,22 @@ class Gravatar
|
|
18
20
|
parts.join
|
19
21
|
end
|
20
22
|
|
23
|
+
# Generate and return only the Gravatar URI
|
21
24
|
def self.src(email_address, size = 64, default = nil)
|
22
|
-
|
25
|
+
begin
|
26
|
+
Gravatar.construct_resource(email_address, size, default)
|
27
|
+
rescue Exception => e
|
28
|
+
nil
|
29
|
+
end
|
23
30
|
end
|
24
31
|
|
32
|
+
# Generate and return the full img tag for the Gravatar URI
|
25
33
|
def self.tag(email_address, size = 64, default = nil, alt_text = nil)
|
26
|
-
|
27
|
-
|
34
|
+
begin
|
35
|
+
return "<img src='#{Gravatar.construct_resource(email_address, size, default)}' class='gravatar' />" if alt_text.nil?
|
36
|
+
return "<img src='#{Gravatar.construct_resource(email_address, size, default)}' class='gravatar' alt='#{alt_text}' />" if !alt_text.nil?
|
37
|
+
rescue Exception => e
|
38
|
+
nil
|
39
|
+
end
|
28
40
|
end
|
29
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-gravatar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Nieuwoudt
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
40
|
+
rubygems_version: 2.1.9
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: rb-gravatar
|