package Resource::Pack::jQuery; use Moose; use Resource::Pack; extends 'Resource::Pack::Resource'; =head1 NAME Resource::Pack::jQuery - Resource::Pack resource for the jQuery Javascript library =head1 SYNOPSIS my $resource = Resource::Pack::jQuery->new( install_to => '/var/www/js', version => '1.4.2', ); $resource->install; =head1 DESCRIPTION This provides the jQuery library as a L resource. =cut =head1 ATTRIBUTES =cut =head2 version The desired jQuery version. Required, if C is false. =cut has version => ( is => 'ro', isa => 'Str', ); =head2 minified Whether or not the Javascript should be minified. Defaults to true. =cut has minified => ( is => 'ro', isa => 'Bool', default => 1, ); =head2 use_bundled If true, uses the bundled copy of jquery-1.4.2.min.js that is shipped with this dist (and ignores the other attributes). Otherwise, uses the values of C and C to download a copy of the library from L. =cut has use_bundled => ( is => 'ro', isa => 'Bool', default => 0, ); has '+name' => (default => 'jquery'); sub _jquery_url { my $self = shift; return 'http://code.jquery.com/jquery-' . $self->version . ($self->minified ? '.min' : '') . '.js'; } sub BUILD { my $self = shift; if (!defined($self->version) && !$self->use_bundled) { confess "version must be specified if use_bundled is false"; } resource $self => as { install_from(Path::Class::Dir->new(__FILE__)->parent); if ($self->use_bundled) { file js => 'jquery-1.4.2.min.js'; } else { url js => $self->_jquery_url; } }; } __PACKAGE__->meta->make_immutable; no Moose; no Resource::Pack; =head1 BUGS No known bugs. Please report any bugs through RT: email C, or browse to L. =head1 SEE ALSO L L =head1 SUPPORT You can find this documentation for this module with the perldoc command. perldoc Resource::Pack::jQuery You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 AUTHOR Jesse Luehrs John Resig is the author of jQuery =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Jesse Luehrs. This is free software; you can redistribute it and/or modify it under the same terms as perl itself. The bundled copy of jQuery is copyright (c) 2010 The jQuery Project. It is licensed under either the MIT license or the GPLv2. =cut 1;