Class Sprockets::Manifest
In: lib/sprockets/manifest.rb
Parent: Object

The Manifest logs the contents of assets compiled to a single directory. It records basic attributes about the asset for fast lookup without having to compile. A pointer from each logical path indicates with fingerprinted asset is the current one.

The JSON is part of the public API and should be considered stable. This should make it easy to read from other programming languages and processes that don‘t have sprockets loaded. See `assets` and `files` for more infomation about the structure.

Methods

assets   backups_for   clean   clobber   compile   files   find_asset   new   remove   save  

Attributes

dir  [R] 
environment  [R] 
path  [R] 

Public Class methods

Create new Manifest associated with an `environment`. `path` is a full path to the manifest json file. The file may or may not already exist. The dirname of the `path` will be used to write compiled assets to. Otherwise, if the path is a directory, the filename will default to "manifest.json" in that directory.

  Manifest.new(environment, "./public/assets/manifest.json")

Public Instance methods

Returns internal assets mapping. Keys are logical paths which map to the latest fingerprinted filename.

  Logical path (String): Fingerprint path (String)

  { "application.js" => "application-2e8e9a7c6b0aafa0c9bdeec90ea30213.js",
    "jquery.js"      => "jquery-ae0908555a245f8266f77df5a8edca2e.js" }

Cleanup old assets in the compile directory. By default it will keep the latest version plus 2 backups.

Wipe directive

Compile and write asset to directory. The asset is written to a fingerprinted filename like `application-2e8e9a7c6b0aafa0c9bdeec90ea30213.js`. An entry is also inserted into the manifest file.

  compile("application.js")

Returns internal file directory listing. Keys are filenames which map to an attributes array.

  Fingerprint path (String):
    logical_path: Logical path (String)
    mtime: ISO8601 mtime (String)
    digest: Base64 hex digest (String)

 { "application-2e8e9a7c6b0aafa0c9bdeec90ea30213.js" =>
     { 'logical_path' => "application.js",
       'mtime' => "2011-12-13T21:47:08-06:00",
       'digest' => "2e8e9a7c6b0aafa0c9bdeec90ea30213" } }

Removes file from directory and from manifest. `filename` must be the name with any directory path.

  manifest.remove("application-2e8e9a7c6b0aafa0c9bdeec90ea30213.js")

Protected Instance methods

Finds all the backup assets for a logical path. The latest version is always excluded. The return array is sorted by the assets mtime in descending order (Newest to oldest).

Persist manfiest back to FS

[Validate]