class Contacts::Mailru
Constants
- ADDRESS_BOOK_URL
- LOGIN_URL
Attributes
Public Instance Methods
contacts()
click to toggle source
# File lib/contacts/mailru.rb, line 30 def contacts postdata = "confirm=1&abtype=6" data, resp, cookies, forward = post(ADDRESS_BOOK_URL, postdata, login_cookies.join(';')) @contacts = [] CSV.parse(data) do |row| @contacts << [row[0], row[4]] unless header_row?(row) end @contacts end
real_connect()
click to toggle source
# File lib/contacts/mailru.rb, line 10 def real_connect username = login 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(login_token_link(data), login_cookies.join(';')) end
skip_gzip?()
click to toggle source
# File lib/contacts/mailru.rb, line 42 def skip_gzip? true end
Private Instance Methods
domain_param(login)
click to toggle source
# File lib/contacts/mailru.rb, line 59 def domain_param(login) login.include?('@') ? login.match(/.+@(.+)/)[1] : 'mail.ru' end
header_row?(row)
click to toggle source
# File lib/contacts/mailru.rb, line 55 def header_row?(row) row[0] == 'AB-Name' end
login_token_link(data)
click to toggle source
# File lib/contacts/mailru.rb, line 47 def login_token_link(data) data.match(/url=(.+)\">/)[1] end