Sha256: c4016c228355587df94654d36453c83657c21833a906ad3c004cf4fb9aa10486
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
require 'digest/md5' require 'dassets/cache' require 'dassets/source_file' module Dassets; end class Dassets::SourceProxy attr_reader :digest_path, :content_cache, :fingerprint_cache attr_reader :source_files def initialize(digest_path, options = nil) options ||= {} @digest_path = digest_path @content_cache = options[:content_cache] || Dassets::Cache::NoCache.new @fingerprint_cache = options[:fingerprint_cache] || Dassets::Cache::NoCache.new @source_files = get_source_files(@digest_path, { :content_cache => @content_cache, :fingerprint_cache => @fingerprint_cache }) end def key "#{self.digest_path} -- #{self.mtime}" end def content @content_cache[self.key] ||= source_content end def fingerprint @fingerprint_cache[self.key] ||= source_fingerprint end def mtime @source_files.map{ |f| f.mtime }.compact.max end def exists? @source_files.inject(true){ |res, f| res && f.exists? } end private def source_content @source_files.map{ |f| f.compiled }.join("\n") end def source_fingerprint Digest::MD5.new.hexdigest(source_content) end def get_source_files(digest_path, options) Dassets.config.combinations[digest_path.to_s].map do |source_digest_path| Dassets::SourceFile.find_by_digest_path(source_digest_path, options) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dassets-0.13.0 | lib/dassets/source_proxy.rb |