Class: Terraspace::CLI::Clean::Cache

Inherits:
Base
  • Object
show all
Defined in:
lib/terraspace/cli/clean/cache.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #pretty

Methods included from Util::Sure

#sure?

Methods included from Util::Logging

#logger

Constructor Details

This class inherits a constructor from Terraspace::CLI::Clean::Base

Instance Method Details

#are_you_sure?(paths) ⇒ Boolean



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/terraspace/cli/clean/cache.rb', line 12

def are_you_sure?(paths)
  pretty_paths = paths.map { |p| "    #{pretty(p)}" }.join("\n")
  message = "    Will remove these folders and all their files:\n\n    \#{pretty_paths}\n\n    Are you sure?\n  EOL\n  sure?(message) # from Util::Sure\nend\n".chomp

#runObject



3
4
5
6
7
8
9
10
# File 'lib/terraspace/cli/clean/cache.rb', line 3

def run
  paths = [Terraspace.cache_root, Terraspace.tmp_root]
  are_you_sure?(paths)
  paths.each do |path|
    FileUtils.rm_rf(path)
    puts "Removed #{pretty(path)}"
  end
end