Sha256: d4fc0a688b9a60b5ff42b9752527d42ee6afcf15f3db81c4dd4677292443e12d

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

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_all!
        puts "** Removing OwlCMS cache **"
        FileUtils.rm_rf Owl::CMS::Cache::CACHE_STORE
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owl-cms-0.1.5 core/classes/cached.rb