Class: Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/contacts/aol.rb,
lib/contacts/base.rb,
lib/contacts/sina.rb,
lib/contacts/sohu.rb,
lib/contacts/gmail.rb,
lib/contacts/plaxo.rb,
lib/contacts/yahoo.rb,
lib/contacts/hotmail.rb,
lib/contacts/net_ease.rb,
lib/contacts/json_picker.rb

Defined Under Namespace

Classes: Aol, AuthenticationError, Base, ConnectionError, ContactsError, Gmail, Hotmail, MailServerError, NetEase, Plaxo, Sina, Sohu, TypeNotFound, Yahoo

Constant Summary collapse

TYPES =
{}
VERSION =
"1.2.8"

Class Method Summary collapse

Class Method Details

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



223
224
225
226
227
228
229
230
231
# File 'lib/contacts/base.rb', line 223

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, options = {}) ⇒ Object



215
216
217
218
219
220
221
# File 'lib/contacts/base.rb', line 215

def self.new(type, , password, options={})
  if TYPES.include?(type.to_s.intern)
    TYPES[type.to_s.intern].new(, 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
16
# File 'lib/contacts/json_picker.rb', line 6

def self.parse_json( string )
  string = string.gsub("'",'"')
  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