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.



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

def cookies
  @cookies
end

Instance Method Details

#contactsObject



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

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



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

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)


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

def skip_gzip?
  true
end