Class Sprockets::Asset
In: lib/sprockets/asset.rb
Parent: Object

`Asset` is the base class for `BundledAsset` and `StaticAsset`.

Methods

Attributes

content_type  [R] 
digest  [R] 
length  [R] 
logical_path  [R] 
mtime  [R] 
pathname  [R] 

Public Class methods

Internal initializer to load `Asset` from serialized `Hash`.

Public Instance methods

==(other)

Alias for eql?

`body` is aliased to source by default if it can‘t have any dependencies.

Return an `Array` of `Asset` files that are declared dependencies.

Return logical path with digest spliced in.

  "foo/bar-37b51d194a7513e45b56f6524f2d51f2.js"

Add enumerator to allow `Asset` instances to be used as Rack compatible body objects.

Copy serialized attributes to the coder object

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

Checks if Asset is fresh by comparing the actual mtime and digest to the inmemory model.

Used to test if cached models need to be rebuilt.

Initialize `Asset` from serialized `Hash`.

Checks if Asset is stale by comparing the actual mtime and digest to the inmemory model.

Subclass must override `fresh?` or `stale?`.

Expand asset into an `Array` of parts.

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

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

Return `String` of concatenated source.

Protected Instance methods

Check if dependency is fresh.

`dep` is a `Hash` with `path`, `mtime` and `hexdigest` keys.

A `Hash` is used rather than other `Asset` object because we want to test non-asset files and directories.

Internal: String paths that are marked as dependencies after processing.

Default to an empty `Array`.

Replace `$root` placeholder with actual environment root.

Get pathname with its root stripped.

Replace actual environment root with `$root` placeholder.

Internal: `ProccessedAsset`s that are required after processing.

Default to an empty `Array`.

[Validate]