Sha256: 05ccebe53f085a08fc4c5c8215ae28bfb0be244b525a0385e6cbd4a2f7e9a99a
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
require 'rack/utils' require 'rack/mime' require 'dassets/source_proxy' module Dassets; end class Dassets::AssetFile attr_reader :digest_path, :dirname, :extname, :basename, :source_proxy def initialize(digest_path) @digest_path = digest_path @dirname = File.dirname(@digest_path) @extname = File.extname(@digest_path) @basename = File.basename(@digest_path, @extname) @source_proxy = Dassets::SourceProxy.new(@digest_path, Dassets.config.cache) end def digest! return if !self.exists? Dassets.config.file_store.save(self.url){ self.content } end def url url_basename = "#{@basename}-#{self.fingerprint}#{@extname}" File.join(@dirname, url_basename).sub(/^\.\//, '').sub(/^\//, '') end def href "/#{self.url}" end def fingerprint return nil if !self.exists? @source_proxy.fingerprint end def content return nil if !self.exists? @source_proxy.content end def mtime return nil if !self.exists? @source_proxy.mtime.httpdate end def size return nil if !self.exists? Rack::Utils.bytesize(self.content) end def mime_type return nil if !self.exists? Rack::Mime.mime_type(@extname) end def exists? @source_proxy.exists? end def ==(other_asset_file) other_asset_file.kind_of?(Dassets::AssetFile) && self.digest_path == other_asset_file.digest_path && self.fingerprint == other_asset_file.fingerprint end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dassets-0.10.1 | lib/dassets/asset_file.rb |
dassets-0.10.0 | lib/dassets/asset_file.rb |
dassets-0.9.0 | lib/dassets/asset_file.rb |
dassets-0.8.0 | lib/dassets/asset_file.rb |