contacts 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +7 -0
- data/lib/contacts/base.rb +9 -7
- data/lib/contacts/gmail.rb +1 -1
- metadata +1 -1
data/README
CHANGED
@@ -26,6 +26,12 @@ For a long time, the only way to get a list of contacts from your free online em
|
|
26
26
|
|
27
27
|
Notice there are three ways to use this library so that you can limit the use as much as you would like in your particular application. The Contacts.guess method will automatically concatenate all the address book contacts from each of the successful logins in the case that a username password works across multiple services.
|
28
28
|
|
29
|
+
== Captcha error
|
30
|
+
|
31
|
+
If there are too many failed attempts with the gmail login info, Google will raise a captcha response. To integrate the captcha handling, pass in the token and response via:
|
32
|
+
|
33
|
+
Contacts::Gmail.new(login, password, :captcha_token => params[:captcha_token], :captcha_response => params[:captcha_response]).contacts
|
34
|
+
|
29
35
|
== Examples
|
30
36
|
|
31
37
|
See the examples/ directory.
|
@@ -45,6 +51,7 @@ See the examples/ directory.
|
|
45
51
|
* Glenn Ford (mailto:glenn@glennfu.com) - http://www.glennfu.com/
|
46
52
|
* Leonardo Wong (mailto:mac@boy.name)
|
47
53
|
* Rusty Burchfield
|
54
|
+
* justintv
|
48
55
|
|
49
56
|
This library is released under the terms of the BSD.
|
50
57
|
|
data/lib/contacts/base.rb
CHANGED
@@ -9,12 +9,14 @@ require "erb"
|
|
9
9
|
|
10
10
|
class Contacts
|
11
11
|
TYPES = {}
|
12
|
-
VERSION = "1.2.
|
12
|
+
VERSION = "1.2.3"
|
13
13
|
|
14
14
|
class Base
|
15
|
-
def initialize(login, password)
|
16
|
-
@login
|
15
|
+
def initialize(login, password, options={})
|
16
|
+
@login = login
|
17
17
|
@password = password
|
18
|
+
@captcha_token = options[:captcha_token]
|
19
|
+
@captcha_response = options[:captcha_response]
|
18
20
|
@connections = {}
|
19
21
|
connect
|
20
22
|
end
|
@@ -195,18 +197,18 @@ class Contacts
|
|
195
197
|
class TypeNotFound < ContactsError
|
196
198
|
end
|
197
199
|
|
198
|
-
def self.new(type, login, password)
|
200
|
+
def self.new(type, login, password, options={})
|
199
201
|
if TYPES.include?(type.to_s.intern)
|
200
|
-
TYPES[type.to_s.intern].new(login, password)
|
202
|
+
TYPES[type.to_s.intern].new(login, password, options)
|
201
203
|
else
|
202
204
|
raise TypeNotFound, "#{type.inspect} is not a valid type, please choose one of the following: #{TYPES.keys.inspect}"
|
203
205
|
end
|
204
206
|
end
|
205
207
|
|
206
|
-
def self.guess(login, password)
|
208
|
+
def self.guess(login, password, options={})
|
207
209
|
TYPES.inject([]) do |a, t|
|
208
210
|
begin
|
209
|
-
a + t[1].new(login, password).contacts
|
211
|
+
a + t[1].new(login, password, options).contacts
|
210
212
|
rescue AuthenticationError
|
211
213
|
a
|
212
214
|
end
|
data/lib/contacts/gmail.rb
CHANGED