Class: Rfmt::CacheCommands

Inherits:
Thor
  • Object
show all
Defined in:
lib/rfmt/cli.rb

Overview

Cache management commands

Instance Method Summary collapse

Instance Method Details

#clearObject



17
18
19
20
21
22
# File 'lib/rfmt/cli.rb', line 17

def clear
  cache_opts = options[:cache_dir] ? { cache_dir: options[:cache_dir] } : {}
  cache = Cache.new(**cache_opts)
  cache.clear
  say 'Cache cleared', :green
end

#pruneObject



37
38
39
40
41
42
# File 'lib/rfmt/cli.rb', line 37

def prune
  cache_opts = options[:cache_dir] ? { cache_dir: options[:cache_dir] } : {}
  cache = Cache.new(**cache_opts)
  pruned = cache.prune
  say "Pruned #{pruned} stale cache entries", :green
end

#statsObject



26
27
28
29
30
31
32
33
# File 'lib/rfmt/cli.rb', line 26

def stats
  cache_opts = options[:cache_dir] ? { cache_dir: options[:cache_dir] } : {}
  cache = Cache.new(**cache_opts)
  stats = cache.stats
  say "Cache directory: #{stats[:cache_dir]}", :blue
  say "Total files in cache: #{stats[:total_files]}", :blue
  say "Cache size: #{(stats[:cache_size_bytes] / 1024.0).round(2)} KB", :blue
end