ghq-cache 0.3.2 → 0.3.3

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: 732bfd5c91049a4619fe5eb026e7a2e3b4396e58
4
- data.tar.gz: 8d6e37aac4a32a85497ad2c3cffc3c9cc6b046ae
3
+ metadata.gz: f06e4789f5cb92b6981bbbb370ed464cdbcdde90
4
+ data.tar.gz: 745daa0aad6f9d6bfd199d7d9005d01b292d7db3
5
5
  SHA512:
6
- metadata.gz: 5c511b2e747b4fd72db40be5bbaf4f14ddcf539aa7da71a32949ab566a99d38c4178d7db8bc130de729082b9fb99d236a124ec11a5d0531a29f4dc0145db7733
7
- data.tar.gz: 055a76578a3cb84a4d4d2a315f24c977680b4bf8da89cea01c7c6976531853fcb6c35e5ee8ae1cad16ef1f0ba44fe13d77eaea4ac9add5a598f0d0d4af7294f8
6
+ metadata.gz: a136625939910d9de208caa457f488f11c23c8906f1fcd9c8d9d6832eabf42f368fdcb4c4d42af384451a5f76697c5c267c81e09deb694524eff038aa062f2a2
7
+ data.tar.gz: 4937099c27f4c84089c0c840408fb391de611b48d2edf98345c99bec05e4e1cecaf5a7322a6b122f52435e778f71050847985b73d87fcdea466771f348ff3690
@@ -4,23 +4,29 @@ module Ghq
4
4
  class << self
5
5
  def print_repository_usage
6
6
  root = Logger.resume
7
+ dir = list_with_depth(1, root).sort_by(&:count).reverse.first
8
+ count_max = dir.count.to_s.length
7
9
  (1..3).each do |depth|
8
- print_usage_with_depth(depth, root)
10
+ print_usage_with_depth(depth, root, count_max)
9
11
  end
10
12
  end
11
13
 
12
14
  private
13
15
 
14
- def print_usage_with_depth(depth, root)
16
+ def print_usage_with_depth(depth, root, count_max)
17
+ list = list_with_depth(depth, root).sort_by(&:count).reverse
18
+ repo_max = `ghq list`.split("\n").map(&:length).max
19
+
15
20
  name =
16
21
  case depth
17
22
  when 1 then 'host'
18
23
  when 2 then 'user'
19
24
  when 3 then 'repository'
20
25
  end
21
- puts "[#{name}]" + ('-' * (30 - name.length))
22
- list_with_depth(depth, root).sort_by(&:count).reverse.first(30).each do |dir|
23
- puts "%5d %s" % [dir.count, dir.path_from_root]
26
+
27
+ puts "[#{name}]" + ('-' * (count_max + repo_max + 4 - name.length))
28
+ list.first(30).each_with_index do |dir, index|
29
+ puts "[%2d] %-#{repo_max}s %#{count_max}d" % [index + 1, dir.path_from_root, dir.count]
24
30
  end
25
31
  puts
26
32
  end
@@ -1,5 +1,5 @@
1
1
  module Ghq
2
2
  module Cache
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghq-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun