email_to_face 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/email_to_face.rb +2 -2
- data/lib/email_to_face/version.rb +1 -1
- data/spec/lib/email_to_face/app_spec.rb +4 -4
- data/spec/lib/email_to_face_spec.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -33,7 +33,7 @@ If the user is not found via the Facebook Graph API, or if an access token is no
|
|
33
33
|
``` ruby
|
34
34
|
@email_to_face = EmailToFace::App.new()
|
35
35
|
@email_to_face.convert('user@email.com')
|
36
|
-
=> { :url => 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=
|
36
|
+
=> { :url => 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=180' }
|
37
37
|
```
|
38
38
|
|
39
39
|
Face.com
|
@@ -65,10 +65,10 @@ By default Gravatar always returns square centered images. If you want to use fa
|
|
65
65
|
:face_api_secret => secret)
|
66
66
|
|
67
67
|
@email_to_face.convert('user@email.com')
|
68
|
-
=> { :url => 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=
|
68
|
+
=> { :url => 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=180', :x => 48.89, :y => 38.1 }
|
69
69
|
```
|
70
70
|
|
71
|
-
The Facebook Graph API lets you specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), normal (100 pixels wide, variable height), and large (
|
71
|
+
The Facebook Graph API lets you specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), normal (100 pixels wide, variable height), and large (180 pixels wide, variable height). You can assign this via the `:facebook_image_type` option (default is 'large', Gravatar will match):
|
72
72
|
|
73
73
|
``` ruby
|
74
74
|
@email_to_face = EmailToFace::App.new(
|
data/lib/email_to_face.rb
CHANGED
@@ -40,9 +40,9 @@ module EmailToFace
|
|
40
40
|
class Gravatar
|
41
41
|
|
42
42
|
def self.user_image(email, fb_type=nil)
|
43
|
-
fb_types = { 'square' => 50, 'small' => 50, 'normal' => 100, 'large' =>
|
43
|
+
fb_types = { 'square' => 50, 'small' => 50, 'normal' => 100, 'large' => 180 }
|
44
44
|
begin
|
45
|
-
url = "http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(email)}&d=404&s=#{fb_types[fb_type] ||
|
45
|
+
url = "http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(email)}&d=404&s=#{fb_types[fb_type] || 180}"
|
46
46
|
response = Net::HTTP.get_response(URI.parse(url))
|
47
47
|
response.code == '200' ? url : nil
|
48
48
|
rescue Exception => e
|
@@ -42,9 +42,9 @@ describe EmailToFace::App do
|
|
42
42
|
:face_api_key => ENV['FACE_API_KEY'],
|
43
43
|
:face_api_secret => ENV['FACE_API_SECRET'])
|
44
44
|
result = @app.convert("virulent@gmail.com")
|
45
|
-
result[:url].should == 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=
|
46
|
-
result[:x].should == 31.
|
47
|
-
result[:y].should == 60.
|
45
|
+
result[:url].should == 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=180'
|
46
|
+
result[:x].should == 31.39
|
47
|
+
result[:y].should == 60.28
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should return an object with a url if :use_face_for_gravatar not set" do
|
@@ -52,7 +52,7 @@ describe EmailToFace::App do
|
|
52
52
|
:face_api_key => ENV['FACE_API_KEY'],
|
53
53
|
:face_api_secret => ENV['FACE_API_SECRET'])
|
54
54
|
result = @app.convert("virulent@gmail.com")
|
55
|
-
result[:url].should == 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=
|
55
|
+
result[:url].should == 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=180'
|
56
56
|
result[:x].should be_nil
|
57
57
|
result[:y].should be_nil
|
58
58
|
end
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
describe EmailToFace::Gravatar do
|
23
23
|
describe ".user_image" do
|
24
24
|
it "returns the url for the user's image if it exists" do
|
25
|
-
EmailToFace::Gravatar.user_image('virulent@gmail.com').should == 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=
|
25
|
+
EmailToFace::Gravatar.user_image('virulent@gmail.com').should == 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404&s=180'
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns nil if the user does not exist" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_to_face
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.4
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julian Tescher
|