class Sprockets::Asset

def base64digest

Public: Returns String base64 digest of source.
def base64digest
  DigestUtils.pack_base64digest(digest)
end

def charset

Returns a String charset name or nil if binary.

Public: Get charset of source.
def charset
  metadata[:charset]
end

def digest

Public: Returns String byte digest of source.
def digest
  metadata[:digest]
end

def digest_path

Returns String.

"foo/bar-37b51d194a7513e45b56f6524f2d51f2.js"

Public: Return logical path with digest spliced in.
def digest_path
  if DigestUtils.already_digested?(@name)
    logical_path
  else
    logical_path.sub(/\.(\w+)$/) { |ext| "-#{etag}#{ext}" }
  end
end

def each

Returns nothing.

part - String body chunk
block

compatible body objects.
Public: Add enumerator to allow `Asset` instances to be used as Rack
def each
  yield to_s
end

def environment_version

Private: Return the version of the environment where the asset was generated.
def environment_version
  metadata[:environment_version]
end

def eql?(other)

Returns true or false.

Assets are equal if they share the same path and digest.

Public: Compare assets.
def eql?(other)
  self.class == other.class && self.id == other.id
end

def etag

Public: ETag String of Asset.
def etag
  version = environment_version
  if version && version != ""
    DigestUtils.hexdigest(version + digest)
  else
    DigestUtils.pack_hexdigest(digest)
  end
end

def full_digest_path

Returns String.

Public: Return load path + logical path with digest spliced in.
def full_digest_path
  File.join(@load_path, digest_path)
end

def hash

Returns Integer hash of the id.

in a Set.
Public: Implements Object#hash so Assets can be used as a Hash key or
def hash
  id.hash
end

def hexdigest

Public: Returns String hexdigest of source.
def hexdigest
  DigestUtils.pack_hexdigest(digest)
end

def initialize(attributes = {})

Returns Asset.

attributes - Hash of ivars

Environment#find_asset should vend them.
Asset wrappers should not be initialized directly, only

Private: Initialize Asset wrapper from attributes Hash.
def initialize(attributes = {})
  @attributes   = attributes
  @content_type = attributes[:content_type]
  @filename     = attributes[:filename]
  @id           = attributes[:id]
  @load_path    = attributes[:load_path]
  @logical_path = attributes[:logical_path]
  @metadata     = attributes[:metadata]
  @name         = attributes[:name]
  @source       = attributes[:source]
  @uri          = attributes[:uri]
end

def inspect

Returns String.

Public: Pretty inspect
def inspect
  "#<#{self.class}:#{object_id.to_s(16)} #{uri.inspect}>"
end

def integrity

Public: A "named information" URL for subresource integrity.
def integrity
  DigestUtils.integrity_uri(digest)
end

def length

Public: Returns Integer length of source.
def length
  metadata[:length]
end

def links

Returns Set of String asset URIs.

All linked assets should be compiled anytime this asset is.

Public: Get all externally linked asset filenames from asset.
def links
  metadata[:links] || Set.new
end

def source

Returns String.

Public: Return `String` of concatenated source.
def source
  if @source
    @source
  else
    # File is read everytime to avoid memory bloat of large binary files
    File.binread(filename)
  end
end

def to_hash

Returns a Hash.

Internal: Return all internal instance variables as a hash.
def to_hash
  @attributes
end

def to_s

Returns String.

Public: Alias for #source.
def to_s
  source
end

def write_to(filename)

Returns nothing.

filename - String target

Deprecated: Save asset to disk.
def write_to(filename)
  FileUtils.mkdir_p File.dirname(filename)
  PathUtils.atomic_write(filename) do |f|
    f.write source
  end
  nil
end