gravy 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -0
- data/lib/gravy/avatar.rb +12 -2
- data/lib/gravy/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -14,4 +14,10 @@ In your Rails app:
|
|
14
14
|
|
15
15
|
This will return the image url for the gravatar associated with that email address.
|
16
16
|
|
17
|
+
## Options
|
17
18
|
|
19
|
+
Gravy will accept any options that gravatar understands, for example size or default:
|
20
|
+
|
21
|
+
`Gravy::Avatar("foo@bar.com", :size => 48, :default => "retro")`
|
22
|
+
|
23
|
+
Gravy will in fact accept _any_ options, so take care to not inject any faulty data into it.
|
data/lib/gravy/avatar.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
module Gravy
|
2
2
|
|
3
|
-
def Avatar(email)
|
3
|
+
def Avatar(email, options = {})
|
4
4
|
gravatar_id = Digest::MD5.hexdigest(email.downcase)
|
5
|
-
"http://gravatar.com/avatar/#{gravatar_id}.png"
|
5
|
+
"http://gravatar.com/avatar/#{gravatar_id}.png#{Avatar.create_options(options)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
class Avatar
|
9
|
+
def self.create_options(options)
|
10
|
+
"?".tap do |encoded_options|
|
11
|
+
options.each do |key, value|
|
12
|
+
encoded_options.concat("#{key}=#{value}&")
|
13
|
+
end
|
14
|
+
end.gsub(/\&$/, "").gsub(/^\?$/, "")
|
15
|
+
end
|
6
16
|
end
|
7
17
|
|
8
18
|
module_function :Avatar
|
data/lib/gravy/version.rb
CHANGED