Class: Speedflow::Plugin::Jira::Prompt
- Inherits:
-
Object
- Object
- Speedflow::Plugin::Jira::Prompt
- Defined in:
- lib/speedflow/plugin/jira/prompt.rb
Overview
Plugin prompt
Instance Attribute Summary collapse
-
#prompt ⇒ Object
Public: Prompt.
Instance Method Summary collapse
-
#errors(exception) ⇒ Object
Public: Errors from JIRA exception.
-
#issue(&issues) ⇒ Object
Public: Prompt issue.
-
#issue_type(issue_types) ⇒ Object
Public: Prompt issue type.
-
#method_missing(method, *args, &block) ⇒ Object
Delegate.
-
#project(projects) ⇒ Object
Public: Prompt project.
-
#title ⇒ Object
Public: Prompt title.
-
#transition(transitions) ⇒ Object
Public: Prompt transition.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Delegate
method - Method. args - Arguments. block - Block.
Returns wathever.
97 98 99 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 97 def method_missing(method, *args, &block) prompt.send(method, *args, &block) end |
Instance Attribute Details
Instance Method Details
#errors(exception) ⇒ Object
Public: Errors from JIRA exception.
exception - JIRA::HTTPError.
Returns nothing.
82 83 84 85 86 87 88 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 82 def errors(exception) if exception.response.respond_to?('body') response = ::JSON.parse(exception.response.body) response['errors'].each { |k, v| prompt.warn "- #{k}: #{v}" } response['errorMessages'].each { |v| prompt.warn "- #{v}" } end end |
#issue(&issues) ⇒ Object
Public: Prompt issue.
issues - Hash of issues from block.
Returns String key of issue.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 64 def issue(&issues) sel_issue = prompt.select('Choose the issue:') do || .choice 'Retry search!', :retry yield(title).each do |v| .choice "#{v.summary} (#{v.key})", v.key end end sel_issue = issue(&issues) if sel_issue == :retry sel_issue end |
#issue_type(issue_types) ⇒ Object
Public: Prompt issue type.
issue_types - List of issue types.
Returns ID of issue type.
37 38 39 40 41 42 43 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 37 def issue_type(issue_types) prompt.select('Choose the issue type:') do || issue_types.each do |issue_type| .choice "#{issue_type.name} (#{issue_type.id})", issue_type.id end end end |
#project(projects) ⇒ Object
Public: Prompt project.
projects - List of projects.
Returns String of project key.
24 25 26 27 28 29 30 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 24 def project(projects) prompt.select('Choose the project:') do || projects.each do |project| .choice "#{project.name} (#{project.key})", project.key end end end |
#title ⇒ Object
Public: Prompt title.
Returns String of title.
15 16 17 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 15 def title ask('What is the title of issue?', required: true) end |
#transition(transitions) ⇒ Object
Public: Prompt transition.
projects - List of transitions.
Returns String of status key.
50 51 52 53 54 55 56 57 |
# File 'lib/speedflow/plugin/jira/prompt.rb', line 50 def transition(transitions) prompt.select('Choose the transition:') do || transitions.each do |transition| .choice( "#{transition.name} (#{transition.id})", transition.id) end end end |