Class: SetupWizard
- Inherits:
-
Object
- Object
- SetupWizard
- Defined in:
- lib/setup_wizard.rb
Overview
Setup wizard
Instance Method Summary collapse
-
#configure_jira_url ⇒ Object
Promts for the JIRA server url until user enters a valid value.
-
#configure_login_credentials ⇒ Object
Prompts for login credentials and executes login API call.
-
#configure_shift_end ⇒ Object
Promts for shift end until user enters a valid value.
-
#configure_shift_start ⇒ Object
Promts for shift start until user enters a valid value.
- #run ⇒ Object
Instance Method Details
#configure_jira_url ⇒ Object
Promts for the JIRA server url until user enters a valid value.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/setup_wizard.rb', line 36 def configure_jira_url loop do begin Configuration::ConfigurationManager .instance.update_jira_server_url prompt.ask("Please enter the JIRA Server URL:") break rescue LogworkException::InvalidURL Utilities.log("Invalid URL", { type: :error }) # Break in case of rspec Utilities.rspec_running? && break end end end |
#configure_login_credentials ⇒ Object
Prompts for login credentials and executes login API call.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/setup_wizard.rb', line 84 def configure_login_credentials # Clear saved cookie Utilities. account = prompt_for_account Utilities.log("Trying to login...") session = Communication::SessionManager.new(account) session.login(force: true) do Utilities.log("Success (#{session.myself[:full_name]}).", { type: :success }) end rescue LogworkException::InvalidCredentials Utilities.log("Invalid username or password.", { type: :error }) rescue LogworkException::APIResourceNotFound, LogworkException::NotSuccessStatusCode Utilities.log("Seems that you have entered an invalid JIRA Server URL.", { type: :error }) end |
#configure_shift_end ⇒ Object
Promts for shift end until user enters a valid value.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/setup_wizard.rb', line 67 def configure_shift_end loop do begin Configuration::ShiftConfiguration.new.update_shift_end( prompt.ask("What time is your shift finished? (24h format, e.g. 18:00):") ) break rescue LogworkException::InvalidTime Utilities.log("Invalid time format", { type: :error }) # Break in case of rspec Utilities.rspec_running? && break end end end |
#configure_shift_start ⇒ Object
Promts for shift start until user enters a valid value.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/setup_wizard.rb', line 51 def configure_shift_start loop do begin Configuration::ShiftConfiguration.new.update_shift_start( prompt.ask("What time is your shift started? (24h format, e.g. 10:00):") ) break rescue LogworkException::InvalidTime Utilities.log("Invalid time format", { type: :error }) # Break in case of rspec Utilities.rspec_running? && break end end end |