NAME
Resource::Pack - tools for managing application resources
VERSION
version 0.03
SYNOPSIS
my $resources = resource my_app => as {
install_from 'data';
install_to '/var/www/site';
url jquery => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
file app_js => 'app.js';
file app_css => (
file => 'app.css',
install_to => 'css',
);
dir 'images';
};
$resources->install;
or, to package this up nicely in a class:
package My::App::Resources;
use Moose;
use Resource::Pack;
extends 'Resource::Pack::Resource';
has '+name' => (default => 'my_app');
sub BUILD {
my $self = shift;
resource $self => as {
install_from 'data';
url jquery => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
file app_js => 'app.js';
file app_css => (
file => 'app.css',
install_to => 'css',
);
dir 'images';
};
}
my $resources = My::App::Resources->new(install_to => '/var/www/site');
$resources->install;
DESCRIPTION
Resource::Pack is a set of Moose classes, built on top of Bread::Board, designed to allow managing non-Perl resources in a very CPAN friendly way.
In the past if you wanted to distribute your non-Perl code via CPAN there were a number of less then ideal ways to do it. The simplest was to store the data in Perl strings or encoded as binary data; this is ugly to say the least. You could also use a module like File::ShareDir, which relies on the fact that CPAN can be told to install files inside a directory called share
. This technique is both reliable and comes with a decent set of tools to make accessing these files pretty simple and easy. And lastly there are tools like JS, which installs js-cpan
, and exploits the fact that CPAN will also install non-Perl files it finds inside lib
alongside your regular Perl files.
So, what does Resource::Pack provide beyond these tools? Mostly it provides a framework which you can use to inspect and manipulate these non-Perl files, and most importantly it provides dependency management. Resource::Pack also can depend on files out on the internet as well and deal with them in the same way as it does local files.
So, this is all the docs I have for now, but more will come soon. This is an early release of this module so it should still be considered experimental and so used with caution. As always the best docs are probably the test files.
EXPORTS
Resource::Pack exports everything that Bread::Board exports, as well as:
resource NAME BODY
Defines a new Resource::Pack::Resource with name NAME, and runs BODY to populate it. This works similarly to container
in Bread::Board, except that it doesn't currently support parameters.
file NAME PARAMS
Defines a Resource::Pack::File object in the current resource, with the name NAME. PARAMS are passed to the Resource::Pack::File constructor, with a default parameter of file
if only one argument is passed.
dir NAME PARAMS
Defines a Resource::Pack::Dir object in the current resource, with the name NAME. PARAMS are passed to the Resource::Pack::Dir constructor, with a default parameter of dir
if only one argument is passed.
url
Defines a Resource::Pack::URL object in the current resource, with the name NAME. PARAMS are passed to the Resource::Pack::URL constructor, with a default parameter of url
if only one argument is passed.
install_to PATH
Sets the install_to
option for the current resource.
install_from PATH
Sets the install_from
option for the current resource.
install_as PATH
Sets the install_as
option for the current resource.
TODO
- Support for archive/zip files
-
It would be nice to be able to store a set of files inside an archive of some kind, and make it just as simple to inspect and unzip that archive. It would also be nice to allow downloading of zip files from the net.
- Symlink support
-
Currently Resource::Pack::Installable only supports copying files and directories. It would be nice to also support symlinking to the original files stored in the Perl @INC directories.
BUGS/CAVEATS
No known bugs.
Please report any bugs through RT: email bug-resource-pack at rt.cpan.org
, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Resource-Pack.
SEE ALSO
Please see those modules/websites for more information related to this module.
SUPPORT
You can find this documentation for this module with the perldoc command.
perldoc Resource::Pack
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
AUTHORS
Stevan Little <stevan.little@iinteractive.com>
Jesse Luehrs <doy at tozt dot net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.