faces 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/faces.gemspec +3 -3
- data/lib/faces.rb +6 -1
- data/lib/providers/facebook.rb +2 -0
- data/lib/providers/flickr.rb +2 -0
- data/lib/providers/gravatar.rb +2 -0
- data/lib/providers/highrise.rb +2 -0
- data/lib/providers/twitter.rb +2 -0
- data/test/test_faces.rb +25 -12
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/faces.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{faces}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nick Pellant"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-18}
|
13
13
|
s.description = %q{Avatars made super simple.}
|
14
14
|
s.email = %q{nick@silentale.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/faces.rb
CHANGED
@@ -49,6 +49,11 @@ module Faces
|
|
49
49
|
obj = "::Faces::Providers::#{provider.to_s.classify}".constantize.new
|
50
50
|
obj.exists?(identifier, configuration)
|
51
51
|
end
|
52
|
+
# Returns true if the provider has SSL available, else false
|
53
|
+
def provider_supports_ssl?(provider)
|
54
|
+
obj = "::Faces::Providers::#{provider.to_s.classify}".constantize.new
|
55
|
+
obj.respond_to?('ssl?') ? obj.ssl? : false
|
56
|
+
end
|
52
57
|
# Returns the default avatar in an <img /> HTML tag
|
53
58
|
def avatar_default_html(configuration = {})
|
54
59
|
url = configuration[:default].present? ? configuration[:default] : ::Faces::Configuration::UNIVERSAL[:default]
|
@@ -83,7 +88,7 @@ module Faces
|
|
83
88
|
html += ' />'
|
84
89
|
end
|
85
90
|
|
86
|
-
module_function :avatar_exists?, :provider_exists?, :provider_method_exists?, :avatar_url, :avatar_html, :generate_html, :avatar_default_html, :avatar_default_url
|
91
|
+
module_function :avatar_exists?, :provider_exists?, :provider_supports_ssl?, :provider_method_exists?, :avatar_url, :avatar_html, :generate_html, :avatar_default_html, :avatar_default_url
|
87
92
|
end
|
88
93
|
module Common
|
89
94
|
# Merges together all configurations given from first to last in order of priority
|
data/lib/providers/facebook.rb
CHANGED
@@ -29,6 +29,8 @@ module Faces
|
|
29
29
|
end
|
30
30
|
# Botch job as it's not possible to check for FBML avatar presence :(
|
31
31
|
def exists?(identifier, configuration = {}); true; end
|
32
|
+
# Doesn't support SSL
|
33
|
+
def ssl?; false; end
|
32
34
|
private
|
33
35
|
# Calculates the size of image to pull from Facebook
|
34
36
|
# This is decided based on the configuration settings of Faces
|
data/lib/providers/flickr.rb
CHANGED
@@ -36,6 +36,8 @@ module Faces
|
|
36
36
|
response = http.request(request)
|
37
37
|
response.code == '200' ? true : false
|
38
38
|
end
|
39
|
+
# Doesn't support SSL
|
40
|
+
def ssl?; false; end
|
39
41
|
private
|
40
42
|
# Fetches the buddyicon farm details based on the user_id given
|
41
43
|
# An avatar can not be pulled from Flickr without this method
|
data/lib/providers/gravatar.rb
CHANGED
@@ -40,6 +40,8 @@ module Faces
|
|
40
40
|
response = http.request(request)
|
41
41
|
response.code == '200' ? true : false
|
42
42
|
end
|
43
|
+
# Supports SSL
|
44
|
+
def ssl?; true; end
|
43
45
|
# Formats email and converts into MD5 hash for use with Gravatar url
|
44
46
|
def md5_email(email)
|
45
47
|
Digest::MD5.hexdigest(email.strip.downcase)
|
data/lib/providers/highrise.rb
CHANGED
@@ -25,6 +25,8 @@ module Faces
|
|
25
25
|
m_configuration = Faces::Common.merge_configurations([Faces::Configuration::HIGHRISE, configuration])
|
26
26
|
Faces::Public.generate_html(url(contact_id, configuration), m_configuration)
|
27
27
|
end
|
28
|
+
# Supports SSL
|
29
|
+
def ssl?; true; end
|
28
30
|
# Checks Avatar exists
|
29
31
|
def exists?(contact_id, configuration = {})
|
30
32
|
url = URI.parse(url(contact_id, configuration))
|
data/lib/providers/twitter.rb
CHANGED
@@ -25,6 +25,8 @@ module Faces
|
|
25
25
|
m_configuration = Faces::Common.merge_configurations([Faces::Configuration::TWITTER, configuration])
|
26
26
|
Faces::Public.generate_html(url(username, configuration), m_configuration)
|
27
27
|
end
|
28
|
+
# Doesn't support SSL
|
29
|
+
def ssl?; false; end
|
28
30
|
# Checks Avatar exists
|
29
31
|
def exists?(username, configuration = {})
|
30
32
|
url = URI.parse(url(username, configuration))
|
data/test/test_faces.rb
CHANGED
@@ -8,53 +8,66 @@ class FacesTest < Test::Unit::TestCase
|
|
8
8
|
#--- avatar_url ---#
|
9
9
|
####################
|
10
10
|
def test_avatar_url_should_return_avatar_url_non_secure
|
11
|
-
url = Faces::Public.avatar_url('someone@something.com', 'gravatar')
|
11
|
+
url = ::Faces::Public.avatar_url('someone@something.com', 'gravatar')
|
12
12
|
assert_match 'http', url
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_avatar_url_should_return_avatar_url_secure
|
16
|
-
url = Faces::Public.avatar_url('someone@something.com', 'gravatar', {:use_secure => true})
|
16
|
+
url = ::Faces::Public.avatar_url('someone@something.com', 'gravatar', {:use_secure => true})
|
17
17
|
assert_match 'https', url
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_avatar_url_should_return_default_when_provider_doesnt_exist
|
21
|
-
url = Faces::Public.avatar_url('someone@something.com', 'imnotreal')
|
22
|
-
assert_equal url, Faces::Public.avatar_default_url
|
21
|
+
url = ::Faces::Public.avatar_url('someone@something.com', 'imnotreal')
|
22
|
+
assert_equal url, ::Faces::Public.avatar_default_url
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_avatar_url_should_return_default_when_provider_method_doesnt_exist
|
26
|
-
url = Faces::Public.avatar_url('xyz', 'facebook')
|
27
|
-
assert_equal url, Faces::Public.avatar_default_url
|
26
|
+
url = ::Faces::Public.avatar_url('xyz', 'facebook')
|
27
|
+
assert_equal url, ::Faces::Public.avatar_default_url
|
28
28
|
end
|
29
29
|
|
30
30
|
#####################
|
31
31
|
#--- avatar_html ---#
|
32
32
|
#####################
|
33
33
|
def test_avatar_html_should_return_avatar_url_non_secure
|
34
|
-
url = Faces::Public.avatar_html('someone@something.com', 'gravatar')
|
34
|
+
url = ::Faces::Public.avatar_html('someone@something.com', 'gravatar')
|
35
35
|
assert_match 'http', url
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_avatar_html_should_return_avatar_url_secure
|
39
|
-
url = Faces::Public.avatar_html('someone@something.com', 'gravatar', {:use_secure => true})
|
39
|
+
url = ::Faces::Public.avatar_html('someone@something.com', 'gravatar', {:use_secure => true})
|
40
40
|
assert_match 'https', url
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_avatar_html_should_return_default_when_provider_doesnt_exist
|
44
|
-
url = Faces::Public.avatar_html('someone@something.com', 'imnotreal')
|
45
|
-
assert_equal url, Faces::Public.avatar_default_html
|
44
|
+
url = ::Faces::Public.avatar_html('someone@something.com', 'imnotreal')
|
45
|
+
assert_equal url, ::Faces::Public.avatar_default_html
|
46
46
|
end
|
47
47
|
|
48
48
|
########################
|
49
49
|
#--- avatar_exists? ---#
|
50
50
|
########################
|
51
51
|
def test_avatar_exists_should_return_true_when_an_avatar_exists
|
52
|
-
exists = Faces::Public.avatar_exists?('da9658571a8ca10cf8b0f91625a8c3d5', 'gravatar')
|
52
|
+
exists = ::Faces::Public.avatar_exists?('da9658571a8ca10cf8b0f91625a8c3d5', 'gravatar')
|
53
53
|
assert_equal exists, true
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_avatar_exists_should_return_false_when_an_avatar_doesnt_exists
|
57
|
-
exists = Faces::Public.avatar_exists?('someone@something.com', 'gravatar')
|
57
|
+
exists = ::Faces::Public.avatar_exists?('someone@something.com', 'gravatar')
|
58
58
|
assert_equal exists, false
|
59
59
|
end
|
60
|
+
|
61
|
+
################################
|
62
|
+
#--- provider_supports_ssl? ---#
|
63
|
+
################################
|
64
|
+
def test_provider_supports_ssl_should_return_true_if_provider_is_ssl_enabled
|
65
|
+
result = ::Faces::Public.provider_supports_ssl?('gravatar')
|
66
|
+
assert result
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_provider_supports_ssl_should_return_false_if_provider_is_not_ssl_enabled_or_set
|
70
|
+
result = ::Faces::Public.provider_supports_ssl?('twitter')
|
71
|
+
assert !result
|
72
|
+
end
|
60
73
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Pellant
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-18 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|