Parent

Class/Module Index [+]

Quicksearch

Sass::CacheStores::Filesystem

A backend for the Sass cache using the filesystem.

Attributes

cache_location[RW]

The directory where the cached files will be stored.

@return [String]

Public Class Methods

new(cache_location) click to toggle source

@param cache_location [String] see {#cache_location}

# File lib/sass/cache_stores/filesystem.rb, line 13
def initialize(cache_location)
  @cache_location = cache_location
end

Public Instance Methods

_retrieve(key, version, sha) click to toggle source

@see Base#_retrieve

# File lib/sass/cache_stores/filesystem.rb, line 18
def _retrieve(key, version, sha)
  return unless File.readable?(path_to(key))
  File.open(path_to(key), "rb") do |f|
    if f.readline("\n").strip == version && f.readline("\n").strip == sha
      return f.read
    end
  end
  begin
    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
_store(key, version, sha, contents) click to toggle source

@see Base#_store

# File lib/sass/cache_stores/filesystem.rb, line 36
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, 0600) do |f|
    f.puts(version)
    f.puts(sha)
    f.write(contents)
  end
rescue Errno::EACCES
  # pass
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.