bl 0.5.9 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc4abff96f8a62449194d70dd0537147d96c9d78
4
- data.tar.gz: 9616b4708482473c7aeae6406e841252d3afd13c
3
+ metadata.gz: 626f60af1ef5bbb4826c638651491678d100bc17
4
+ data.tar.gz: 9bb8afac7c45900cf10d422aef4c7d7a074e5551
5
5
  SHA512:
6
- metadata.gz: 392f184bce65f964f5cafe57b8ff7a077e8f376c42f76b005663bdad4889daebad6dda67435946a19b70d889bfea5eb6dc59aa0d38665b4c3724d248355f398a
7
- data.tar.gz: 49bfab3b810c0f1082e0a81cd269d0752b5aaca90f8b142dd4388e1ae06ec5045fa6ac1ca44ea7104d80e21c013ae1093f7d930babfd168c376358cbcc5b4528
6
+ metadata.gz: 799682459b708731fa859797a29177e4e88dce270862ec2248bb4ccce413241b4bcd49804fbed14da898b98076f1ed4d885f46837cb3bf79f699d0843975242e
7
+ data.tar.gz: 19330e9ba70afff70f7a34c0cae19cb14670212cdebc8ccd98bf533779213217cf6511f9e49dbf342137ada862dacb7a91a60738c6977763210422c7d46dfb02
@@ -77,44 +77,40 @@ module Bl
77
77
  end
78
78
  opts[:categoryId] = [-1] if options[:nocategory]
79
79
  res = client.get('issues', opts)
80
- print_issue_response(res)
80
+ print_issue_response(printable_issues(res.body))
81
81
  end
82
82
 
83
83
  desc 'search', 'search issues'
84
84
  options ISSUES_PARAMS
85
85
  def search
86
86
  res = client.get('issues', delete_class_options(options.to_h))
87
- print_issue_response(res)
87
+ print_issue_response(printable_issues(res.body))
88
88
  end
89
89
 
90
90
  desc 'show KEY', "show an issue's details"
91
91
  def show(key)
92
- body = client.get("issues/#{key}").body
93
- puts "id: #{body.id}"
94
- puts "type: #{body.issueType.name}"
95
- puts "key: #{body.issueKey}"
96
- puts "created: #{body.created}"
97
- puts "due date: #{body.dueDate}"
98
- puts "summary: #{body.summary}"
99
- puts "priority: #{body.priority.name}"
100
- puts "category: #{body.category}"
101
- puts "resolution: #{body.resolution}"
102
- puts "version: #{body.versions}"
103
- puts "status: #{body.status.name}"
104
- puts "milestone: #{body.milestone}"
105
- puts "assignee: #{body.assignee&.name}"
106
- puts "created user: #{body.createdUser.name}"
92
+ res = client.get("issues/#{key}")
93
+ body = printable_issues(res.body)
94
+ additional_fileds = %w(
95
+ description
96
+ category
97
+ resolution
98
+ versions
99
+ milestone
100
+ createdUser
101
+ )
102
+ fields = ISSUE_FIELDS.concat(additional_fileds)
103
+ puts formatter.render(body, fields: fields, vertical: true)
104
+
107
105
  puts '--'
108
- puts "description:"
109
- puts body.description
110
106
  puts "attachments:"
111
- body.attachments.each do |file|
107
+ body[0].attachments.each do |file|
112
108
  puts ['-', file.id, file.name, file.size].join("\t")
113
109
  puts "\tview url: https://#{@config[:space_id]}.backlog.jp/ViewAttachment.action?attachmentId=#{file.id}"
114
110
  puts "\tdownload url: https://#{@config[:space_id]}.backlog.jp/downloadAttachment/#{file.id}/#{file.name}"
115
111
  end
116
112
  puts "shared files:"
117
- body.sharedFiles.each do |file|
113
+ body[0].sharedFiles.each do |file|
118
114
  puts ['-', file.id, file.name, file.size].join("\t")
119
115
  puts "\tfile url: https://#{@config[:space_id]}.backlog.jp/ViewSharedFile.action?projectKey=#{@config[:project_key]}&sharedFileId=#{file.id}"
120
116
  end
@@ -136,7 +132,7 @@ module Bl
136
132
  issue_default_options.merge({summary: s}).merge(delete_class_options(options.to_h))
137
133
  )
138
134
  puts '💡 issue added'
139
- print_issue_response(res)
135
+ print_issue_response(printable_issues(res.body))
140
136
  end
141
137
  end
142
138
 
@@ -147,7 +143,7 @@ module Bl
147
143
  keys.each do |k|
148
144
  res = client.patch("issues/#{k}", delete_class_options(options.to_h))
149
145
  puts 'issue updated'
150
- print_issue_response(res)
146
+ print_issue_response(printable_issues(res.body))
151
147
  end
152
148
  end
153
149
 
@@ -156,7 +152,7 @@ module Bl
156
152
  keys.each do |k|
157
153
  res = client.patch("issues/#{k}", statusId: 4)
158
154
  puts '🎉 issue closed'
159
- print_issue_response(res)
155
+ print_issue_response(printable_issues(res.body))
160
156
  end
161
157
  end
162
158
 
@@ -246,7 +242,20 @@ module Bl
246
242
  private
247
243
 
248
244
  def print_issue_response(res)
249
- puts formatter.render(res.body, fields: ISSUE_FIELDS)
245
+ puts formatter.render(res, fields: ISSUE_FIELDS)
246
+ end
247
+
248
+ def printable_issues(ary)
249
+ ary = Array(ary)
250
+ ary.each do |v|
251
+ v.issueType = v.issueType.name
252
+ v.assignee = v.assignee.name if v.assignee
253
+ v.status = v.status.name
254
+ v.priority = v.priority.name
255
+ v.created = format_datetime(v.created)
256
+ v.updated = format_datetime(v.updated)
257
+ end
258
+ ary
250
259
  end
251
260
  end
252
261
  end
@@ -52,8 +52,12 @@ module Bl
52
52
  assigneeId: :numeric
53
53
  }
54
54
  ISSUE_FIELDS = %i(
55
+ issueType
55
56
  issueKey
56
57
  summary
58
+ assignee
59
+ status
60
+ priority
57
61
  startDate
58
62
  dueDate
59
63
  created
@@ -132,7 +136,6 @@ module Bl
132
136
  created
133
137
  updated
134
138
  )
135
- TPUT_COLS = `tput cols`.to_i
136
139
  TYPE_COLORS = %w(
137
140
  #e30000
138
141
  #934981
@@ -184,5 +187,9 @@ module Bl
184
187
  opts.map { |opt| h.delete(opt) }
185
188
  h
186
189
  end
190
+
191
+ def format_datetime(str)
192
+ DateTime.parse(str).strftime('%Y-%m-%d %H:%M')
193
+ end
187
194
  end
188
195
  end
@@ -80,7 +80,7 @@ module Bl
80
80
  private
81
81
 
82
82
  def print_response(res)
83
- formatter.render(res.body, fields: USER_FIELDS)
83
+ puts formatter.render(res.body, fields: USER_FIELDS)
84
84
  end
85
85
  end
86
86
  end
@@ -1,3 +1,3 @@
1
1
  module Bl
2
- VERSION = '0.5.9'.freeze
2
+ VERSION = '0.5.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - saki