Class: Mongrel::PageCacheHandler::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/utils.rb

Class Method Summary collapse

Class Method Details

.build_cachetastic_key(request) ⇒ Object

def build_full_file_path(request, mk_dirs = false)

File.join(build_directory_path(request, mk_dirs), build_file_name(request))

end

def build_directory_path(request, mk_dirs = false)

pcd = ActionController::Base.page_cache_directory
dir_path = File.join(pcd, build_path(request))
FileUtils.mkdir_p(dir_path) if mk_dirs
dir_path

end

def build_file_name(request)

query_params = build_query_params(request)
f_name = ""
query_params.each_pair do |key, value|
  f_name << key.to_s
  f_name << "_"
  f_name << value
  f_name << "-"
end
f_name.gsub!(" ", "_")
f_name.downcase!
f_name.chop!
f_name

end



48
49
50
51
52
53
54
55
# File 'lib/utils.rb', line 48

def build_cachetastic_key(request)
  path = request.params[Mongrel::Const::PATH_INFO].downcase.dup
  path = "/" if path.blank?
  path << "?" << request.params["QUERY_STRING"].downcase.dup unless request.params["QUERY_STRING"].blank?
  path.gsub!(/(gclid=.*?)(&|\z)/, '')
  path
  # File.join(build_path(request), build_file_name(request))
end

.do_work(request, response) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/utils.rb', line 8

def do_work(request, response)
  if ActionController::Base.perform_caching
    if request.params[Mongrel::Const::REQUEST_METHOD] == "GET"
      case request.params[Mongrel::Const::PATH_INFO]
      when /\.xml$/                              ## CHANGEME
        yield request, response if block_given?  ## CHANGEME
      when /\.[a-zA-Z]*$/
      else
        yield request, response if block_given?  ## CHANGEME
      end
    end
  end
end