Class: Contacts
- Inherits:
-
Object
show all
- Defined in:
- lib/contacts/aol.rb,
lib/contacts/gmx.rb,
lib/contacts/base.rb,
lib/contacts/gmail.rb,
lib/contacts/onelt.rb,
lib/contacts/plaxo.rb,
lib/contacts/yahoo.rb,
lib/contacts/mailru.rb,
lib/contacts/seznam.rb,
lib/contacts/web_de.rb,
lib/contacts/hotmail.rb,
lib/contacts/inbox_lt.rb,
lib/contacts/tonline_de.rb,
lib/contacts/json_picker.rb
Defined Under Namespace
Classes: Aol, AuthenticationError, Base, ConnectionError, ContactsError, Gmail, Gmx, Hotmail, InboxLt, Mailru, Onelt, Plaxo, Seznam, TonlineDe, TypeNotFound, WebDe, Yahoo
Constant Summary
collapse
- TYPES =
{}
Class Method Summary
collapse
Class Method Details
.get_email_domain(email) ⇒ Object
217
218
219
220
|
# File 'lib/contacts/base.rb', line 217
def self.get_email_domain(email)
name, domain = email.split('@')
domain
end
|
.guess(email, password, options = {}) ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/contacts/base.rb', line 235
def self.guess(email, password, options={})
klass = guess_importer(email, options)
return if klass.nil?
a = []
begin
a = klass.new(email, password, options).contacts
rescue AuthenticationError
end
return a
end
|
.guess_importer(email, options = {}) ⇒ Object
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/contacts/base.rb', line 222
def self.guess_importer(email, options={})
if keys = options[:types]
types = TYPES.select{|k, v| keys.include?(k)}
end
types ||= TYPES
email_domain = get_email_domain(email)
types.values.find do |klass|
klass::DETECTED_DOMAINS.any? { |m| email_domain.to_s.match(m) }
end
end
|
.new(type, login, password, options = {}) ⇒ Object
209
210
211
212
213
214
215
|
# File 'lib/contacts/base.rb', line 209
def self.new(type, login, password, options={})
if TYPES.include?(type.to_s.intern)
TYPES[type.to_s.intern].new(login, password, options)
else
raise TypeNotFound, "#{type.inspect} is not a valid type, please choose one of the following: #{TYPES.keys.inspect}"
end
end
|
.parse_json(string) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/contacts/json_picker.rb', line 6
def self.parse_json( string )
if Object.const_defined?('ActiveSupport') and
ActiveSupport.const_defined?('JSON')
ActiveSupport::JSON.decode( string )
elsif Object.const_defined?('JSON')
JSON.parse( string )
else
raise 'Contacts requires JSON or Rails (with ActiveSupport::JSON)'
end
end
|