Sha256: 1be8efa1bf99b79fcebacd896d987bccb344f2ce32a7100d7f18f4aa22479d45

Contents?: true

Size: 819 Bytes

Versions: 4

Compression:

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

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
owl-cms-0.1.3 core/classes/cached.rb
owl-cms-0.1.2 core/classes/cached.rb
owl-cms-0.1.1 core/classes/cached.rb
owl-cms-0.1.0 core/classes/cached.rb