class RubyTapasDownloader::Login
Perform Login
in Ruby Tapas.
Login
must be performed before any attempt to download files.
Attributes
agent[R]
@return [Mechanize] the Mechanize agent.
email[R]
@return [String] the e-mail for the user.
password[R]
@return [String] the password for the user.
Public Class Methods
new(agent, email, password)
click to toggle source
# File lib/ruby_tapas_downloader/login.rb, line 14 def initialize(agent, email, password) @agent = agent @email = email @password = password end
Public Instance Methods
login()
click to toggle source
Perform login.
# File lib/ruby_tapas_downloader/login.rb, line 21 def login RubyTapasDownloader.logger.info 'Logging in...' request_login_page fill_login_form submit_login_form end
Private Instance Methods
fill_login_form()
click to toggle source
# File lib/ruby_tapas_downloader/login.rb, line 34 def fill_login_form login_form.username = email login_form.password = password end
login_form()
click to toggle source
# File lib/ruby_tapas_downloader/login.rb, line 43 def login_form @page.forms.first end
request_login_page()
click to toggle source
# File lib/ruby_tapas_downloader/login.rb, line 30 def request_login_page @page = agent.get RubyTapasDownloader::Config.urls.fetch(:login) end
submit_login_form()
click to toggle source
# File lib/ruby_tapas_downloader/login.rb, line 39 def submit_login_form login_form.submit end