Class: JiraCommand::Prompt::Base
- Inherits:
-
Object
- Object
- JiraCommand::Prompt::Base
- Defined in:
- lib/jira_command/prompt/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Sets the attribute config.
-
#prompt ⇒ Object
writeonly
Sets the attribute prompt.
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #select_board(message: 'Please select board', refresh: false) ⇒ Object
- #select_issue_type(message:, refresh: false) ⇒ Object
- #select_project(message:, refresh: false) ⇒ Object
- #select_sprint(message: 'Please select sprint:', board_id:, state: 'active,future') ⇒ Object
- #select_user(message:, project_key: nil, refresh: false, additional: []) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/jira_command/prompt/base.rb', line 12 def initialize @prompt = TTY::Prompt.new @config = JiraCommand::Config.new.read end |
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
Sets the attribute config
10 11 12 |
# File 'lib/jira_command/prompt/base.rb', line 10 def config=(value) @config = value end |
#prompt=(value) ⇒ Object (writeonly)
Sets the attribute prompt
10 11 12 |
# File 'lib/jira_command/prompt/base.rb', line 10 def prompt=(value) @prompt = value end |
Instance Method Details
#select_board(message: 'Please select board', refresh: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jira_command/prompt/base.rb', line 17 def select_board(message: 'Please select board', refresh: false) baord_list = if @config[:boards].nil? || refresh agile_board = JiraCommand::Jira::Board.new(@config) agile_board.list else @config[:boards] end @prompt.select() do || baord_list.each do |item| .choice name: item[:name], value: item[:id] end end end |
#select_issue_type(message:, refresh: false) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jira_command/prompt/base.rb', line 32 def select_issue_type(message:, refresh: false) issue_types = if @config[:issue_types].nil? || refresh jira_issue_type = JiraCommand::Jira::IssueType.new(@config) jira_issue_type.list else @config[:issue_types] end @prompt.select() do || issue_types.each do |item| .choice name: item[:name], value: { id: item[:id], name: item[:name] } end end end |
#select_project(message:, refresh: false) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jira_command/prompt/base.rb', line 47 def select_project(message:, refresh: false) projects = if @config[:projects].nil? || refresh jira_project = JiraCommand::Jira::Project.new(@config) jira_project.list else @config[:projects] end @prompt.select() do || projects.each do |item| .choice name: item[:name], value: { id: item[:id], key: item[:key] } end end end |
#select_sprint(message: 'Please select sprint:', board_id:, state: 'active,future') ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/jira_command/prompt/base.rb', line 83 def select_sprint(message: 'Please select sprint:', board_id:, state: 'active,future') jira_sprint = JiraCommand::Jira::Sprint.new(@config) res = jira_sprint.list( board_id: board_id, query: { state: state } ) @prompt.select() do || res.each do |item| .choice name: item[:name], value: item[:id] end end end |
#select_user(message:, project_key: nil, refresh: false, additional: []) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/jira_command/prompt/base.rb', line 62 def select_user(message:, project_key: nil, refresh: false, additional: []) user_list = if @config[:users].nil? || refresh user_api = JiraCommand::Jira::User.new(@config) user_api.all_list(project: project_key) else @config[:users] end @prompt.select() do || additional.each do |item| .choice name: item[:name], value: item[:account_id] end user_list.each do |item| .choice name: item[:name], value: item[:account_id] end end end |