my_gravatar 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/my_gravatar/form_helpers.rb +34 -0
- data/lib/my_gravatar/gravatar_extensions.rb +51 -0
- data/lib/my_gravatar/version.rb +3 -0
- data/lib/my_gravatar.rb +5 -0
- data/my_gravatar.gemspec +19 -0
- metadata +11 -2
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 pragash rajarathnam
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# MyGravatar
|
2
|
+
|
3
|
+
This gem will help you display images from the Gravatar site without the hassle of needing to know all the ways in which you want to generate the request.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'my_gravatar'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install gravatar
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Example
|
22
|
+
|
23
|
+
<%= gravatar_image_tag(:gravatar => { :secure => true,
|
24
|
+
:email => "pragashonlink@gmail.com",
|
25
|
+
:size => "s",
|
26
|
+
:rating => "g" }) %>
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module MyGravatar
|
2
|
+
module FormHelpers
|
3
|
+
|
4
|
+
def gravatar_image_tag(options = {})
|
5
|
+
raise "Please specify gravatar options." unless options[:gravatar]
|
6
|
+
raise "Please specify gravatar email." unless options[:gravatar][:email]
|
7
|
+
|
8
|
+
source, options = process_gravatar_options(options)
|
9
|
+
|
10
|
+
image_tag(source, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
#secure, email, size, default_image, rating
|
14
|
+
def process_gravatar_options(opts)
|
15
|
+
host = GravatarExtensions.url(opts[:gravatar][:secure] ||= false)
|
16
|
+
hash = GravatarExtensions.account_key(opts[:gravatar][:email])
|
17
|
+
|
18
|
+
url_params = []
|
19
|
+
["size", "default_image", "rating"].each do |k|
|
20
|
+
key = GravatarExtensions.gravatar_param_key(k)
|
21
|
+
value = opts[:gravatar][k.to_sym] ||= GravatarExtensions.gravatar_default_value(k)
|
22
|
+
url_params << "#{key}=#{value}"
|
23
|
+
end
|
24
|
+
|
25
|
+
url = []
|
26
|
+
url << host
|
27
|
+
url << hash
|
28
|
+
url << url_params.join("/")
|
29
|
+
|
30
|
+
return url.join("/"), opts.delete(:gravatar)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module MyGravatar
|
2
|
+
module GravatarExtensions
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def url(https)
|
6
|
+
https ? "https://secure.gravatar.com/avatar" : "http://www.gravatar.com/avatar"
|
7
|
+
end
|
8
|
+
|
9
|
+
def account_key(value)
|
10
|
+
require 'digest/md5'
|
11
|
+
|
12
|
+
digest = Digest::MD5.hexdigest(value.lstrip.rstrip.downcase)
|
13
|
+
end
|
14
|
+
|
15
|
+
def gravatar_param_key(key)
|
16
|
+
case (key)
|
17
|
+
when "size"
|
18
|
+
"s"
|
19
|
+
when "default_image"
|
20
|
+
"d"
|
21
|
+
when "rating"
|
22
|
+
"r"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def gravatar_default_value(key)
|
27
|
+
case (key)
|
28
|
+
when "size"
|
29
|
+
size
|
30
|
+
when "default_image"
|
31
|
+
image
|
32
|
+
when "rating"
|
33
|
+
rating
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def size
|
38
|
+
"200"
|
39
|
+
end
|
40
|
+
|
41
|
+
def image
|
42
|
+
"retro"
|
43
|
+
end
|
44
|
+
|
45
|
+
def rating
|
46
|
+
"g"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
data/lib/my_gravatar.rb
ADDED
data/my_gravatar.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/my_gravatar/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "my_gravatar"
|
6
|
+
gem.version = MyGravatar::VERSION
|
7
|
+
gem.authors = ["Pragash"]
|
8
|
+
gem.email = ["pragashonlink@gmail.com"]
|
9
|
+
gem.homepage = "http://www.pragashblog.blogspot.com"
|
10
|
+
gem.summary = %q{Include GRAVATAR images}
|
11
|
+
gem.description = %q{Using this gem one can easily call and use the images in GRAVATAR}
|
12
|
+
|
13
|
+
gem.rubyforge_project = "my_gravatar"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_gravatar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -17,7 +17,16 @@ email:
|
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
|
-
files:
|
20
|
+
files:
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/my_gravatar.rb
|
26
|
+
- lib/my_gravatar/form_helpers.rb
|
27
|
+
- lib/my_gravatar/gravatar_extensions.rb
|
28
|
+
- lib/my_gravatar/version.rb
|
29
|
+
- my_gravatar.gemspec
|
21
30
|
homepage: http://www.pragashblog.blogspot.com
|
22
31
|
licenses: []
|
23
32
|
post_install_message:
|