Class: Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/contacts/vcf.rb,
lib/contacts/base.rb,
lib/contacts/gmail.rb,
lib/contacts/plaxo.rb,
lib/contacts/yahoo.rb,
lib/contacts/hotmail.rb,
lib/contacts/outlook.rb,
lib/contacts/json_picker.rb,
lib/contacts/aol_importer.rb

Defined Under Namespace

Classes: AolImporter, AuthenticationError, Base, CaptchaError, ConnectionError, ContactsError, Gmail, Hotmail, Outlook, Plaxo, TypeNotFound, Vcf, Yahoo

Constant Summary collapse

TYPES =
{}
FILETYPES =
{}

Class Method Summary collapse

Class Method Details

.guess(login, password, options = {}) ⇒ Object



210
211
212
213
214
215
216
217
218
# File 'lib/contacts/base.rb', line 210

def self.guess(, password, options={})
  TYPES.inject([]) do |a, t|
    begin
      a + t[1].new(, password, options).contacts
    rescue AuthenticationError
      a
    end
  end.uniq
end

.new(type, login, password = "", secret_key = "", options = {}) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/contacts/base.rb', line 197

def self.new(type, , password="", secret_key="", options={})
  if !password.nil? && password != ''  && !secret_key.nil? && secret_key != ''
    password = Encryptor.decrypt(URI.unescape(password), :key => secret_key)
  end
  if TYPES.include?(type.to_s.intern)
    TYPES[type.to_s.intern].new(, password, options)
  elsif FILETYPES.include?(type.to_s.intern)
    FILETYPES[type.to_s.intern].new()
  else
    raise TypeNotFound, "#{type.inspect} is not a valid type, please choose one of the following: #{TYPES.keys.inspect} or #{FILETYPES.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