rb-gravatar 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rb-gravatar.rb +29 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dcb0e63e5a5a04ed175a48ec484c08ecfc3a531c
|
4
|
+
data.tar.gz: ae85365e36a0a80c288dc95c58b484e14244a6d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb461919203d60462e5c15e8a72a36930c020a44c85f35df6bb402cab00e0fc772893784a4187b2af12f9965bb624e72884a40f5d7bff1995505087762104b48
|
7
|
+
data.tar.gz: 378a3881e5c18be9fccf82546dd5a43b9abb1b78ea2b103015b10a61b83529c1c7106f773f34c6f94c706e8b8f3b6ee86f6e91ea496765ed7366592eb3c44f88
|
data/lib/rb-gravatar.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
class Gravatar
|
5
|
+
def self.construct_resource(email_address, size, default)
|
6
|
+
if size < 1 || size > 2048
|
7
|
+
size = 64
|
8
|
+
end
|
9
|
+
parts = []
|
10
|
+
parts << "http://www.gravatar.com/avatar/"
|
11
|
+
parts << "#{Digest::MD5.hexdigest(email_address.downcase.strip)}"
|
12
|
+
parts << "?s=#{size}"
|
13
|
+
|
14
|
+
if !default.nil?
|
15
|
+
parts << "&d=#{CGI.escape(default)}"
|
16
|
+
end
|
17
|
+
|
18
|
+
parts.join
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.src(email_address, size = 64, default = nil)
|
22
|
+
Gravatar.construct_resource(email_address, size, default)
|
23
|
+
end
|
24
|
+
|
25
|
+
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?
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rb-gravatar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean Nieuwoudt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple up to date gem for creating Gravatar image URL's and tags
|
14
|
+
email: sean@wixelhq.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/rb-gravatar.rb
|
20
|
+
homepage: http://github.com/Wixel/ruby-gravatar
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.5
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: rb-gravatar
|
44
|
+
test_files: []
|