class Contacts

Constants

FILETYPES
TYPES
VERSION

Public Class Methods

guess(login, password, options={}) click to toggle source
# File lib/contacts/base.rb, line 217
def self.guess(login, password, options={})
  TYPES.inject([]) do |a, t|
    begin
      a + t[1].new(login, password, options).contacts
    rescue AuthenticationError
      a
    end
  end.uniq
end
new(type, login, password="", secret_key="", options={}) click to toggle source
# File lib/contacts/base.rb, line 204
def self.new(type, login, 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(login, password, options)
  elsif FILETYPES.include?(type.to_s.intern)
    FILETYPES[type.to_s.intern].new(login)
  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 ) click to toggle source
# 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