Class Jammit::Packager
In: lib/jammit/packager.rb
Parent: Object

The Jammit::Packager resolves the configuration file into lists of real assets that get merged into individual asset packages. Given the compiled contents of an asset package, the Packager knows how to cache that package with the correct timestamps.

Methods

Attributes

force  [RW]  Set force to false to allow packages to only be rebuilt when their source files have changed since the last time their package was built.
package_names  [RW]  Set force to false to allow packages to only be rebuilt when their source files have changed since the last time their package was built.

Public Class methods

Creating a new Packager will rebuild the list of assets from the Jammit.configuration. When assets.yml is being changed on the fly, create a new Packager.

Public Instance methods

Caches a single prebuilt asset package and gzips it at the highest compression level. Ensures that the modification time of both both variants is identical, for web server caching modules, as well as MHTML.

Get the list of individual assets for a package.

Return the compressed contents of a javascript package.

Return the compressed contents of a stylesheet package.

Return the compiled contents of a JST package.

Ask the packager to precache all defined assets, along with their gzip‘d versions. In order to prebuild the MHTML stylesheets, we need to know the base_url, because IE only supports MHTML with absolute references. Unless forced, will only rebuild assets whose source files have been changed since their last package build.

Private Instance methods

Return a list of all of the packages that should be cached. If "force" is true, this is all of them — otherwise only the packages that are missing or whose source files have changed since the last package build.

Compiles the list of assets that goes into each package. Runs an ordered list of Dir.globs, taking the merged unique result. If there are JST files in this package we need to add an extra path for when package_assets is off (e.g. in a dev environment). This package (e.g. /assets/package-name.jst) will never exist as an actual file but will be dynamically generated by Jammit on every request.

Absolute globs are absolute — relative globs are relative to ASSET_ROOT. Print a warning if no files were found that match the glob.

Get the latest mtime of a list of files (plus the config path).

Raise a PackageNotFound exception for missing packages…

Look up a package asset list by name, raising an exception if the package has gone missing.

In Rails, the difference between a path and an asset URL is "public".

[Validate]