bl 0.5.2 → 0.5.3

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: 45be41d8aefab74ca033976af77670a3d80509cc
4
- data.tar.gz: ad8cfa27ddd7d1687b6e32eba423db290a4c4022
3
+ metadata.gz: d20d3678c35119bbab68027cdd10ba5dc75e4490
4
+ data.tar.gz: cb4a885c2d366087ae8533344f307a1750cdd215
5
5
  SHA512:
6
- metadata.gz: 413732648dbd6df0714f5e94f54ff023d9ca85d4108335bbb94dd89d1fa5d9c02a9a4c7fc6e102b675929c298eec88402ec58d4afc80cc6ef42592b860f8d712
7
- data.tar.gz: bd4c258f3d7e8ff0b4e6cee0a5c87061f6ae24d194273072f18b5433f6a7daed91e64d82a363675da7633715dc6946ad6ef57ef6bd43f3be2e75ce14bc7a9329
6
+ metadata.gz: 57a13bd38a912c91c9be4deab150196c983d966ce5cfa3c4113c30b390a8a787b62df9b70af9744a9af20b8bbe31e3604ff1207c7580b91acf1c9e8e3c5cf93b
7
+ data.tar.gz: 65a669111cee35f1719aafd872c489c5b7ad0b6fdf71c6ca4a3d28dd0649c3bde9a6d686c89633b4f7b1c7bc21f1d769efa5ed046bd8bf455db6ef6d28a98d17
data/README.md CHANGED
@@ -70,6 +70,7 @@ Commands:
70
70
  bl project SUBCOMMAND ...ARGS # manage projects
71
71
  bl recent SUBCOMMAND ...ARGS # list recent stuff
72
72
  bl resolutions # list resolutions
73
+ bl roles # list roles
73
74
  bl search # search issues
74
75
  bl show KEY # show an issue's details
75
76
  bl space SUBCOMMAND ...ARGS #
@@ -121,6 +122,13 @@ Edit issue by your favorite $EDITOR:
121
122
 
122
123
  bl edit ISSUE-12
123
124
 
125
+ ### Milestone
126
+
127
+ Add an milestone:
128
+
129
+ bl milestone add m1 --releaseDueDate=2017-04-01
130
+
131
+
124
132
  ### Project
125
133
 
126
134
  List projects:
data/Rakefile CHANGED
@@ -53,3 +53,40 @@ EOS
53
53
  end
54
54
  end
55
55
  end
56
+
57
+ desc 'system test'
58
+ task :system_test do
59
+ ret = true
60
+ commands = [
61
+ 'category list',
62
+ 'config',
63
+ 'count',
64
+ 'file list',
65
+ 'gitrepo list',
66
+ 'groups list',
67
+ 'help',
68
+ 'list',
69
+ 'milestone list',
70
+ 'notifications list',
71
+ 'priorities',
72
+ 'project list',
73
+ 'resolutions',
74
+ 'roles',
75
+ 'search',
76
+ 'space info',
77
+ 'statuses',
78
+ 'type list',
79
+ 'users list',
80
+ 'webhooks list',
81
+ 'wiki list'
82
+ ]
83
+ commands.each do |c|
84
+ command = 'bl ' + c + ' > /dev/null'
85
+ system(command)
86
+ if $?.exited?
87
+ puts "#{command}: OK"
88
+ else
89
+ puts "#{comamnd}: NG"
90
+ end
91
+ end
92
+ end
@@ -22,6 +22,7 @@ Commands:
22
22
  bl project SUBCOMMAND ...ARGS # manage projects
23
23
  bl recent SUBCOMMAND ...ARGS # list recent stuff
24
24
  bl resolutions # list resolutions
25
+ bl roles # list roles
25
26
  bl search # search issues
26
27
  bl show KEY # show an issue's details
27
28
  bl space SUBCOMMAND ...ARGS #
@@ -22,6 +22,13 @@ Edit issue by your favorite $EDITOR:
22
22
 
