Resource::Pack - tools for managing application resources
version 0.03
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;
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.
share
js-cpan
lib
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.
Resource::Pack exports everything that Bread::Board exports, as well as:
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.
container
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.
file
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.
dir
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.
url
Sets the install_to option for the current resource.
install_to
Sets the install_from option for the current resource.
install_from
Sets the install_as option for the current resource.
install_as
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.
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.
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.
bug-resource-pack at rt.cpan.org
Please see those modules/websites for more information related to this module.
JS
File::ShareDir
Bread::Board
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
http://annocpan.org/dist/Resource-Pack
CPAN Ratings
http://cpanratings.perl.org/d/Resource-Pack
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Resource-Pack
Search CPAN
http://search.cpan.org/dist/Resource-Pack
Stevan Little <stevan.little@iinteractive.com>
Jesse Luehrs <doy at tozt dot net>
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.
To install Resource::Pack, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Resource::Pack
CPAN shell
perl -MCPAN -e shell install Resource::Pack
For more information on module installation, please visit the detailed CPAN module installation guide.