Class: Jirack::Command
- Inherits:
-
Thor
- Object
- Thor
- Jirack::Command
- Defined in:
- lib/jirack/command.rb
Instance Method Summary collapse
- #assign(issue_number) ⇒ Object
- #back(issue_number) ⇒ Object
- #config ⇒ Object
- #forward(issue_number) ⇒ Object
- #list ⇒ Object
- #notify(issue_number) ⇒ Object
- #open(issue_number) ⇒ Object
Instance Method Details
#assign(issue_number) ⇒ Object
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/jirack/command.rb', line 139 def assign(issue_number) cred = Jirack::Credential.new client = cred.jira_client issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }") myself = JIRA::Resource::UserFactory.new(client).myself client.put("/rest/api/2/issue/#{ issue.key }/assignee", { name: myself.name }.to_json) end |
#back(issue_number) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/jirack/command.rb', line 88 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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/jirack/command.rb', line 64 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jirack/command.rb', line 40 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?('unassign') puts "#{ active_sprint['name'] } unassign issues: " active_unassign_issue(client, cred.project_name, active_sprint['name']).each do |issue| puts "#{ issue.key }: #{ issue.summary }(#{issue.id}) [#{ issue.points }] #{ issue.status.name } " end elsif .key?('sum-point') sum_points = active_assign_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_assign_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
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/jirack/command.rb', line 112 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
128 129 130 131 132 133 134 135 136 |
# File 'lib/jirack/command.rb', line 128 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 |