gravy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,3 +1,3 @@
1
1
  module Gravy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Oemuer Oezkir