Class: Jirack::Command
- Inherits:
-
Thor
- Object
- Thor
- Jirack::Command
- Defined in:
- lib/jirack/command.rb
Instance Method Summary collapse
- #back(issue_number) ⇒ Object
- #config ⇒ Object
- #forward(issue_number) ⇒ Object
- #list ⇒ Object
- #notify(issue_number) ⇒ Object
- #open(issue_number) ⇒ Object
Instance Method Details
#back(issue_number) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/jirack/command.rb', line 82 def back(issue_number) cred = Jirack::Credential.new client = cred.jira_client issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }", { extend: 'transitions' }) next_status = issue.status.next_status(client, cred.workflow_ids) next_transition = issue.transitions.all.find {|transition| transition.to.id != next_status.id } transition = JIRA::Resource::Transition.new(client, :attrs => {id: next_transition.id }, :issue_id => issue.id) transition.save(transition: { id: next_transition.id }) # slack に通知 if .key? : slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }" end puts "#{ cred.project_name }-#{ issue_number } back to #{ next_transition.to.name }" end |
#config ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jirack/command.rb', line 13 def config cred = Jirack::Credential.new host = ask "input host (ex. 'mydomain.atlassian.net') #{ cred.host&.empty? ? '' : "(#{cred.host})" }:" cred.host = host unless host.empty? project_name = ask "input project name #{ cred.project_name&.empty? ? '' : "(#{cred.project_name})" }:" cred.project_name = project_name unless project_name.empty? username = ask "input user name #{ cred.username&.empty? ? '' : "(#{cred.username})" }:" cred.username = username unless username.empty? password = ask '(required!)input password:', echo: false cred.password = password puts '' slack_webhook_url = ask "input slack webhook urk #{ cred.slack_webhook_url&.empty? ? '' : "(#{cred.slack_webhook_url})" }:" cred.slack_webhook_url = slack_webhook_url unless slack_webhook_url.empty? cred.store end |
#forward(issue_number) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jirack/command.rb', line 58 def forward(issue_number) cred = Jirack::Credential.new client = cred.jira_client issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }", { extend: 'transitions' }) next_status = issue.status.next_status(client, cred.workflow_ids) next_transition = issue.transitions.all.find {|transition| transition.to.id == next_status.id } transition = JIRA::Resource::Transition.new(client, :attrs => {id: next_transition.id }, :issue_id => issue.id) transition.save(transition: { id: next_transition.id }) # slack に通知 if .key? : slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }" end puts "#{ cred.project_name }-#{ issue_number } forward to #{ next_transition.to.name }" end |
#list ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jirack/command.rb', line 39 def list cred = Jirack::Credential.new client = cred.jira_client active_sprint = active_sprint(client, project_board(client, cred.project_name)['id'].to_i) if .key?('sum-point') sum_points = active_sprint_issue(client, cred.project_name, active_sprint['name']).inject(0.0) {|sum, issue| sum + issue.points } puts "#{ active_sprint['name'] } points: #{ sum_points }" else puts "#{ active_sprint['name'] } issues: " active_sprint_issue(client, cred.project_name, active_sprint['name']).each do |issue| puts "#{ issue.key }: #{ issue.summary }(#{issue.id}) [#{ issue.points }] #{ issue.status.name } " end end end |
#notify(issue_number) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/jirack/command.rb', line 106 def notify(issue_number) cred = Jirack::Credential.new client = cred.jira_client issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }") # slack に通知 if .key? : slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }" end puts "#{ cred.project_name }-#{ issue_number } notify slack" end |
#open(issue_number) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/jirack/command.rb', line 122 def open(issue_number) cred = Jirack::Credential.new client = cred.jira_client issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }") Launchy.open issue_url(issue) end |