Skip to content
Browse files

Adicionando os scripts para limpar o cache.

  • Loading branch information...
1 parent 767e4de commit 51a5db9933773ce409175270574d8385b5488124 @tapajos committed Sep 2, 2008
Showing with 54 additions and 0 deletions.
  1. +38 −0 script/cache_sweeper
  2. +16 −0 script/integration_sweeper
View
38 script/cache_sweeper
@@ -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')}"
View
16 script/integration_sweeper
@@ -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.
Something went wrong with that request. Please try again.