Provided by: libmojolicious-plugin-assetpack-perl_2.02-1_all bug

NAME

       Mojolicious::Plugin::AssetPack::Store - Storage for assets

SYNOPSIS

         use Mojolicious::Lite;

         # Load plugin and pipes in the right order
         plugin AssetPack => {pipes => \@pipes};

         # Change where assets can be found
         app->asset->store->paths([
           app->home->rel_file("some/directory"),
           "/some/other/directory",
         ]);

         # Change where assets are stored
         app->asset->store->paths->[0] = app->home->rel_file("some/directory");

         # Define asset
         app->asset->process($moniker => @assets);

         # Retrieve a Mojolicious::Plugin::AssetPack::Asset object
         my $asset = app->asset->store->asset("some/file.js");

DESCRIPTION

       Mojolicious::Plugin::AssetPack::Store is an object to manage cached assets on disk.

       The idea is that a Mojolicious::Plugin::AssetPack::Pipe object can store an asset after it
       is processed. This will speed up development, since only changed assets will be processed
       and it will also allow processing tools to be optional in production environment.

       This module will document meta data about each asset which is saved to disk, so it can be
       looked up later as a unique item using "load".

ATTRIBUTES

       Mojolicious::Plugin::AssetPack::Store inherits all attributes from Mojolicious::Static
       implements the following new ones.

   asset_class
         $str = $self->asset_class;
         $self = $self->asset_class("Mojolicious::Plugin::AssetPack::Asset");

       Holds the classname of which new assets will be constructed from.

   default_headers
         $hash_ref = $self->default_headers;
         $self = $self->default_headers({"Cache-Control" => "max-age=31536000"});

       Used to set default headers used by "serve_asset".

   paths
         $paths = $self->paths;
         $self = $self->paths([$app->home->rel_file("assets")]);

       See "paths" in Mojolicious::Static for details.

   ua
         $ua = $self->ua;

       See "ua" in Mojolicious::Plugin::AssetPack.

METHODS

       Mojolicious::Plugin::AssetPack::Store inherits all attributes from Mojolicious::Static
       implements the following new ones.

   asset
         $asset = $self->asset($url, $paths);

       Returns a Mojolicious::Plugin::AssetPack::Asset object or undef unless $url can be found
       in $paths. $paths default to "paths" in Mojolicious::Static. $paths and $url can be...

       • helper://some.mojo.helper/some_identifier?format=css

         Will call a helper registered under the name "csome.mojo.helper", with the query
         parameters as arguments. Example:

           $output = $c->some->mojo->helper(some_identifier => {format => "css"});

         $output can be a scalar containing the asset content or a hash-ref with arguments passed
         on to Mojolicious::Plugin::AssetPack::Asset. Note that "format" need to be present in
         the URL or the returning hash-ref for this to work.

         This feature is currently EXPERIMENTAL. Let me know if you use it/find it interesting.

       • http://example.com/foo/bar

         An absolute URL will be downloaded from web, unless the host is "local": "local" is a
         special host which will run the request through the current Mojolicious application.

       • foo/bar

         An relative URL will be looked up using "file" in Mojolicious::Static.

       Note that assets from web will be cached locally, which means that you need to delete the
       files on disk to download a new version.

   load
         $bool = $self->load($asset, \%attr);

       Used to load an existing asset from disk. %attr will override the way an asset is looked
       up. The example below will ignore minified and rather use the value from %attr:

         $bool = $self->load($asset, {minified => $bool});

   persist
         $self = $self->persist;

       Used to save the internal state of the store to disk.

       This method is EXPERIMENTAL, and may change without warning.

   save
         $bool = $self->save($asset, \%attr);

       Used to save an asset to disk. %attr are usually the same as "TO_JSON" in
       Mojolicious::Plugin::AssetPack::Asset and used to document metadata about the $asset so it
       can be looked up using "load".

   serve_asset
       Override "serve_asset" in Mojolicious::Static with the functionality to set response
       headers first, from "default_headers".

SEE ALSO

       Mojolicious::Plugin::AssetPack.