Class: Contacts::Mailru

Inherits:
Base
  • Object
show all
Defined in:
lib/contacts/mailru.rb

Constant Summary collapse

LOGIN_URL =
"https://auth.mail.ru/cgi-bin/auth"
ADDRESS_BOOK_URL =
"http://win.mail.ru/cgi-bin/abexport/addressbook.csv"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#connect, #connected?, #initialize, #login, #password

Constructor Details

This class inherits a constructor from Contacts::Base

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



8
9
10
# File 'lib/contacts/mailru.rb', line 8

def cookies
  @cookies
end

Instance Method Details

#contactsObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/contacts/mailru.rb', line 30

def contacts
  postdata = "confirm=1&abtype=6"
  data, resp, cookies, forward = post(ADDRESS_BOOK_URL, postdata, .join(';'))

  @contacts = []
  CSV.parse(data) do |row|
    @contacts << [row[0], row[4]] unless header_row?(row)
  end

  @contacts
end

#real_connectObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/contacts/mailru.rb', line 10

def real_connect
  username = 
  
  postdata =  "Login=%s&Domain=%s&Password=%s" % [
    CGI.escape(username),
    CGI.escape(domain_param(username)),
    CGI.escape(password)
  ]

  data, resp, self.cookies, forward = post(LOGIN_URL, postdata, "")

  if data.index("fail=1")
    raise AuthenticationError, "Username and password do not match"
  elsif cookies == "" or data == ""
    raise ConnectionError, PROTOCOL_ERROR
  end

  data, resp, cookies, forward = get((data), .join(';'))
end

#skip_gzip?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/contacts/mailru.rb', line 42

def skip_gzip?
  true
end