Module: JiraHelper::Issue
- Included in:
- Lita::Handlers::Jira, Lita::Handlers::JiraUtility
- Defined in:
- lib/jirahelper/issue.rb
Overview
Issues
Instance Method Summary collapse
- #create_issue(project, subject, summary) ⇒ Object
- #fetch_issue(key, expected = true) ⇒ Object
-
#fetch_issues(jql) ⇒ Type Array
Leverage the jira-ruby Issue.jql search feature.
- #fetch_project(key) ⇒ Object
-
#format_issue(issue) ⇒ Object
NOTE: Not breaking this function out just yet.
- #format_issue_link(key) ⇒ Object
-
#format_issues(issues) ⇒ Type Array<String>
Enumerate issues returned from JQL query and format for response.
-
#optional_issue_property(fallback = '') ⇒ Type String
Attempt to retrieve optional JIRA issue property value via a provided block.
Instance Method Details
#create_issue(project, subject, summary) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/jirahelper/issue.rb', line 54 def create_issue(project, subject, summary) project = fetch_project(project) return nil unless project issue = client.Issue.build issue.save(fields: { subject: subject, summary: summary, project: { id: project.id } }) issue.fetch issue end |
#fetch_issue(key, expected = true) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/jirahelper/issue.rb', line 5 def fetch_issue(key, expected = true) client.Issue.find(key) rescue log.error('JIRA HTTPError') if expected nil end |
#fetch_issues(jql) ⇒ Type Array
Leverage the jira-ruby Issue.jql search feature
16 17 18 |
# File 'lib/jirahelper/issue.rb', line 16 def fetch_issues(jql) client.Issue.jql(jql) end |
#fetch_project(key) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/jirahelper/issue.rb', line 20 def fetch_project(key) client.Project.find(key) rescue log.error('JIRA HTTPError') nil end |
#format_issue(issue) ⇒ Object
NOTE: Not breaking this function out just yet. rubocop:disable Metrics/AbcSize
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jirahelper/issue.rb', line 29 def format_issue(issue) t(config.format == 'one-line' ? 'issue.oneline' : 'issue.details', key: issue.key, summary: issue.summary, status: issue.status.name, assigned: optional_issue_property('unassigned') { issue.assignee.displayName }, fixVersion: optional_issue_property('none') { issue.fixVersions.first['name'] }, priority: optional_issue_property('none') { issue.priority.name }, url: format_issue_link(issue.key)) end |
#format_issue_link(key) ⇒ Object
50 51 52 |
# File 'lib/jirahelper/issue.rb', line 50 def format_issue_link(key) "#{config.site}#{config.context}/browse/#{key}" end |
#format_issues(issues) ⇒ Type Array<String>
Enumerate issues returned from JQL query and format for response
45 46 47 48 |
# File 'lib/jirahelper/issue.rb', line 45 def format_issues(issues) results = [t('myissues.info')] results.concat(issues.map { |issue| format_issue(issue) }) end |
#optional_issue_property(fallback = '') ⇒ Type String
Attempt to retrieve optional JIRA issue property value via a provided block. JIRA properties such as assignee and priority may not exist. In that case, the fallback will be used.
71 72 73 74 75 |
# File 'lib/jirahelper/issue.rb', line 71 def optional_issue_property(fallback = '') yield rescue fallback end |