23
23
  bl edit ISSUE-12
24
24
 
25
+ ### Milestone
26
+
27
+ Add an milestone:
28
+
29
+ bl milestone add m1 --releaseDueDate=2017-04-01
30
+
31
+
25
32
  ### Project
26
33
 
27
34
  List projects:
@@ -25,7 +25,7 @@ module Bl
25
25
  option :name, type: :string
26
26
  def update(*ids)
27
27
  ids.each do |id|
28
- res = client.patch("#{@url}/#{id}", options)
28
+ res = client.patch("#{@url}/#{id}", delete_class_options(options))
29
29
  puts "category updated: #{res.body.id}\t#{res.body.name}"
30
30
  end
31
31
  end
@@ -47,6 +47,24 @@ module Bl
47
47
  assigneeId: :numeric
48
48
  }
49
49
 
50
+ ISSUE_FIELDS = %i(
51
+ issueKey
52
+ summary
53
+ startDate
54
+ dueDate
55
+ created
56
+ updated
57
+ )
58
+
59
+ ROLES = [
60
+ {id: 1, name: 'Administrator'},
61
+ {id: 2, name: 'Normal User'},
62
+ {id: 3, name: 'Reporter'},
63
+ {id: 4, name: 'Viewer'},
64
+ {id: 5, name: 'Guest Reporter'},
65
+ {id: 6, name: 'Guest Viewer'}
66
+ ]
67
+
50
68
  def initialize(*)
51
69
  @config = Bl::Config.instance
52
70
  super
@@ -78,7 +96,7 @@ module Bl
78
96
  desc 'count', 'count issues'
79
97
  options ISSUES_PARAMS
80
98
  def count
81
- puts client.get('issues/count', delete_format(options.to_h)).body.count
99
+ puts client.get('issues/count', delete_class_options(options.to_h)).body.count
82
100
  end
83
101
 
84
102
  desc 'list', 'list issues by typical ways'
@@ -103,13 +121,15 @@ module Bl
103
121
  opts[:order] = "asc"
104
122
  end
105
123
  opts[:categoryId] = [-1] if options[:nocategory]
106
- client.get('issues', opts).body.map {|i| print_issue(i)}
124
+ res = client.get('issues', opts)
125
+ puts formatter.render(res.body, fields: ISSUE_FIELDS, max_width: TPUT_COLS)
107
126
  end
108
127
 
109
128
  desc 'search', 'search issues'
110
129
  options ISSUES_PARAMS
111
130
  def search
112
- client.get('issues', delete_format(options.to_h)).body.map {|i| print_issue(i)}
131
+ res = client.get('issues', delete_class_options(options.to_h))
132
+ puts formatter.render(res.body, fields: ISSUE_FIELDS, max_width: TPUT_COLS)
113
133
  end
114
134
 
115
135
  desc 'show KEY', "show an issue's details"
@@ -157,7 +177,7 @@ module Bl
157
177
  issue_default_options = @config[:issue][:default]
158
178
  res = client.post(
159
179
  'issues',
160
- issue_default_options.merge({summary: s}).merge(delete_format(options.to_h))
180
+ issue_default_options.merge({summary: s}).merge(delete_class_options(options.to_h))
161
181
  )
162
182
  puts "issue added: #{res.body.issueKey}\t#{res.body.summary}"
163
183
  end
@@ -168,7 +188,7 @@ module Bl
168
188
  option :comment, type: :string
169
189
  def update(*keys)
170
190
  keys.each do |k|
171
- res = client.patch("issues/#{k}", delete_format(options.to_h))
191
+ res = client.patch("issues/#{k}", delete_class_options(options.to_h))
172
192
  puts "issue updated: #{res.body.issueKey}\t#{res.body.summary}"
173
193
  end
174
194
  end
@@ -217,6 +237,11 @@ module Bl
217
237
  puts formatter.render(res.body, fields: %i(id name))
