require 'fileutils' module Owl module Lib class CachedFile def self.find(request) path = Rack::Utils.unescape(request.path_info) file_to_return = false self.possible_paths(path).each do |file| break if file_to_return file_to_return = file if File.exists?(file) end file_to_return end def self.possible_paths(path) [ File.expand_path("#{Owl::CMS::Cache::CACHE_STORE}#{path}.html" ), File.expand_path("#{Owl::CMS::Cache::CACHE_STORE}#{path}/index.html" ), File.expand_path("#{Owl::CMS::Cache::CACHE_STORE}#{path}index.html" ) ] end def self.clear puts "** Removing OwlCMS cache **" FileUtils.rm_rf Owl::CMS::Cache::CACHE_STORE end end end end