require 'fileutils' module Addicted class CacheSweeper # add to this list to protect any other important # files or folders in the public directory # TODO: make this configurable somewhere other than inside plugin # to make updating easier PROTECTED_ENTRIES = %w( .svn .htaccess 404.html 500.html dispatch.cgi dispatch.fcgi dispatch.rb favicon.ico images javascripts robots.txt stylesheets system ) def self.clear_all # TODO: figure out why RAILS_ROOT wasn't working in here and i had to use the ../../, etc. Dir["#{File.join(File.dirname(__FILE__), '/../../../../public/*')}"].each do |entry| unless PROTECTED_ENTRIES.include? File.basename(entry) if File.file?(entry) File.delete(entry) elsif File.directory?(entry) FileUtils.remove_dir(entry, true) end end end end end end