class Sprockets::Asset

def base64digest

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

def charset

Returns a String charset name or nil if binary.

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

def dependencies

Returns Array of Assets.

See Asset#to_a

Deprecated: Get all required Assets.
def dependencies
  to_a.reject { |a| a.filename.eql?(self.filename) }
end

def digest_path

Returns String.

"foo/bar-37b51d194a7513e45b56f6524f2d51f2.js"

Public: Return logical path with digest spliced in.
def digest_path
  logical_path.sub(/\.(\w+)$/) { |ext| "-#{etag}#{ext}" }
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 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 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(metadata[:digest])
end

def included

Returns Array of String asset URIs.

asset.
Public: Get all internally required assets that were concated into this
def included
  metadata[:included]
end

def initialize(environment, attributes = {})

Returns Asset.

attributes - Hash of ivars

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

Private: Intialize Asset wrapper from attributes Hash.
def initialize(environment, attributes = {})
  @environment  = environment
  @attributes   = attributes
  @content_type = attributes[:content_type]
  @filename     = attributes[:filename]
  @id           = attributes[:id]
  @integrity    = attributes[:integrity]
  @load_path    = attributes[:load_path]
  @logical_path = attributes[:logical_path]
  @metadata     = attributes[:metadata]
  @mtime        = attributes[:mtime]
  @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 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 mtime

Returns Time.

Time resolution is normalized to the nearest second.

Deprecated: Returns Time of the last time the source was modified.
def mtime
  Time.at(@mtime)
end

def pathname

Returns Pathname.

Deprecated: Use #filename instead.
def pathname
  @pathname ||= Pathname.new(filename)
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_a

Returns Array of Assets.

case is to relink to the assets anyway.
assets in memory (and in cache) is expensive and redundant. The common use
Use Asset#included instead. Keeping a full copy of the bundle's processed

purposes.
This allows you to link to individual files for debugging

the asset's contents as a whole.
Appending all of an assets body parts together should give you

Deprecated: Expand asset into an `Array` of parts.
def to_a
  if metadata[:included]
    metadata[:included].map { |uri| @environment.load(uri) }
  else
    [self]
  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
  # Set mtime correctly
  File.utime(mtime, mtime, filename)
  nil
end