has_gravatar 0.0.2 → 0.0.3b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7dd48ea960895ae0720de73cc33f8d5cb1ac02f
4
- data.tar.gz: 11b077455a547e9331cdcb384ba79e5293336244
3
+ metadata.gz: f425b29ba214f3331144b532483a83caf1b23010
4
+ data.tar.gz: 67cbf5913ee33ce74ee6d55ef7187ccdacf946f4
5
5
  SHA512:
6
- metadata.gz: 83a9534945e06f3847125ade40e6eefbc6eef6e364ae01ca87912b467ec570c4db815bbf8f2d552f35b313cbab94e8fa286a12c62ce073bbdedd5c7316a6e483
7
- data.tar.gz: 976f5679674d8f7403191f4810ec2b63780a34beaf078b420817817aa21f7380c12edf6bc4b84b77ff7a042b4a7157ea64f8b1184fe70d96710b850798a94521
6
+ metadata.gz: 40bea5929e50ebbd7930c4825651225353690dae8e66a2e024d69ba943553e078c47b74265b891024af9eaa0e1a14a758227c09df7918c98bc7e24a3552af15b
7
+ data.tar.gz: 31f27187a6e780c4e149004f24d6ccd5434013a7c66a6ac4f4c8e37c6c003e259e75aaa4443d0ea2c0bc34561abf23f94793f800e8a6d2948904871fe37690f1
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
+ bundler_args:
2
3
  rvm:
3
- - "1.9.3"
4
- - "2.0.0"
4
+ - "2.2.3"
@@ -1,47 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- has_gravatar (0.0.1)
5
- activerecord (~> 4.0)
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 (4.0.2)
11
- activesupport (= 4.0.2)
12
- builder (~> 3.1.0)
13
- activerecord (4.0.2)
14
- activemodel (= 4.0.2)
15
- activerecord-deprecated_finders (~> 1.0.2)
16
- activesupport (= 4.0.2)
17
- arel (~> 4.0.0)
18
- activerecord-deprecated_finders (1.0.3)
19
- activesupport (4.0.2)
20
- i18n (~> 0.6, >= 0.6.4)
21
- minitest (~> 4.2)
22
- multi_json (~> 1.3)
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.6.9)
30
- minitest (4.7.5)
31
- multi_json (1.8.4)
32
- rake (10.1.1)
33
- rspec (2.14.1)
34
- rspec-core (~> 2.14.0)
35
- rspec-expectations (~> 2.14.0)
36
- rspec-mocks (~> 2.14.0)
37
- rspec-core (2.14.7)
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.14.4)
41
- sqlite3 (1.3.8)
42
- thread_safe (0.1.3)
43
- atomic
44
- tzinfo (0.3.38)
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Victor Gama
3
+ Copyright (c) 2016 Victor Gama
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
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 gravatar URLs from Active Record models.
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
- has_gravatar is distributed as a gem, which is how it should be used in your app.
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
- `bundle`
22
+ ```
23
+ $ bundle
24
+ ```
17
25
 
18
- After these two simple steps, has_gravatar is ready to be used on any Active Record model.
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 < ActiveRecord::Base
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
- Pull requests are welcome!
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
@@ -4,4 +4,4 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new
5
5
 
6
6
  task default: :spec
7
- task test: :spec
7
+ task test: :spec
@@ -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 = %q{Dead simple Gravatar URL generator}
14
- spec.summary = %q{Dead simple Gravatar URL generator}
15
- spec.homepage = 'http://github.com/victorgama/has_gravatar'
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 = ["lib"]
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
- end
27
+ spec.add_dependency 'activerecord', '>= 5.0.0.rc1'
28
+ end
@@ -2,4 +2,4 @@ require 'active_record'
2
2
  require 'has_gravatar/version'
3
3
  require 'has_gravatar/extensions'
4
4
 
5
- ActiveRecord::Base.send :include, HasGravatar::Extensions
5
+ ActiveRecord::Base.send :include, HasGravatar::Extensions
@@ -4,28 +4,28 @@ module HasGravatar
4
4
  module Extensions
5
5
  extend ActiveSupport::Concern
6
6
  module ClassMethods
7
- def has_gravatar *fields
7
+ def has_gravatar(*fields)
8
8
  fields.each do |field|
9
9
  method_name = "#{field}_gravatar".to_sym
10
- self.send :define_method, method_name do |*args|
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) then
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.has_key?(:secure) && args[:secure] == true
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("%%%02X", $&.unpack("C")[0]) } if args.has_key? :default_avatar
19
- size = 's=' << args[:size].to_s if args.has_key? :size
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(self.send field.to_sym)
22
- suffix = [default_url, size].reject! {|item| item == nil || item.empty? }.join('&')
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
@@ -1,3 +1,3 @@
1
1
  module HasGravatar
2
- VERSION = "0.0.2"
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
@@ -1,8 +1,8 @@
1
1
  require 'has_gravatar'
2
2
 
3
- ActiveRecord::Base.establish_connection(adapter: "sqlite3",
4
- database: File.dirname(__FILE__) + "/db/has_gravatar.sqlite3")
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'
@@ -1 +1 @@
1
- User.create!(email: 'example@example.com')
1
+ User.create!(email: 'example@example.com')
@@ -1,3 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
2
  has_gravatar :email
3
- end
3
+ end
@@ -1,9 +1,9 @@
1
- ActiveRecord::Schema.define do
1
+ ActiveRecord::Schema.define do
2
2
  self.verbose = false
3
-
3
+
4
4
  create_table :users, force: true do |t|
5
5
  t.string :email
6
-
7
- t.timestamps
6
+
7
+ t.timestamps null: true
8
8
  end
9
- end
9
+ end
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.2
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: 2014-01-19 00:00:00.000000000 Z
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: '4.0'
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: '4.0'
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: http://github.com/victorgama/has_gravatar
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: '0'
125
+ version: 1.3.1
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.2.0
128
+ rubygems_version: 2.4.8
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Dead simple Gravatar URL generator