30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/xccache/cache/cachemap.rb', line 30
def print_stats
verbose = Config.instance.verbose?
colors = { :hit => "green", :missed => "yellow" }
descs = %i[hit missed ignored].to_h do |type|
colorize = proc { |s| colors.key?(type) ? s.send(colors[type]).dark : s.dark }
items = get_cache_data(type)
percent = cache_data.count.positive? ? items.count.to_f / cache_data.count * 100 : 0
desc = "#{type} #{percent.round}% (#{items.count}/#{cache_data.count})"
desc = desc.capitalize if verbose
desc = "#{desc} #{colorize.call(items.to_s)}" if verbose && !items.empty?
[type, desc]
end
if verbose
UI.info <<~DESC
-------------------------------------------------------------------
Cache stats
#{descs.values.map { |s| "• #{s}" }.join("\n")}
-------------------------------------------------------------------
DESC
else
UI.info <<~DESC
-------------------------------------------------------------------
Cache stats: #{descs.values.join(', ')}
To see the full stats, use --verbose in the xccache command
-------------------------------------------------------------------
DESC
end
end
|