218
238
  end
219
239
 
240
+ desc 'roles', 'list roles'
241
+ def roles
242
+ puts formatter.render(ROLES, fields: %i(id name))
243
+ end
244
+
220
245
  desc 'doctor', 'check issues'
221
246
  def doctor
222
247
  unassigned_issues = client.get('issues', assigneeId: [-1]).body
@@ -279,11 +304,5 @@ module Bl
279
304
  desc 'watchings SUBCOMMAND ...ARGS', ''
280
305
  subcommand 'watchings', Watchings
281
306
 
282
- private
283
-
284
- def delete_format(h)
285
- h.delete('format')
286
- h
287
- end
288
307
  end
289
308
  end
@@ -3,5 +3,15 @@ module Bl
3
3
  include Bl::Requestable
4
4
  include Bl::Formatting
5
5
  class_option :format, type: :string, default: 'table', desc: 'set output format'
6
+
7
+ TPUT_COLS = `tput cols`.to_i
8
+
9
+ protected
10
+
11
+ def delete_class_options(h)
12
+ opts = ['format']
13
+ opts.map { |opt| h.delete(opt) }
14
+ h
15
+ end
6
16
  end
7
17
  end
@@ -23,7 +23,7 @@ module Bl
23
23
  desc 'add GROUP_NAME', ''
24
24
  options members: :array
25
25
  def add(name)
26
- res = client.post(@url, {name: name}.merge(options))
26
+ res = client.post(@url, {name: name}.merge(delete_class_options(options)))
27
27
  puts 'group added'
28
28
  print_group_and_members(res.body)
29
29
  end
@@ -31,7 +31,7 @@ module Bl
31
31
  desc 'update GROUP_ID', ''
32
32
  options name: :string, members: :array
33
33
  def update(id)
34
- res = client.patch("#{@url}/#{id}", options.to_h)
34
+ res = client.patch("#{@url}/#{id}", delete_class_options(options.to_h))
35
35
  puts 'group updated'
36
36
  print_group_and_members(res.body)
37
37
  end
@@ -45,7 +45,7 @@ module Bl
45
45
  options MILESTONE_PARAMS
46
46
  def update(*ids)
47
47
  ids.each do |id|
48
- res = client.patch("#{@url}/#{id}", options)
48
+ res = client.patch("#{@url}/#{id}", delete_class_options(options))
49
49
  puts "milestone updated: #{res.body.id}\t#{res.body.name}"
50
50
  end
51
51
  end
@@ -36,8 +36,8 @@ module Bl
36
36
  puts '--milestone--'
37
37
  versions = client.get("projects/#{@config[:project_key]}/versions").body
38
38
  versions.each do |version|
39
- all_issues_count = count_issues(id, versionId: [version.id])
40
- closed_issues_count = count_issues(id, versionId: [version.id], statusId: [4])
39
+ all_issues_count = count_issues(id, milestoneId: [version.id])
40
+ closed_issues_count = count_issues(id, milestoneId: [version.id], statusId: [4])
41
41
  puts "#{version.name}: #{closed_issues_count} / #{all_issues_count}"
42
42
  end
43
43
  puts '--category--'
@@ -1,6 +1,19 @@
1
1
  module Bl
2
2
  class Type < Command
3
3
 
4
+ TYPE_COLORS = %w(
5
+ #e30000
6
+ #934981
7
+ #814fbc
8
+ #007e9a
9
+ #ff3265
10
+ #666665
11
+ #990000
12
+ #2779ca
13
+ #7ea800
14
+ #ff9200
15
+ )
16
+
4
17
  def initialize(*)
5
18
  @config = Bl::Config.instance
6
19
  @url = "projects/#{@config[:project_key]}/issueTypes"
@@ -40,5 +53,12 @@ module Bl
40
53
  puts "type deleted: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
41
54
  end
42
55
  end
