class Batali::Command::Cache
Cache
management and information
Public Instance Methods
display()
click to toggle source
Display
local cache information
# File lib/batali/command/cache.rb, line 28 def display cache_size = Dir.glob(Utility.join_path(cache_directory, "**", "**", "*")).map do |path| File.size(path) if File.file?(path) end.compact.inject(&:+).to_i cache_size = "#{sprintf("%.2f", ((cache_size / 1024.to_f) / 1024))}M" [ "#{ui.color("Path:", :bold)} #{cache_directory}", "#{ui.color("Size:", :bold)} #{cache_size}", ].each do |line| ui.puts " #{line}" end end
execute!()
click to toggle source
Display
information from manifest
# File lib/batali/command/cache.rb, line 10 def execute! if opts[:scrub] scrub! end ui.puts ui.color("Batali cache information:", :bold) + "\n" display end
scrub!()
click to toggle source
Remove all contents from local cache
# File lib/batali/command/cache.rb, line 19 def scrub! ui.confirm "Remove all contents from local cache (#{cache_directory})" unless opts[:yes] run_action "Scrubbing local cache" do FileUtils.rm_rf(cache_directory) nil end end