Sha256: b24e0206dd488f2e249656c128b78ed52a681256d267f4d17cdf0b65fd50371c
Contents?: true
Size: 824 Bytes
Versions: 1
Compression:
Stored size: 824 Bytes
Contents
module RubyHackernews class LoginService include MechanizeContext def login(username, password) page = agent.get(ConfigurationService.base_url) login_url = page.search(".pagetop/a").last['href'].sub("/","") login_page = agent.get(ConfigurationService.base_url + login_url) form = login_page.forms.first form.acct = username form.pw = password page = form.submit return page.title != nil end def logout require_authentication page = agent.get(ConfigurationService.base_url) login_url = page.search(".pagetop/a").last['href'].sub("/","") logout_page = agent.get(ConfigurationService.base_url + login_url) agent.cookie_jar.jar.clear return logout_page.search(".pagetop/a").last.inner_html == "login" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-hackernews-1.4.0 | lib/ruby-hackernews/services/login_service.rb |