gravatarable 0.0.0
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 +7 -0
- data/lib/gravatarable.rb +38 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b918d9196b2bc8ee89e8a31dcc0884ef72a884c0
|
4
|
+
data.tar.gz: 5348c6720bda0693ab054e551f23a3940076eaba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec425710c770ed3f116086bfcbceada84d0edab909cef532640a17ca25f8b0d4f1fddbd31badd428ab4bff0e52b911231daddc3ffc5abec996af71ed3f8b5e2b
|
7
|
+
data.tar.gz: 63571ddf21eb80512c199a0f73c2bf6b28694db4bf0e42b0996ff158fdf86060754527ae3d30d3ef8e401ea8a10d68446488f6780b759bdea1dc6ecceaae3545
|
data/lib/gravatarable.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Gravatarable
|
2
|
+
def self.included(base)
|
3
|
+
base.send(:include, InstanceMethods)
|
4
|
+
base.extend ClassMethods
|
5
|
+
base.class_eval do
|
6
|
+
class_setup
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
def gravatar_url
|
12
|
+
email = self.send(self.class.email_addr.to_sym).downcase
|
13
|
+
email_hash = hash_email(email)
|
14
|
+
gravatar_path(email_hash)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def gravatar_path(hsh)
|
20
|
+
"https://www.gravatar.com/avatar/#{hsh}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def hash_email(email)
|
24
|
+
Digest::MD5.hexdigest(email)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module ClassMethods
|
29
|
+
def class_setup
|
30
|
+
class_attribute :email_addr
|
31
|
+
before_save :gravatar_url if "#{self.email_addr}_changed?".to_sym
|
32
|
+
end
|
33
|
+
|
34
|
+
def gravatar_column(col_name)
|
35
|
+
self.email_addr = col_name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gravatarable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Liam Sean Brady
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Simplifying displaying Gravatar images in your Rails app!
|
14
|
+
email: liamseanbrady@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/gravatarable.rb
|
20
|
+
homepage: http://github.com/liamseanbrady
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.2.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Gravatar image gem
|
43
|
+
test_files: []
|