56
+
57
+ desc 'colors', 'list colors'
58
+ def colors
59
+ TYPE_COLORS.each do |color|
60
+ puts Paint[color, '#ffffff', color]
61
+ end
62
+ end
43
63
  end
44
64
  end
@@ -1,6 +1,22 @@
1
1
  module Bl
2
2
  class Users < Command
3
3
 
4
+ USER_FIELDS = %i(
5
+ id
6
+ userId
7
+ name
8
+ roleType
9
+ lang
10
+ mailAddress
11
+ )
12
+
13
+ USER_PARAMS = {
14
+ password: :string,
15
+ name: :string,
16
+ mailAddress: :string,
17
+ roleType: :numeric
18
+ }
19
+
4
20
  def initialize(*)
5
21
  @config = Bl::Config.instance
6
22
  @url = 'users'
@@ -10,46 +26,40 @@ module Bl
10
26
  desc 'list', 'list users'
11
27
  def list
12
28
  res = client.get('users')
13
- puts formatter.render(res.body, fields: %i(id userId name roleType lang mailAddress))
29
+ puts formatter.render(res.body, fields: USER_FIELDS)
14
30
  end
15
31
 
16
32
  desc 'show USER_ID', ''
17
33
  def show(id)
18
34
  res = client.get("#{@url}/#{id}")
19
- print_user(res.body)
35
+ puts formatter.render(res.body, fields: USER_FIELDS)
20
36
  end
21
37
 
22
38
  desc 'add USER_ID PASSWORD NAME MAIL_ADDRESS ROLE_TYPE', ''
23
39
  def add(id, pass, name, mail_address, role_type)
24
40
  res = client.post("#{@url}", userId: id, password: pass, name: name, mailAddress: mail_address, roleType: role_type)
25
- print_user(res.body)
41
+ puts formatter.render(res.body, fields: USER_FIELDS)
26
42
  end
27
43
 
28
- USER_PARAMS = {
29
- password: :string,
30
- name: :string,
31
- mailAddress: :string,
32
- roleType: :numeric
33
- }
34
44
  desc 'update USER_ID', ''
35
45
  options USER_PARAMS
36
46
  def update(id)
37
- res = client.patch("#{@url}/#{id}", options.to_h)
47
+ res = client.patch("#{@url}/#{id}", delete_class_options(options.to_h))
38
48
  puts 'user updated:'
39
- print_user(res.body)
49
+ puts formatter.render(res.body, fields: USER_FIELDS)
40
50
  end
41
51
 
42
52
  desc 'delete', ''
43
53
  def delete(id)
44
54
  res = client.delete("#{@url}/#{id}")
45
55
  puts 'user deleted'
46
- print_user(res.body)
56
+ puts formatter.render(res.body, fields: USER_FIELDS)
47
57
  end
48
58
 
49
59
  desc 'myself', ''
50
60
  def myself
51
61
  res = client.get("#{@url}/myself")
52
- print_user(res.body)
62
+ puts formatter.render(res.body, fields: USER_FIELDS)
53
63
  end
54
64
 
55
65
  desc 'icon ID', ''
@@ -1,3 +1,3 @@
1
1
  module Bl
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.5.3'.freeze
3
3
  end
@@ -19,7 +19,7 @@ module Bl
19
19
  desc 'list USER_ID', ''
20
20
  options WATCHINGS_PARAMS
21
21
  def list(id)
22
- res = client.get("/users/#{id}/#{@url}", delete_format(options.to_h))
22
+ res = client.get("/users/#{id}/#{@url}", delete_class_options(options.to_h))
23
23
  res.body.map { |t| print_watch_target(t) }
24
24
  end
25
25
 
@@ -72,11 +72,5 @@ module Bl
72
72
  puts 'watch mark as checked'
73
73
  end
74
74
 
75
- private
76
-
77
- def delete_format(h)
78
- h.delete('format')
79
- h
80
- end
81
75
  end
82
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - saki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-15 00:00:00.000000000 Z
11
+ date: 2017-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor