class Sass::CacheStores::Filesystem

A backend for the Sass cache using the filesystem.

def _retrieve(key, version, sha)

Other tags:
    See: Base#\_retrieve -
def _retrieve(key, version, sha)
  return unless File.readable?(path_to(key))
  begin
    File.open(path_to(key), "rb") do |f|
      if f.readline("\n").strip == version && f.readline("\n").strip == sha
        return f.read
      end
    end
    File.unlink path_to(key)
  rescue Errno::ENOENT
    # Already deleted. Race condition?
  end
  nil
rescue EOFError, TypeError, ArgumentError => e
  Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
end

def _store(key, version, sha, contents)

Other tags:
    See: Base#\_store -
def _store(key, version, sha, contents)
  compiled_filename = path_to(key)
  FileUtils.mkdir_p(File.dirname(compiled_filename))
  Sass::Util.atomic_create_and_write_file(compiled_filename) do |f|
    f.puts(version)
    f.puts(sha)
    f.write(contents)
  end
rescue Errno::EACCES
  # pass
end

def initialize(cache_location)

Parameters:
  • cache_location (String) -- see \{#cache\_location}
def initialize(cache_location)
  @cache_location = cache_location
end

def path_to(key)

Returns:
  • (String) - The path to the cache file.

Parameters:
  • key (String) --
def path_to(key)
  key = key.gsub(/[<>:\\|?*%]/) {|c| "%%%03d" % c.ord}
  File.join(cache_location, key)
end