lib/lita/handlers/jira.rb in lita-jira-0.4.0 vs lib/lita/handlers/jira.rb in lita-jira-0.5.0

- old
+ new

@@ -32,22 +32,31 @@ t('help.details.syntax') => t('help.details.desc') } ) route( - /^jira\scomment\son\s#{ISSUE_PATTERN}\s"(?<comment>.+)"$/, + /^jira\scomment\son\s#{ISSUE_PATTERN}\s#{COMMENT_PATTERN}$/, :comment, command: true, help: { t('help.comment.syntax') => t('help.comment.desc') } ) + route( + /^todo\s#{PROJECT_PATTERN}\s#{SUBJECT_PATTERN}(\s#{SUMMARY_PATTERN})?$/, + :todo, + command: true, + help: { + t('help.todo.syntax') => t('help.todo.desc') + } + ) + def summary(response) issue = fetch_issue(response.match_data['issue']) return response.reply(t('error.request')) unless issue - response.reply("#{issue.key}: #{issue.summary}") + response.reply(t('issue.summary', key: issue.key, summary: issue.summary)) end def details(response) issue = fetch_issue(response.match_data['issue']) return response.reply(t('error.request')) unless issue @@ -58,9 +67,17 @@ issue = fetch_issue(response.match_data['issue']) return response.reply(t('error.request')) unless issue comment = issue.comments.build comment.save!(body: response.match_data['comment']) response.reply(t('comment.added', issue: issue.key)) + end + + def todo(response) + issue = create_issue(response.match_data['project'], + response.match_data['subject'], + response.match_data['summary']) + return response.reply(t('error.request')) unless issue + response.reply(t('issue.created', key: issue.key)) end end Lita.register_handler(Jira) end