Awesome
SimpleGravatar
Add gravatars to your ruby project as simple as possible.
Installation
Add it to your Gemfile and run the bundle
command:
gem 'simple_gravatar'
Usage
Include de module where you want to use it:
class UserDecorator
include SimpleGravatar
def initialize(user)
@user = user
end
def gravatar
gravatar_url @user.email
end
end
Using in rails
Include the module in ActionView::Base
, let's say, in
config/initializers/simple_gravatar.rb
:
ActionView::Base.send(:include, SimpleGravatar) if defined? ActionView::Base
and use it anywhere in your views:
<%= image_tag gravatar_url('patriciomacadden@gmail.com') %>
Using in sinatra
Include the module as a helper:
helpers SimpleGravatar
get '/' do
gravatar_url 'patriciomacadden@gmail.com'
end
Available options
All available options are the specified by Gravatar API documentation.
Contributing
- Fork it
- Create a branch (
git checkout -b my_awesome_branch
) - Commit your changes (
git commit -am "Added some magic"
) - Push to the branch (
git push origin my_awesome_branch
) - Send pull request
License
See the LICENSE.