Created
November 13, 2010 13:19
-
-
Save chriskottom/675312 to your computer and use it in GitHub Desktop.
simple Rake task for cleanup of Rails directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :admin do | |
desc "Clean up all temporary files in the application directory" | |
task :cleanup, :needs => :environment do | |
puts "Removing temporary directory contents" | |
tmp_files = [] | |
%w{ cache pids sessions sockets }.each do |dir| | |
tmp_files += Dir.glob( File.join(Rails.root, "tmp", dir, "*") ) | |
end | |
File.delete(*tmp_files) | |
puts "Removing log files" | |
log_files = Dir.glob( File.join(Rails.root, "log", "*") ) | |
File.delete(*log_files) | |
puts "Removing emacs temporary files" | |
emacs_tmp_files = Dir.glob( File.join(Rails.root, "**", "*~") ) | |
emacs_tmp_files += Dir.glob( File.join(Rails.root, "**", "\#*\#") ) | |
File.delete(*emacs_tmp_files) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment