ghq-cache 0.3.1 → 0.3.2

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: 0d9368162f00c4bdb0adea8729c40ababe4be28a
4
- data.tar.gz: 0bd77faae814a37885104b29af27f389634849de
3
+ metadata.gz: 732bfd5c91049a4619fe5eb026e7a2e3b4396e58
4
+ data.tar.gz: 8d6e37aac4a32a85497ad2c3cffc3c9cc6b046ae
5
5
  SHA512:
6
- metadata.gz: 12b8366e9cb0392821e2034d63e9c5fa3fd51ef825d6fc4cb02a80a30feb9f719ed46057dfa64a40a3cffb660f29c9a374da79a4ea20f62eedd041cb8a19a6ad
7
- data.tar.gz: 1d80ecb3bb9d73875edede2c6c0729599abce865ad0ed5f7cf19daec55f470b784660d3cacb964bf2ecfa72e0c1f9736162c46407a1c5bda0bb51b83d890b039
6
+ metadata.gz: 5c511b2e747b4fd72db40be5bbaf4f14ddcf539aa7da71a32949ab566a99d38c4178d7db8bc130de729082b9fb99d236a124ec11a5d0531a29f4dc0145db7733
7
+ data.tar.gz: 055a76578a3cb84a4d4d2a315f24c977680b4bf8da89cea01c7c6976531853fcb6c35e5ee8ae1cad16ef1f0ba44fe13d77eaea4ac9add5a598f0d0d4af7294f8
data/lib/ghq/cache/cli.rb CHANGED
@@ -20,6 +20,11 @@ module Ghq
20
20
  FileUtils.rm_f(Logger::LOG_PATH)
21
21
  FileUtils.rm_f(Builder::CACHE_PATH)
22
22
  end
23
+
24
+ desc 'stats', 'Show the statistics of your repository usage'
25
+ def stats
26
+ Stats.print_repository_usage
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -0,0 +1,37 @@
1
+ module Ghq
2
+ module Cache
3
+ class Stats
4
+ class << self
5
+ def print_repository_usage
6
+ root = Logger.resume
7
+ (1..3).each do |depth|
8
+ print_usage_with_depth(depth, root)
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def print_usage_with_depth(depth, root)
15
+ name =
16
+ case depth
17
+ when 1 then 'host'
18
+ when 2 then 'user'
19
+ when 3 then 'repository'
20
+ 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]
24
+ end
25
+ puts
26
+ end
27
+
28
+ def list_with_depth(depth, *dirs)
29
+ return dirs if depth == 0
30
+ dirs.map do |dir|
31
+ list_with_depth(depth - 1, *dir.children)
32
+ end.flatten.compact
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  module Ghq
2
2
  module Cache
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
data/lib/ghq/cache.rb CHANGED
@@ -1,5 +1,6 @@
1
- require 'ghq/cache/cli'
2
1
  require 'ghq/cache/directory'
3
2
  require 'ghq/cache/builder'
4
3
  require 'ghq/cache/logger'
4
+ require 'ghq/cache/stats'
5
+ require 'ghq/cache/cli'
5
6
  require 'ghq/cache/version'
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -86,6 +86,7 @@ files:
86
86
  - lib/ghq/cache/cli.rb
87
87
  - lib/ghq/cache/directory.rb
88
88
  - lib/ghq/cache/logger.rb
89
+ - lib/ghq/cache/stats.rb
89
90
  - lib/ghq/cache/version.rb
90
91
  homepage: https://github.com/k0kubun/ghq-cache
91
92
  licenses: []