Permalink
Browse files

Prepairing for prerelease of 1.0.0.pre1

  • Loading branch information...
1 parent 7d6c62d commit c3141659bf9c0a20b515b85bcee313855ad7acbe @mdeering committed Jul 11, 2010
Showing with 75 additions and 68 deletions.
  1. +4 −4 MIT-LICENSE
  2. +34 −45 README.textile
  3. +16 −2 ROADMAP.textile
  4. +1 −1 Rakefile
  5. +1 −1 VERSION
  6. +5 −5 gravatar_image_tag.gemspec
  7. +7 −8 lib/gravatar_image_tag.rb
  8. +7 −2 spec/gravatar_image_tag_spec.rb
View
@@ -1,16 +1,16 @@
-Copyright (c) 2009 Michael Deering
-
+Copyright (c) 2010 Michael Deering
+
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
-
+
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
View
@@ -6,26 +6,31 @@ Rails view helper for grabbing "Gravatar":http://en.gravatar.com/ images. The g
h2. Install as a Ruby Gem
-<pre>sudo gem install gravatar_image_tag</pre>
+h3. Rails 2
p. Include the following line in your Rails environment
-<pre>config.gem 'gravatar_image_tag'</pre>
+<pre># config/environment
+ config.gem 'gravatar_image_tag'</pre>
-p. Then ensure the gem is installed if you did not already run the gem install as noted above.
+p. Then ensure the gem is installed by running the following rake task from the your application root.
<pre>rake gems:install</pre>
-h2. Install as a Ruby on Rails Plugin
+h3. Rails 3
-The traditional way.
-<pre>./script/plugin install git://github.com/mdeering/gravatar_image_tag.git</pre>
+p. Include the following line in your Rails environment
-or the old-school but still c00l way!
-<pre>piston import git://github.com/mdeering/gravatar_image_tag.git vendor/plugins/gravatar_image_tag</pre>
+<pre># Gemfile
+ gem 'gravatar_image_tag'</pre>
-or for all you hip gitsters.
-<pre>git submodule add git://github.com/mdeering/gravatar_image_tag.git vendor/plugins/gravatar_image_tag git submodule init</pre>
+p. Then ensure the gem is installed by running the following command from the your application root.
+
+<pre>bundle install</pre>
+
+h2. Install as a Ruby on Rails Plugin
+
+<pre>./script/plugin install git://github.com/mdeering/gravatar_image_tag.git</pre>
h2. Usage
@@ -35,43 +40,40 @@ Once you have installed it as a plugin for your rails app usage is simple.
*Boom* here is my gravatar !http://www.gravatar.com/avatar/4da9ad2bd4a2d1ce3c428e32c423588a(Michael Deering)!
-h2. Configuration Points
-
-h3. Setting the default image
+h2. Configuration
-If no default image is given in either an initializer or through the options passed to the gravatar_image_tag then the default image from the gravatar site will be displayed.
+h3. Global configuration points
-<pre>gravatar_image_tag('junk', :alt => 'Default Gravatar Image')</pre>
+<pre># config/initializers/gravatar_image_tag.rb
+GravatarImageTag.configure do |config|
+ config.default_image = nil # Set this to use your own default gravatar image rather then serving up Gravatar's default image [ 'http://example.com/images/default_gravitar.jpg', :identicon, :monsterid, :wavatar, 404 ].
+ config.filetype = nil # Set this if you require a specific image file format ['gif', 'jpg' or 'png']. Gravatar's default is png
+ config.rating = nil # Set this if you change the rating of the images that will be returned ['G', 'PG', 'R', 'X']. Gravatar's default is G
+ config.size = nil # Set this to globally set the size of the gravatar image returned (1..512). Gravatar's default is 80
+ config.secure = false # Set this to true if you require secure images on your pages.
+end
+</pre>
-*Splat* the default gravatar image !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7(Default Gravatar Image)!
+h3. Setting the default image inline
-You can specify the default image through an initializer as follows:
+p. *Splat* the default gravatar image !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7(Default Gravatar Image)!
-<pre># config/initializers/gravatar_defaults.rb
-ActionView::Base.default_gravatar_image = 'http://assets.yourhost.com/images/default_gravatar.png'</pre>
-
-You can also specify the default image to fallback to or override the one set in the above initializer by passing the _:gravatar => { :default => 'http://assets.yourhost.com/images/override_gravatar.png' }_ option to the gravatar_image_tag call. All other options will be forwarded onto the image_tag.
+p. You can set the default gravatar image inline as follows:
<pre>gravatar_image_tag('junk', :alt => 'Github Default Gravatar', :gravatar => { :default => 'http://github.com/images/gravatars/gravatar-80.png' })</pre>
-*Ka-Pow* !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7?default=http%3A%2F%2Fgithub.com%2Fimages%2Fgravatars%2Fgravatar-80.png(Github Default Gravatar)!
+p. *Ka-Pow* !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7?default=http%3A%2F%2Fgithub.com%2Fimages%2Fgravatars%2Fgravatar-80.png(Github Default Gravatar)!
p. Other options supported besides an image url to fall back on include the following:
+
* :identicon !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7?default=identicon(Identicon Avatar)!
* :monsterid !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7?default=monsterid(Monster Id Avatar)!
* :wavatar !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7?default=wavatar(Wavatar Avatar)!
* 404: !http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7?default=404(Not Found)!
h3. Setting the default image size
-If no default image size is given in either the plugin configuration or through the options passed to the gravatar_image_tag then the default image size from the gravatar site will be displayed (80px x 80px at the time of this writing).
-
-You can specify your default image size through the plugin configuration by adding the following line to your rails environment.
-
-<pre># config/initializers/gravatar_defaults.rb
-ActionView::Base.default_gravatar_size = 120</pre>
-
-You can also specify the image size or override the one set in the plugin configuration by passing the _:gravatar => { :size => 50 }_ option to the gravatar_image_tag call. All other options will be forwarded on to the image_tag call.
+p. You can set the gravatar image size inline as follows:
<pre>gravatar_image_tag('spam@spam.com'.gsub('spam', 'mdeering'), :alt => 'Michael Deering', :class => 'some-class', :gravatar => { :size => 15 })</pre>
@@ -85,32 +87,19 @@ p. You can make a request for a gravatar from the secure server at https://secur
Delivered by a secure url! !https://secure.gravatar.com/avatar/4da9ad2bd4a2d1ce3c428e32c423588a(Michael Deering)!
-p. You globally set the gravatar image tag to always use the secure server by setting the following. By default this is set to false.
-
-<pre># config/initializers/gravatar_defaults.rb
-ActionView::Base.secure_gravatar = true</pre>
-
h3. Using Gravatar's built in rating system
-p. By default only those gravatars that have a rating of 'g' are returned. You can change this by passing in the rating parameter as follows. Possible options for ratings are _g, pg, r, or x_.
+p. You can set the gravatar rating inline as follows:
<pre>gravatar_image_tag('spam@spam.com'.gsub('spam', 'mdeering'), :alt => 'Michael Deering', :gravatar => { :rating => 'pg' } )</pre>
-p. You can globally set the gravatar image tag rating by setting the following. There is no default value, the default of 'g' is being set by the gravatar service itself.
-
-<pre># config/initializers/gravatar_defaults.rb
-ActionView::Base.default_gravatar_rating = 'r'</pre>
h3. Specifying a filetype
-p. By default no filetype extension is given in the produced gravatar urls but of your application requires it you can specify one to be added to the generated url.
+p. You can set the gravatar filetype inline as follows:
<pre>gravatar_image_tag('spam@spam.com'.gsub('spam', 'mdeering'), :alt => 'Michael Deering', :gravatar => { :filetype => :gif } )</pre>
-p. You can globally set the filetype extension as follows.
-
-<pre># config/initializers/gravatar_defaults.rb
-ActionView::Base.default_gravatar_filetype = :gif</pre>
h2. Credits
View
@@ -1,13 +1,27 @@
-h1. 0.2.0
+h1. 1.1.0
-* Add model helpers for ActiveRecord and DataMapper
+* Add model helpers for ActiveRecord/ActiveModel
<pre>class Comment < ActiveRecord::Base
has_gravatar :author, :size => 120
end</pre>
<pre>Comment.first.gravatar_url</pre>
+h1. 1.0.0
+
+* Block Configuration DSL support
+
+<pre># config/initializers/gravatar_image_tag.rb
+GravatarImageTag.configure do |config|
+ config.default_image = nil # Set this to use your own default gravatar image rather then serving up Gravatar's default image [ 'http://example.com/images/default_gravitar.jpg', :identicon, :monsterid, :wavatar, 404 ].
+ config.filetype = nil # Set this if you require a specific image file format ['gif', 'jpg' or 'png']. Gravatar's default is png
+ config.rating = nil # Set this if you change the rating of the images that will be returned ['G', 'PG', 'R', 'X']. Gravatar's default is G
+ config.size = nil # Set this to globally set the size of the gravatar image returned (1..512). Gravatar's default is 80
+ config.secure = false # Set this to true if you require secure images on your pages.
+end
+</pre>
+
h1. 0.1.0
* -Add support for https calls to Gravatar-
View
@@ -21,7 +21,7 @@ begin
end
Jeweler::GemcutterTasks.new
rescue LoadError
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
end
desc 'Default: spec tests.'
View
@@ -1 +1 @@
-0.0.0.pre1
+1.0.0.pre1
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{gravatar_image_tag}
- s.version = "0.1.0"
+ s.version = "1.0.0.pre1"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Michael Deering"]
- s.date = %q{2010-01-19}
+ s.date = %q{2010-07-11}
s.email = %q{mdeering@mdeering.com}
s.extra_rdoc_files = [
"README.textile"
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.homepage = %q{http://github.com/mdeering/gravatar_image_tag}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
+ s.rubygems_version = %q{1.3.7}
s.summary = %q{A configurable and documented Rails view helper for adding gravatars into your Rails application.}
s.test_files = [
"spec/gravatar_image_tag_spec.rb",
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
else
end
else
View
@@ -14,39 +14,38 @@ class Configuration
end
def self.included(base)
- GravatarImageTag.configure do |c|
- end
+ GravatarImageTag.configure { |c| nil }
base.extend ClassMethods
base.send :include, InstanceMethods
end
module ClassMethods
def default_gravatar_filetype=(value)
- # TODO: Deprication Warning!
+ warn "DEPRECATION WARNING: configuration of filetype= through this method is deprecated! Use the block configuration instead. http://github.com/mdeering/gravatar_image_tag"
GravatarImageTag.configure do |c|
c.filetype = value
end
end
def default_gravatar_image=(value)
- # TODO: Deprication Warning!
+ warn "DEPRECATION WARNING: configuration of default_gravatar_image= through this method is deprecated! Use the block configuration instead. http://github.com/mdeering/gravatar_image_tag"
GravatarImageTag.configure do |c|
c.default_image = value
end
end
def default_gravatar_rating=(value)
- # TODO: Deprication Warning!
+ warn "DEPRECATION WARNING: configuration of default_gravatar_rating= through this method is deprecated! Use the block configuration instead. http://github.com/mdeering/gravatar_image_tag"
GravatarImageTag.configure do |c|
c.rating = value
end
end
def default_gravatar_size=(value)
- # TODO: Deprication Warning!
+ warn "DEPRECATION WARNING: configuration of default_gravatar_size= through this method is deprecated! Use the block configuration instead. http://github.com/mdeering/gravatar_image_tag"
GravatarImageTag.configure do |c|
c.size = value
end
end
def secure_gravatar=(value)
- # TODO: Deprication Warning!
+ warn "DEPRECATION WARNING: configuration of secure_gravatar= through this method is deprecated! Use the block configuration instead. http://github.com/mdeering/gravatar_image_tag"
GravatarImageTag.configure do |c|
c.secure = value
end
@@ -82,7 +81,7 @@ def self.gravatar_url_base(secure = false)
end
def self.gravatar_id(email, filetype = nil)
- "#{ Digest::MD5.hexdigest(email) }#{ ".#{filetype}" unless filetype.nil? }"
+ "#{ Digest::MD5.hexdigest(email) }#{ ".#{filetype}" unless filetype.nil? }" unless email.nil?
end
def self.url_params(gravatar_params)
@@ -42,6 +42,7 @@
:secure_gravatar => secure
}.each do |singleton_variable, value|
it "should give a deprication warning for assigning to #{singleton_variable} and passthrough to set the new variable" do
+ ActionView::Base.should_receive(:warn)
ActionView::Base.send("#{singleton_variable}=", value)
GravatarImageTag.configuration.default_image == value if singleton_variable == :default_gravatar_image
GravatarImageTag.configuration.filetype == value if singleton_variable == :default_gravatar_filetype
@@ -54,9 +55,9 @@
# Now that the defaults are set...
{
{ :gravatar_id => md5, :size => default_size, :default => default_image_escaped } => {},
- { :gravatar_id => md5, :size => 30, :default => default_image_escaped } => { :gravatar => { :size => 30 }},
+ { :gravatar_id => md5, :size => 30, :default => default_image_escaped } => { :gravatar => { :size => 30 } },
{ :gravatar_id => md5, :size => default_size, :default => other_image_escaped } => { :gravatar => {:default => other_image } },
- { :gravatar_id => md5, :size => 30, :default => other_image_escaped } => { :gravatar => { :default => other_image, :size => 30 }},
+ { :gravatar_id => md5, :size => 30, :default => other_image_escaped } => { :gravatar => { :default => other_image, :size => 30 } },
}.each do |params, options|
it "#gravatar_image_tag #{params} should create the provided url when defaults have been set with the provided options #{options}" do
view = ActionView::Base.new
@@ -74,4 +75,8 @@
(!!view.gravatar_image_tag(email, { :gravatar => { :secure => true } }).match(/src="https:\/\/secure.gravatar.com\/avatar\//)).should be_true
end
+ it 'GravatarImageTag#gravitar_id should not error out when email is nil' do
+ lambda { GravatarImageTag::gravatar_id(nil) }.should_not raise_error(TypeError)
+ end
+
end

0 comments on commit c314165

Please sign in to comment.