Sha256: 7603caf9ed0ae476f160c5a19ae5ad7637ba767666dabfd4a4b2d368a0d8a61c

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

require 'dassets/source_file'

module Dassets; end
class Dassets::SourceCache

  attr_reader :digest_path, :source_file, :cache

  def initialize(digest_path, cache=nil)
    @digest_path = digest_path
    @source_file = Dassets::SourceFile.find_by_digest_path(digest_path)
    @cache = cache || NoCache.new
  end

  def content
    @cache["#{self.key} -- content"] ||= @source_file.compiled
  end

  def fingerprint
    @cache["#{self.key} -- fingerprint"] ||= @source_file.fingerprint
  end

  def key
    "#{self.digest_path} -- #{self.mtime}"
  end

  def mtime
    @source_file.mtime
  end

  def exists?
    @source_file.exists?
  end

  class NoCache
    def [](key); end
    def []=(key, value); end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dassets-0.5.0 lib/dassets/source_cache.rb
dassets-0.4.1 lib/dassets/source_cache.rb
dassets-0.4.0 lib/dassets/source_cache.rb