public
Rubygem
Description: Ruby helpers for avatar display
Clone URL: git://github.com/gcnovus/avatar.git
Search Repo:
made sure that :default always came last in GravatarSource so the other 
params are passed to Gravatar, not the default
gcnovus (author)
Tue Apr 01 12:13:16 -0700 2008
commit  5d3689be7b096a2b8d4b42ab26df7fc6235271e2
tree    14a053a256bb790373d95b8bfe1d7d3bb4ee2528
parent  e3a0e1852b93d3a0ea8484982d6874159769467b
...
56
57
58
59
 
 
 
60
61
62
...
65
66
67
68
69
70
71
 
 
 
 
72
73
74
...
56
57
58
 
59
60
61
62
63
64
...
67
68
69
 
 
 
 
70
71
72
73
74
75
76
0
@@ -56,7 +56,9 @@
0
         
0
         returning(self.class.base_url) do |url|
0
           url << Digest::MD5::hexdigest(email).strip
0
- options.each do |k, v|
0
+ # default must be last or the other options will be parameters to that URL, not the Gravatar one
0
+ [:size, :rating, :default].each do |k|
0
+ v = options[k]
0
             next if v.nil?
0
             url << (url.include?('?') ? '&' : '?')
0
             url << "#{k}=#{v}"
0
@@ -65,10 +67,10 @@
0
       end
0
       
0
       # Returns a Hash containing
0
- # * :field - passed through; defaults to <code>self.default_field</code>
0
- # * :default - passed through; defaults to <code>self.default_avatar_url_for(+person+, +options+)</code>
0
- # * :size - :gravatar_size or :size or :s passed through <em>only if a number</em>
0
- # * :rating - :gravatar_rating or :rating or :r passed through <em>only if one of <code>self.class.allowed_ratings</code></em>
0
+ # * :field - value of :gravatar_field; defaults to <code>self.default_field</code>
0
+ # * :default - value of :gravatar_default_url; defaults to <code>self.default_avatar_url_for(+person+, +options+)</code>
0
+ # * :size - value of :gravatar_size or :size or :s passed through <em>only if a number</em>
0
+ # * :rating - value of :gravatar_rating or :rating or :r passed through <em>only if one of <code>self.class.allowed_ratings</code></em>
0
       def parse_options(person, options)
0
         returning({}) do |result|
0
           result[:gravatar_field] = options[:gravatar_field] || default_field
...
71
72
73
 
 
 
 
 
74
...
71
72
73
74
75
76
77
78
79
0
@@ -71,5 +71,10 @@
0
     assert_equal "http://www.gravatar.com/avatar/#{@email_hash}", @source.avatar_url_for(@gary, :r => 'EVIL')
0
   end
0
   
0
+ def test_default_always_at_end
0
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?rating=any&default=http://gonzo.com", @source.avatar_url_for(@gary, :gravatar_rating => :any, :gravatar_default_url => 'http://gonzo.com')
0
+ assert_equal "http://www.gravatar.com/avatar/#{@email_hash}?size=110&default=http://gonzo.com", @source.avatar_url_for(@gary, :gravatar_size => 110, :gravatar_default_url => 'http://gonzo.com')
0
+ end
0
+
0
 end

Comments

    No one has commented yet.