has_gravatar 0.0.2 → 0.0.3b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile.lock +32 -35
- data/LICENSE +1 -1
- data/README.md +50 -16
- data/Rakefile +1 -1
- data/has_gravatar.gemspec +11 -13
- data/lib/has_gravatar.rb +1 -1
- data/lib/has_gravatar/extensions.rb +10 -10
- data/lib/has_gravatar/version.rb +2 -2
- data/spec/lib/has_gravatar_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -4
- data/spec/support/data.rb +1 -1
- data/spec/support/models.rb +1 -1
- data/spec/support/schema.rb +5 -5
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f425b29ba214f3331144b532483a83caf1b23010
|
4
|
+
data.tar.gz: 67cbf5913ee33ce74ee6d55ef7187ccdacf946f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bea5929e50ebbd7930c4825651225353690dae8e66a2e024d69ba943553e078c47b74265b891024af9eaa0e1a14a758227c09df7918c98bc7e24a3552af15b
|
7
|
+
data.tar.gz: 31f27187a6e780c4e149004f24d6ccd5434013a7c66a6ac4f4c8e37c6c003e259e75aaa4443d0ea2c0bc34561abf23f94793f800e8a6d2948904871fe37690f1
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,47 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
has_gravatar (0.0.
|
5
|
-
activerecord (
|
4
|
+
has_gravatar (0.0.3b)
|
5
|
+
activerecord (>= 5.0.0.rc1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
thread_safe (~> 0.1)
|
24
|
-
tzinfo (~> 0.3.37)
|
25
|
-
arel (4.0.1)
|
26
|
-
atomic (1.1.14)
|
27
|
-
builder (3.1.4)
|
10
|
+
activemodel (5.0.0.rc1)
|
11
|
+
activesupport (= 5.0.0.rc1)
|
12
|
+
activerecord (5.0.0.rc1)
|
13
|
+
activemodel (= 5.0.0.rc1)
|
14
|
+
activesupport (= 5.0.0.rc1)
|
15
|
+
arel (~> 7.0)
|
16
|
+
activesupport (5.0.0.rc1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
arel (7.0.0)
|
22
|
+
concurrent-ruby (1.0.2)
|
28
23
|
diff-lcs (1.2.5)
|
29
|
-
i18n (0.
|
30
|
-
minitest (
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
rspec-
|
35
|
-
rspec-
|
36
|
-
|
37
|
-
rspec-
|
38
|
-
rspec-expectations (2.14.4)
|
24
|
+
i18n (0.7.0)
|
25
|
+
minitest (5.9.0)
|
26
|
+
rake (10.5.0)
|
27
|
+
rspec (2.99.0)
|
28
|
+
rspec-core (~> 2.99.0)
|
29
|
+
rspec-expectations (~> 2.99.0)
|
30
|
+
rspec-mocks (~> 2.99.0)
|
31
|
+
rspec-core (2.99.2)
|
32
|
+
rspec-expectations (2.99.2)
|
39
33
|
diff-lcs (>= 1.1.3, < 2.0)
|
40
|
-
rspec-mocks (2.
|
41
|
-
sqlite3 (1.3.
|
42
|
-
thread_safe (0.
|
43
|
-
|
44
|
-
|
34
|
+
rspec-mocks (2.99.4)
|
35
|
+
sqlite3 (1.3.11)
|
36
|
+
thread_safe (0.3.5)
|
37
|
+
tzinfo (1.2.2)
|
38
|
+
thread_safe (~> 0.1)
|
45
39
|
|
46
40
|
PLATFORMS
|
47
41
|
ruby
|
@@ -52,3 +46,6 @@ DEPENDENCIES
|
|
52
46
|
rake (~> 10.1)
|
53
47
|
rspec (~> 2.14)
|
54
48
|
sqlite3 (~> 1.3)
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
1.12.4
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,32 @@
|
|
1
|
-
has_gravatar
|
2
|
-
============
|
1
|
+
# has_gravatar
|
3
2
|
|
4
3
|
[![Build Status](https://travis-ci.org/victorgama/has_gravatar.png?branch=master)](https://travis-ci.org/victorgama/has_gravatar) [![Dependency Status](https://gemnasium.com/victorgama/has_gravatar.png)](https://gemnasium.com/victorgama/has_gravatar)
|
5
4
|
|
6
|
-
has_gravatar is intended to add easy access to
|
5
|
+
has_gravatar is intended to add easy access to Gravatar URLs from ActiveRecord models.
|
7
6
|
|
8
|
-
Installation
|
9
|
-
------------
|
7
|
+
## Installation
|
10
8
|
|
11
|
-
|
9
|
+
Add the following line to your `Gemfile`, depending on your Rails version:
|
10
|
+
|
11
|
+
### For Rails 5 and upward
|
12
|
+
```
|
13
|
+
gem 'has_gravatar', '~> 0.0.3'
|
14
|
+
```
|
15
|
+
|
16
|
+
### For Rails 4.2.6 and backwards
|
17
|
+
```
|
18
|
+
gem 'has_gravatar', '~> 0.0.2'
|
19
|
+
```
|
12
20
|
|
13
|
-
First, include the gem in your Gemfile:
|
14
|
-
`gem "has_gravatar"`
|
15
21
|
And install it:
|
16
|
-
|
22
|
+
```
|
23
|
+
$ bundle
|
24
|
+
```
|
17
25
|
|
18
|
-
After these two simple steps, has_gravatar is ready to be used on any
|
26
|
+
After these two simple steps, has_gravatar is ready to be used on any ActiveRecord model.
|
19
27
|
In order to use it, call `has_gravatar`, passing one or more fields as argument. Example:
|
20
28
|
```ruby
|
21
|
-
class User <
|
29
|
+
class User < ApplicationRecord
|
22
30
|
has_gravatar :primary_email, :secondary_email, :email
|
23
31
|
end
|
24
32
|
```
|
@@ -29,17 +37,43 @@ user = User.first
|
|
29
37
|
|
30
38
|
# Returns http://gravatar.com/avatar/<hash>
|
31
39
|
user.email_gravatar
|
32
|
-
|
40
|
+
|
33
41
|
# Supports default images
|
34
42
|
user.email_gravatar default_avatar: 'http://my.domain.com/public/default_gravatar.png'
|
35
|
-
|
43
|
+
|
36
44
|
# And sizing
|
37
45
|
user.email_gravatar default_avatar: 'http://my.domain.com/public/default_gravatar.png', size: 128
|
38
|
-
|
46
|
+
|
39
47
|
# And HTTPS
|
40
48
|
user.email_gravatar default_avatar: 'http://my.domain.com/public/default_gravatar.png', size: 128, secure: true
|
41
49
|
|
42
50
|
```
|
43
51
|
|
44
|
-
|
45
|
-
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
If you find any problem using this gem, please fill an Issue. Pull requests are welcome. 🚢
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
```
|
59
|
+
The MIT License (MIT)
|
60
|
+
|
61
|
+
Copyright (c) 2016 Victor Gama
|
62
|
+
|
63
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
64
|
+
this software and associated documentation files (the "Software"), to deal in
|
65
|
+
the Software without restriction, including without limitation the rights to
|
66
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
67
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
68
|
+
subject to the following conditions:
|
69
|
+
|
70
|
+
The above copyright notice and this permission notice shall be included in all
|
71
|
+
copies or substantial portions of the Software.
|
72
|
+
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
74
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
75
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
76
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
77
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
78
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
79
|
+
```
|
data/Rakefile
CHANGED
data/has_gravatar.gemspec
CHANGED
@@ -2,29 +2,27 @@
|
|
2
2
|
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'has_gravatar/version'
|
5
|
+
require 'has_gravatar/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
|
9
|
-
spec.name = 'has_gravatar'
|
8
|
+
spec.name = 'has_gravatar'
|
10
9
|
spec.version = HasGravatar::VERSION
|
11
10
|
spec.authors = ['Victor Gama']
|
12
11
|
spec.email = ['hey@vito.io']
|
13
|
-
spec.description =
|
14
|
-
spec.summary =
|
15
|
-
spec.homepage = '
|
12
|
+
spec.description = 'Dead simple Gravatar URL generator'
|
13
|
+
spec.summary = 'Dead simple Gravatar URL generator'
|
14
|
+
spec.homepage = 'https://github.com/victorgama/has_gravatar'
|
16
15
|
spec.license = 'MIT'
|
17
|
-
|
18
|
-
spec.files = `git ls-files`.split(
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
19
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
spec.require_paths = [
|
22
|
-
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
23
22
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
23
|
spec.add_development_dependency 'rake', '~> 10.1'
|
25
24
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
26
25
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
27
|
-
|
28
|
-
spec.add_dependency 'activerecord', '~> 4.0'
|
29
26
|
|
30
|
-
|
27
|
+
spec.add_dependency 'activerecord', '>= 5.0.0.rc1'
|
28
|
+
end
|
data/lib/has_gravatar.rb
CHANGED
@@ -4,28 +4,28 @@ module HasGravatar
|
|
4
4
|
module Extensions
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
module ClassMethods
|
7
|
-
def has_gravatar
|
7
|
+
def has_gravatar(*fields)
|
8
8
|
fields.each do |field|
|
9
9
|
method_name = "#{field}_gravatar".to_sym
|
10
|
-
|
10
|
+
send :define_method, method_name do |*args|
|
11
11
|
protocol = '://'
|
12
12
|
default_url = nil
|
13
13
|
size = nil
|
14
|
-
if args.is_a?(Array) && args.size == 1 && args[0].is_a?(Hash)
|
14
|
+
if args.is_a?(Array) && args.size == 1 && args[0].is_a?(Hash)
|
15
15
|
args = args[0]
|
16
|
-
protocol = 's://secure.' if args.
|
16
|
+
protocol = 's://secure.' if args.key?(:secure) && args[:secure] == true
|
17
17
|
# From: ERB library (http://rdoc.info/stdlib/erb/1.8.7/ERB/Util%3aurl_encode)
|
18
|
-
default_url = 'd=' << args[:default_avatar].to_s.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf(
|
19
|
-
size = 's=' << args[:size].to_s if args.
|
18
|
+
default_url = 'd=' << args[:default_avatar].to_s.gsub(/[^a-zA-Z0-9_\-.]/n) { sprintf('%%%02X', $&.unpack('C')[0]) } if args.key? :default_avatar
|
19
|
+
size = 's=' << args[:size].to_s if args.key? :size
|
20
20
|
end
|
21
|
-
hash = Digest::MD5.hexdigest(
|
22
|
-
suffix = [default_url, size].reject! {|item| item
|
21
|
+
hash = Digest::MD5.hexdigest(send(field.to_sym))
|
22
|
+
suffix = [default_url, size].reject! { |item| item.nil? || item.empty? }.join('&')
|
23
23
|
suffix = '?' << suffix unless suffix.empty?
|
24
|
-
|
24
|
+
|
25
25
|
"http#{protocol}gravatar.com/avatar/#{hash}#{suffix}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
data/lib/has_gravatar/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module HasGravatar
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = '0.0.3b'.freeze
|
3
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Model' do
|
3
|
+
describe 'Model' do
|
4
4
|
it 'should contain VERSION' do
|
5
5
|
HasGravatar::VERSION.should_not be_nil
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
let(:user) { User.first }
|
9
|
-
|
9
|
+
|
10
10
|
it 'should respond to email_gravatar method' do
|
11
11
|
user.should respond_to :email_gravatar
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it 'should return a valid gravatar url for the given email address' do
|
15
15
|
# Hash calculated by md5.cz
|
16
16
|
user.email_gravatar.should eq 'http://gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it 'should support https gravatars' do
|
20
20
|
user.email_gravatar(secure: true).should start_with 'https://secure.gravatar'
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it 'should support default images' do
|
24
24
|
user.email_gravatar(default_avatar: 'http://example.com/public/default_gravatar.png').should include 'example.com'
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it 'should support gravatar size' do
|
28
28
|
user.email_gravatar(size: 128).should include '?s=128'
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'has_gravatar'
|
2
2
|
|
3
|
-
ActiveRecord::Base.establish_connection(adapter:
|
4
|
-
database: File.dirname(__FILE__) +
|
5
|
-
|
3
|
+
ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
|
4
|
+
database: File.dirname(__FILE__) + '/db/has_gravatar.sqlite3')
|
5
|
+
|
6
6
|
load File.dirname(__FILE__) + '/support/schema.rb'
|
7
7
|
load File.dirname(__FILE__) + '/support/models.rb'
|
8
|
-
load File.dirname(__FILE__) + '/support/data.rb'
|
8
|
+
load File.dirname(__FILE__) + '/support/data.rb'
|
data/spec/support/data.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
User.create!(email: 'example@example.com')
|
1
|
+
User.create!(email: 'example@example.com')
|
data/spec/support/models.rb
CHANGED
data/spec/support/schema.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_gravatar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3b
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Gama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: activerecord
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.0.0.rc1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.0.0.rc1
|
83
83
|
description: Dead simple Gravatar URL generator
|
84
84
|
email:
|
85
85
|
- hey@vito.io
|
@@ -105,7 +105,7 @@ files:
|
|
105
105
|
- spec/support/data.rb
|
106
106
|
- spec/support/models.rb
|
107
107
|
- spec/support/schema.rb
|
108
|
-
homepage:
|
108
|
+
homepage: https://github.com/victorgama/has_gravatar
|
109
109
|
licenses:
|
110
110
|
- MIT
|
111
111
|
metadata: {}
|
@@ -120,12 +120,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 1.3.1
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.4.8
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Dead simple Gravatar URL generator
|