Class: Menu::Config
Overview
MenuConfig handlers
Instance Method Summary collapse
- #create_input_map ⇒ Object
- #create_procs_map ⇒ Object
-
#print_config_value(value) ⇒ Object
rubocop:enable Metrics/AbcSize.
-
#run_list ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#set_shift_end ⇒ Object
Set shift end time.
-
#set_shift_start ⇒ Object
Set shift start time.
-
#set_url ⇒ Object
Set JIRA URL.
Methods inherited from Base
#initialize, #run_default, #run_selected_command
Constructor Details
This class inherits a constructor from Menu::Base
Instance Method Details
#create_input_map ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/menu/config.rb', line 34 def create_input_map { url: [:url], shift_start: [:shift_start], shift_end: [:shift_end], list: [:list] } end |
#create_procs_map ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/menu/config.rb', line 25 def create_procs_map { url: proc { set_url }, shift_start: proc { set_shift_start }, shift_end: proc { set_shift_end }, list: proc { run_list } } end |
#print_config_value(value) ⇒ Object
rubocop:enable Metrics/AbcSize
79 80 81 82 83 |
# File 'lib/menu/config.rb', line 79 def print_config_value(value) puts "#{value[:key]}=#{value[:value].call}" rescue LogworkException::ConfigurationValueNotFound puts "#{value[:key]}=[not-set]" end |
#run_list ⇒ Object
rubocop:disable Metrics/AbcSize
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/menu/config.rb', line 66 def run_list values = [ { key: :url, value: proc { Configuration::ConfigurationManager.instance.jira_server_url } }, { key: :shift_start, value: proc { ShiftConfiguration.new.shift_start } }, { key: :shift_end, value: proc { ShiftConfiguration.new.shift_end } }, { key: :username, value: proc { CredentialsConfiguration.new.login_credentials.username } }, { key: :password, value: proc { CredentialsConfiguration.new.login_credentials.password.nil? ? nil : "****" } } ] values.each { |v| print_config_value(v) } end |
#set_shift_end ⇒ Object
Set shift end time.
58 59 60 61 62 |
# File 'lib/menu/config.rb', line 58 def set_shift_end ShiftConfiguration.new.update_shift_end([:shift_end]) rescue LogworkException::InvalidTime Utilities.log("Invalid end time format.", { type: :error }) end |
#set_shift_start ⇒ Object
Set shift start time.
51 52 53 54 55 |
# File 'lib/menu/config.rb', line 51 def set_shift_start ShiftConfiguration.new.update_shift_start([:shift_start]) rescue LogworkException::InvalidTime Utilities.log("Invalid starttime format.", { type: :error }) end |
#set_url ⇒ Object
Set JIRA URL.
44 45 46 47 48 |
# File 'lib/menu/config.rb', line 44 def set_url Configuraiton::ConfigurationManager.instance.update_jira_server_url([:url]) rescue LogworkException::InvalidURL Utilities.log("Invalid JIRA server URL.", { type: :error }) end |