jirack 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2bcac42459a795dec1c3d02d68bf2084f9858ff
4
- data.tar.gz: 857462e79a8c78f02fdd0fabd55f743462869d93
3
+ metadata.gz: f5e435247e8d64d5c82ec1b4c18ea5752f65a333
4
+ data.tar.gz: 488e87a597e2fe842ef11980ff03d6cad878c55c
5
5
  SHA512:
6
- metadata.gz: d0a15d071c942a28652032954146ad41adc8326c7088e741fd8ace12cfc98e62471cbdfe78597a3dc7de9ddf93a8f4a37385dfd7f296e094f4e5cc629588f0fa
7
- data.tar.gz: 0d1226b89dcbb396774b768a3f8dd8730d457e5ea6cf62461b5143d0c9bc294232596d0bda0f4a19a9c951b7245de2ae44acb630c7d0a28d6b1f168724e3a5f6
6
+ metadata.gz: 77a0d34286e75265e79641e65ab37cf27d20d9bf66b919e8ff660be727ea7361173ee50370326f0c7e6eebefb440e1d92933dfe7d0d746aa0e9b56a75f513503
7
+ data.tar.gz: 4c38fac8b74a48747aab79807b91bd594790b2562f6540a9ec6b1c90a2bb0578c4a5ce01f89a8a4c4ebd38956e2857a7abf453c873db541827d3c658817af03c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jirack (0.2.0)
4
+ jirack (0.3.0)
5
5
  jira-ruby
6
6
  launchy
7
7
  slack-incoming-webhooks
@@ -35,7 +35,8 @@ module Jirack
35
35
  end
36
36
 
37
37
  desc 'list', 'show your active issue'
38
- method_option 'unassign', type: :boolean, aliases: '-u', desc: 'show your all issue point'
38
+ method_option 'all', type: :boolean, aliases: '-a', desc: 'show all issue'
39
+ method_option 'unassign', type: :boolean, aliases: '-u', desc: 'show all unassign issue'
39
40
  method_option 'sum-point', type: :boolean, aliases: '-n', desc: 'show your all issue point'
40
41
  def list
41
42
  cred = Jirack::Credential.new
@@ -46,15 +47,22 @@ module Jirack
46
47
  if options.key?('unassign')
47
48
  puts "#{ active_sprint['name'] } unassign issues: "
48
49
  active_unassign_issue(client, cred.project_name, active_sprint['name']).each do |issue|
49
- puts "#{ issue.key }: #{ issue.summary }(#{issue.id}) [#{ issue.points }] #{ issue.status.name } "
50
+ puts "%s %s %4.1f %s" % [issue.key, mb_rjust(issue.status.name, 25), issue.points, issue.summary]
50
51
  end
52
+
51
53
  elsif options.key?('sum-point')
52
54
  sum_points = active_assign_issue(client, cred.project_name, active_sprint['name']).inject(0.0) {|sum, issue| sum + issue.points }
53
55
  puts "#{ active_sprint['name'] } points: #{ sum_points }"
56
+
57
+ elsif options.key?('all')
58
+ puts "#{ active_sprint['name'] } issues: "
59
+ active_sprint_issue(client, cred.project_name, active_sprint['name']).each do |issue|
60
+ puts "%s % 18s %s %4.1f %s" % [issue.key, issue.assign_user_name, mb_rjust(issue.status.name, 25), issue.points, issue.summary]
61
+ end
54
62
  else
55
63
  puts "#{ active_sprint['name'] } issues: "
56
64
  active_assign_issue(client, cred.project_name, active_sprint['name']).each do |issue|
57
- puts "#{ issue.key }: #{ issue.summary }(#{issue.id}) [#{ issue.points }] #{ issue.status.name } "
65
+ puts "%s %s %4.1f %s" % [issue.key, mb_rjust(issue.status.name, 25), issue.points, issue.summary]
58
66
  end
59
67
  end
60
68
  end
@@ -74,13 +82,15 @@ module Jirack
74
82
  transition = JIRA::Resource::Transition.new(client, :attrs => {id: next_transition.id }, :issue_id => issue.id)
75
83
  transition.save(transition: { id: next_transition.id })
76
84
 
85
+
86
+ puts "#{ cred.project_name }-#{ issue_number } forward to #{ next_transition.to.name }"
87
+
77
88
  # slack に通知
78
89
  if options.key? :message
79
90
  slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url
80
91
  slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
92
+ puts "@#{ issue.reporter.name } #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
81
93
  end
82
-
83
- puts "#{ cred.project_name }-#{ issue_number } forward to #{ next_transition.to.name }"
84
94
  end
85
95
 
86
96
  desc 'back issue_number', 'back issue status'
@@ -98,16 +108,18 @@ module Jirack
98
108
  transition = JIRA::Resource::Transition.new(client, :attrs => {id: next_transition.id }, :issue_id => issue.id)
99
109
  transition.save(transition: { id: next_transition.id })
100
110
 
111
+ puts "#{ cred.project_name }-#{ issue_number } back to #{ next_transition.to.name }"
112
+
101
113
  # slack に通知
102
114
  if options.key? :message
103
115
  slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url
104
116
  slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
117
+ puts "@#{ issue.reporter.name } #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
105
118
  end
106
-
107
- puts "#{ cred.project_name }-#{ issue_number } back to #{ next_transition.to.name }"
108
119
  end
109
120
 
110
121
  desc 'notify issue_number', 'notify issue message'
122
+ method_option 'silent', :aliases => '-s', type: :boolean, desc: 'not notify slack '
111
123
  method_option 'message', :aliases => '-m', required: true, desc: 'notify slack message'
112
124
  def notify(issue_number)
113
125
  cred = Jirack::Credential.new
@@ -116,12 +128,12 @@ module Jirack
116
128
  issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }")
117
129
 
118
130
  # slack に通知
119
- if options.key? :message
131
+ if options.key?(:message) && !options.key?(:silent)
120
132
  slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url
121
133
  slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
122
134
  end
123
135
 
124
- puts "#{ cred.project_name }-#{ issue_number } notify slack"
136
+ puts "@#{ issue.reporter.name } #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
125
137
  end
126
138
 
127
139
  desc 'open issue_number', 'open browser issue page'
@@ -165,9 +177,19 @@ module Jirack
165
177
  JIRA::Resource::Issue.jql(client, "project=\"#{ project_name }\" AND assignee = NULL AND cf[10007] = \"#{ sprint_name }\"")
166
178
  end
167
179
 
180
+ def active_sprint_issue(client, project_name, sprint_name)
181
+ JIRA::Resource::Issue.jql(client, "project=\"#{ project_name }\" AND cf[10007] = \"#{ sprint_name }\" ORDER BY assignee")
182
+ end
183
+
168
184
  def issue_url(issue)
169
185
  uri = URI.parse(issue.self)
170
186
  "https://#{ uri.host }/browse/#{ issue.key }"
171
187
  end
188
+
189
+ def mb_rjust(string, width, padding=' ')
190
+ output_width = string.each_char.map{|c| c.bytesize == 1 ? 1 : 2}.reduce(0, &:+)
191
+ padding_size = [0, width - output_width].max
192
+ padding * padding_size + string
193
+ end
172
194
  end
173
195
  end
@@ -16,6 +16,11 @@ module Jirack
16
16
  self.key.split('-')[1].to_i
17
17
  end
18
18
 
19
+ def assign_user_name
20
+ self.assignee&.name&.split('@')&.first
21
+ end
22
+
23
+
19
24
  private
20
25
 
21
26
 
@@ -1,3 +1,3 @@
1
1
  module Jirack
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jirack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rhythm191
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler