bl 0.0.17 → 0.0.18

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: 18cdd252e41197f75e79f497859d6c25c76b5e8a
4
- data.tar.gz: 68832669abf7c790ef4e1af95dc14c46167ebdf8
3
+ metadata.gz: ad4bf727d88d7db10b943cb746c7fae8d5a4c56a
4
+ data.tar.gz: 1c4e165df3c2925a0903987542407604289dbea7
5
5
  SHA512:
6
- metadata.gz: 8e595744db4442fac77249ea36ce5a90e776e420a9166ea1051e540ad2314e92b48747c667f4aeaba664b1c9ced43531a0e4b947dd330e86ebd8e8eac129dc8f
7
- data.tar.gz: d5edffe356dd2bf6edd9e2c63bed2552841d7b403b23312eaa13e360ebf10b3dd4fc57383d38b164c23dbead586eb8e6d37a96cc8cb13b50bccf27e7151944c2
6
+ metadata.gz: c2adffd8959a0166d98d8dc39574c9891391022ba673bfc6b5f1b87b661da69d307e928eb31325d1af50ffad8296f7f5242bd76166711205b95b74dfe132ea5a
7
+ data.tar.gz: 55d89e37cf36f10a84b8eeef9f28aca618419ecdcd6e6cc237400a00984d475909393adeab0094aae378430b5cc7e2f874c4ac436f2bae78c9958424490474b9
data/bl.gemspec CHANGED
@@ -14,7 +14,9 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/sakihet/bl'
15
15
  spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ }
18
20
  spec.bindir = 'exe'
19
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
22
  spec.require_paths = ['lib']
data/lib/bl/cli.rb CHANGED
@@ -39,16 +39,7 @@ module Bl
39
39
  if File.exist?(filename)
40
40
  puts "#{filename} exits."
41
41
  else
42
- config = {
43
- space_id: '',
44
- api_key: '',
45
- project_key: '',
46
- issue: {
47
- default_project_id: '',
48
- default_issue_type_id: '',
49
- default_priority_id: ''
50
- }
51
- }
42
+ config = Bl::Config.instance.default_config
52
43
  f = File.new(filename, 'w')
53
44
  f.write(config.to_yaml)
54
45
  puts "#{filename} generated."
data/lib/bl/config.rb CHANGED
@@ -2,17 +2,35 @@ require 'singleton'
2
2
  require 'yaml'
3
3
 
4
4
  module Bl
5
- CONFIG_FILE = '.bl.yml'
5
+ CONFIG_FILE = '.bl.yml'.freeze
6
6
 
7
7
  class Config
8
8
  include Singleton
9
9
 
10
10
  def initialize
11
- @config = YAML.load_file(File.join(Dir.home, Bl::CONFIG_FILE))
11
+ file = File.join(Dir.home, Bl::CONFIG_FILE)
12
+ if File.exist?(file)
13
+ @config = YAML.load_file(file)
14
+ else
15
+ @config = nil
16
+ end
12
17
  end
13
18
 
14
19
  def [](key)
15
20
  @config[key]
16
21
  end
22
+
23
+ def default_config
24
+ {
25
+ space_id: '',
26
+ api_key: '',
27
+ project_key: '',
28
+ issue: {
29
+ default_project_id: '',
30
+ default_issue_type_id: '',
31
+ default_priority_id: ''
32
+ }
33
+ }
34
+ end
17
35
  end
18
36
  end
data/lib/bl/formatting.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Bl
2
- module Formatting extend self
2
+ module Formatting
3
+ module_function
3
4
 
4
5
  def colorize_type(name, color)
5
6
  Paint[name, :white, color]
data/lib/bl/project.rb CHANGED
@@ -17,11 +17,11 @@ module Bl
17
17
 
18
18
  desc 'status ID', 'show project status'
19
19
  def status(id)
20
- all_issues_count = client.get('issues/count', projectId: [id]).body.count
21
- open_issues_count = client.get('issues/count', projectId: [id], statusId: [1]).body.count
22
- in_progress_issues_count = client.get('issues/count', projectId: [id], statusId: [2]).body.count
23
- resolved_issues_count = client.get('issues/count', projectId: [id], statusId: [3]).body.count
24
- closed_issues_count = client.get('issues/count', projectId: [id], statusId: [4]).body.count
20
+ all_issues_count = count_issues(id)
21
+ open_issues_count = count_issues(id, 1)
22
+ in_progress_issues_count = count_issues(id, 2)
23
+ resolved_issues_count = count_issues(id, 3)
24
+ closed_issues_count = count_issues(id, 4)
25
25
  puts "#{closed_issues_count} / #{all_issues_count}"
26
26
  puts "open: #{open_issues_count}"
27
27
  puts "in progress: #{in_progress_issues_count}"
@@ -32,8 +32,25 @@ module Bl
32
32
  desc 'users ID', 'show project users'
33
33
  def users(id)
34
34
  client.get("#{@url}/#{id}/users").body.each do |u|
35
- puts [u.id, u.userId, u.name, u.roleType, u.lang, u.mailAddress].join("\t")
35
+ puts [
36
+ u.id,
37
+ u.userId,
38
+ u.name,
39
+ u.roleType,
40
+ u.lang,
41
+ u.mailAddress
42
+ ].join("\t")
36
43
  end
37
44
  end
45
+
46
+ private
47
+
48
+ def count_issues(project_id, *status)
49
+ client.get(
50
+ 'issues/count',
51
+ projectId: [project_id],
52
+ statusId: status
53
+ ).body.count
54
+ end
38
55
  end
39
56
  end
data/lib/bl/recent.rb CHANGED
@@ -8,15 +8,21 @@ module Bl
8
8
  end
9
9
 
10
10
  desc 'issues COUNT', 'list recently viewed issues'
11
- def issues(count=nil)
12
- client.get('users/myself/recentlyViewedIssues', count: count).body.each do |i|
11
+ def issues(count = nil)
12
+ client.get(
13
+ 'users/myself/recentlyViewedIssues',
14
+ count: count
15
+ ).body.each do |i|
13
16
  puts [i.issue.issueKey, i.issue.summary].join("\t")
14
17
  end
15
18
  end
16
19
 
17
20
  desc 'wikis COUNT', 'list recently viewed wikis'
18
- def wikis(count=nil)
19
- client.get('users/myself/recentlyViewedWikis', count: count).body.each do |w|
21
+ def wikis(count = nil)
22
+ client.get(
23
+ 'users/myself/recentlyViewedWikis',
24
+ count: count
25
+ ).body.each do |w|
20
26
  puts [w.page.id, w.page.name].join("\t")
21
27
  end
22
28
  end
@@ -1,5 +1,6 @@
1
1
  module Bl
2
- module Requestable extend self
2
+ module Requestable
3
+ module_function
3
4
 
4
5
  def client
5
6
  BacklogKit::Client.new(
data/lib/bl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bl
2
- VERSION = '0.0.17'
2
+ VERSION = '0.0.18'.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.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - saki