email_to_face 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ EmailToFace
2
+ ====
3
+
4
+ Installation
5
+ ---
6
+ Using Bundler:
7
+
8
+ gem "email_to_face"
9
+
10
+ Facebok Graph API
11
+ ----
12
+ The Graph API is the simple, slick new interface to Facebook's data. Using it to get a user image with EmailToFace is quite straightforward:
13
+
14
+ @email_to_face = EmailToFace::App.new(:facebook_user_token => oauth_access_token)
15
+ @email_to_face.convert('user@email.com')
16
+ => { :url => 'https://graph.facebook.com/111111111/picture?type=large' }
17
+
18
+
19
+ Gravatar
20
+ ----
21
+ If the user is not found via the Graph API, or if an access token is not passed, the gravatar api will be called.
22
+
23
+ @email_to_face = EmailToFace::App.new()
24
+ @email_to_face.convert('user@email.com')
25
+ => { :url => 'http://www.gravatar.com/avatar.php?gravatar_id=c44b0f24cfce9aacc7c1969c5666cfae&d=404' }
26
+
27
+ Face.com
28
+ ----
29
+ If face.com credentials are passed, the convert method will return the location of the users's face in the image.
30
+ See [developers.face.com](http://developers.face.com/) for more information.
31
+
32
+ @email_to_face = EmailToFace::App.new(:facebook_user_token => oauth_access_token, :face_api_key => key, :face_api_secret => secret)
33
+ @email_to_face.convert('user@email.com')
34
+ => { :url => 'https://graph.facebook.com/111111111/picture?type=large', :x => 48.89, :y => 38.1 }
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = EmailToFace::VERSION
8
8
  s.authors = ["Julian Tescher"]
9
9
  s.email = ["jatescher@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/jtescher/EmailToFace"
11
11
  s.summary = %q{ Email to user image tool }
12
12
  s.description = %q{ A way to simply obtain a facebook, or gravatar image from an email. }
13
13
 
@@ -23,6 +23,5 @@ Gem::Specification.new do |s|
23
23
 
24
24
  # s.add_runtime_dependency "rest-client"
25
25
  s.add_runtime_dependency "json"
26
- s.add_runtime_dependency "typhoeus"
27
26
  s.add_runtime_dependency "face"
28
27
  end
data/lib/email_to_face.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "json"
2
- require 'typhoeus'
2
+ require 'net/http'
3
3
  require 'face'
4
4
  require "email_to_face/version"
5
5
  require 'email_to_face/app'
@@ -14,8 +14,13 @@ module EmailToFace
14
14
  def self.user_image(email)
15
15
  begin
16
16
  # Query the graph for the user e.g. email@gmail.com&type=user&access_token=token
17
- uri = URI.encode("https://graph.facebook.com/search?q=#{email}&type=user&access_token=#{@access_token}")
18
- response = Typhoeus::Request.get(uri, :disable_ssl_peer_verification => true)
17
+ url = URI.encode("https://graph.facebook.com/search?q=#{email}&type=user&access_token=#{@access_token}")
18
+ uri = URI.parse(url)
19
+
20
+ req = Net::HTTP.new(uri.host, 443)
21
+ req.use_ssl = true
22
+
23
+ response = req.request_get(uri.path + '?' + uri.query)
19
24
  result = JSON.parse(response.body)
20
25
  rescue Exception => e
21
26
  puts e.inspect
@@ -35,9 +40,9 @@ module EmailToFace
35
40
 
36
41
  def self.user_image(email)
37
42
  begin
38
- uri = URI.encode("http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(email)}&d=404")
39
- response = Typhoeus::Request.get(uri)
40
- response.code == 200 ? uri : nil
43
+ url = "http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(email)}&d=404"
44
+ response = Net::HTTP.get_response(URI.parse(url))
45
+ response.code == '200' ? url : nil
41
46
  rescue Exception => e
42
47
  puts e.inspect
43
48
  return nil
@@ -1,3 +1,3 @@
1
1
  module EmailToFace
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julian Tescher
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-13 00:00:00 -07:00
18
+ date: 2011-09-14 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- name: typhoeus
50
+ name: face
51
51
  prerelease: false
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -60,20 +60,6 @@ dependencies:
60
60
  version: "0"
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: face
65
- prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- type: :runtime
76
- version_requirements: *id004
77
63
  description: " A way to simply obtain a facebook, or gravatar image from an email. "
78
64
  email:
79
65
  - jatescher@gmail.com
@@ -86,6 +72,7 @@ extra_rdoc_files: []
86
72
  files:
87
73
  - .gitignore
88
74
  - Gemfile
75
+ - README.md
89
76
  - Rakefile
90
77
  - email_to_face.gemspec
91
78
  - lib/email_to_face.rb
@@ -95,7 +82,7 @@ files:
95
82
  - spec/lib/email_to_face_spec.rb
96
83
  - spec/spec_helper.rb
97
84
  has_rdoc: true
98
- homepage: ""
85
+ homepage: https://github.com/jtescher/EmailToFace
99
86
  licenses: []
100
87
 
101
88
  post_install_message: