Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

Commit

Permalink
Adicionando os scripts para limpar o cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
tapajos committed Sep 3, 2008
1 parent 767e4de commit 51a5db9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
38 changes: 38 additions & 0 deletions script/cache_sweeper
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env ruby
require 'find'
require 'fileutils'

cached_list = []

routes = `rake routes`
routes.each do |full_route|
cached_list << $1 if full_route =~ /^[^\(].*?\/(\w*)[\/|\s].*$/
end

cached_list.delete_if { |item| item.strip == '' || %w(selenium server_error).include?(item) }

def full_path(file_name)
public_path = File.expand_path(File.dirname(__FILE__) + "/../public")
"#{public_path}/#{file_name}"
end

def full_file_path(file_name)
"#{full_path(file_name)}.html"
end

cached_list.compact.uniq.each do |file_name|

if File.directory?(full_path(file_name))
FileUtils.rm_rf(full_path(file_name))
p "Removed: #{full_path(file_name)}"
end

if File.exist?(full_file_path(file_name))
FileUtils.rm_rf(full_file_path(file_name))
p "Removed: #{full_file_path(file_name)}"
end

end

FileUtils.rm_rf(full_file_path('index'))
p "Removed: #{full_file_path('index')}"
16 changes: 16 additions & 0 deletions script/integration_sweeper
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
require 'find'
require 'fileutils'

system "#{File.dirname(__FILE__)}/cache_sweeper"

js_path = File.expand_path(File.dirname(__FILE__) + "/../public/javascripts")

Find.find(js_path) do |file_name|
file_name_without_path = file_name.gsub(Regexp.new(js_path), '')
if !File.directory?(file_name) && !file_name.include?(".svn") && file_name_without_path =~ /^\/all.*\.js$/
FileUtils.rm_rf("#{js_path}#{file_name_without_path}")
p "Removed: #{js_path}#{file_name_without_path}"
end
end

0 comments on commit 51a5db9

Please sign in to comment.