yehezkielbs-contacts 1.2.14 → 1.2.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/contacts/base.rb +4 -1
- data/lib/contacts/gmail.rb +22 -5
- metadata +9 -9
data/lib/contacts/base.rb
CHANGED
@@ -14,6 +14,7 @@ class Contacts
|
|
14
14
|
def initialize(login, password, options={})
|
15
15
|
@login = login
|
16
16
|
@password = password
|
17
|
+
@oauth_info = (options[:oauth_info] && options[:oauth_info].size > 0) ? options[:oauth_info] : nil
|
17
18
|
@captcha_token = options[:captcha_token]
|
18
19
|
@captcha_response = options[:captcha_response]
|
19
20
|
@connections = {}
|
@@ -21,7 +22,9 @@ class Contacts
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def connect
|
24
|
-
|
25
|
+
unless @oauth_info
|
26
|
+
raise AuthenticationError, "Login and password must not be nil, login: #{@login.inspect}, password: #{@password.inspect}" if @login.nil? || @login.empty? || @password.nil? || @password.empty?
|
27
|
+
end
|
25
28
|
real_connect
|
26
29
|
end
|
27
30
|
|
data/lib/contacts/gmail.rb
CHANGED
@@ -3,7 +3,7 @@ require 'gdata'
|
|
3
3
|
class Contacts
|
4
4
|
class Gmail < Base
|
5
5
|
|
6
|
-
CONTACTS_SCOPE = '
|
6
|
+
CONTACTS_SCOPE = 'https://www.google.com/m8/feeds/'
|
7
7
|
CONTACTS_FEED = CONTACTS_SCOPE + 'contacts/default/full/?max-results=1000'
|
8
8
|
|
9
9
|
def contacts
|
@@ -12,10 +12,27 @@ class Contacts
|
|
12
12
|
|
13
13
|
def real_connect
|
14
14
|
gclient = GData::Client::Contacts.new
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
|
16
|
+
if (@oauth_info)
|
17
|
+
gclient.oauth_info = @oauth_info
|
18
|
+
else
|
19
|
+
gclient.clientlogin(@login, @password, @captcha_token, @captcha_response)
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
response = gclient.get(CONTACTS_FEED)
|
24
|
+
rescue GData::Client::AuthorizationError
|
25
|
+
# if oauth fails, try username & password
|
26
|
+
if @oauth_info && @login && @password
|
27
|
+
gclient.clientlogin(@login, @password, @captcha_token, @captcha_response)
|
28
|
+
response = gclient.get(CONTACTS_FEED)
|
29
|
+
else
|
30
|
+
raise
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
feed = response.to_xml
|
35
|
+
|
19
36
|
@contacts = feed.elements.to_a('entry').collect do |entry|
|
20
37
|
title, email = entry.elements['title'].text, nil
|
21
38
|
entry.elements.each('gd:email') do |e|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yehezkielbs-contacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 15
|
10
|
+
version: 1.2.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lucas Carlson
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-
|
22
|
+
date: 2012-07-03 00:00:00 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: json
|
@@ -38,19 +38,19 @@ dependencies:
|
|
38
38
|
type: :runtime
|
39
39
|
version_requirements: *id001
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name: gdata
|
41
|
+
name: yehezkielbs-gdata
|
42
42
|
prerelease: false
|
43
43
|
requirement: &id002 !ruby/object:Gem::Requirement
|
44
44
|
none: false
|
45
45
|
requirements:
|
46
46
|
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
hash:
|
48
|
+
hash: 23
|
49
49
|
segments:
|
50
50
|
- 1
|
51
51
|
- 1
|
52
|
-
-
|
53
|
-
version: 1.1.
|
52
|
+
- 2
|
53
|
+
version: 1.1.2
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements: []
|
153
153
|
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.8.
|
155
|
+
rubygems_version: 1.8.24
|
156
156
|
signing_key:
|
157
157
|
specification_version: 3
|
158
158
|
summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.lt, seznam.cz, t-online.de
|