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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rb-gravatar.rb +15 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcb0e63e5a5a04ed175a48ec484c08ecfc3a531c
4
- data.tar.gz: ae85365e36a0a80c288dc95c58b484e14244a6d3
3
+ metadata.gz: 30f2d29385a6a31d0201c5dfc8d85cf11ff555b1
4
+ data.tar.gz: 5df574546c7fbcb1de066f8e6603fd54b2750bd5
5
5
  SHA512:
6
- metadata.gz: cb461919203d60462e5c15e8a72a36930c020a44c85f35df6bb402cab00e0fc772893784a4187b2af12f9965bb624e72884a40f5d7bff1995505087762104b48
7
- data.tar.gz: 378a3881e5c18be9fccf82546dd5a43b9abb1b78ea2b103015b10a61b83529c1c7106f773f34c6f94c706e8b8f3b6ee86f6e91ea496765ed7366592eb3c44f88
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
- Gravatar.construct_resource(email_address, size, default)
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
- return "<img src='#{Gravatar.construct_resource(email_address, size, default)}' />" if alt_text.nil?
27
- return "<img src='#{Gravatar.construct_resource(email_address, size, default)}' alt='#{alt_text}' />" if !alt_text.nil?
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.2
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.0.5
40
+ rubygems_version: 2.1.9
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: rb-gravatar