diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-04-19 15:39:15 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-04-19 15:39:15 -0500 |
commit | 2f652ba783a4b8675a020955e494c64391eb0ab2 (patch) | |
tree | b1e6f0ee404fc911017d123a9c85559964c938cb /lib/Resource/Pack/JSON.pm | |
parent | 549b2365930137f85799ee1975b4b43dbdbdd290 (diff) | |
download | resource-pack-json-2f652ba783a4b8675a020955e494c64391eb0ab2.tar.gz resource-pack-json-2f652ba783a4b8675a020955e494c64391eb0ab2.zip |
initial implementation
Diffstat (limited to 'lib/Resource/Pack/JSON.pm')
-rw-r--r-- | lib/Resource/Pack/JSON.pm | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/lib/Resource/Pack/JSON.pm b/lib/Resource/Pack/JSON.pm index 7a6c626..9970688 100644 --- a/lib/Resource/Pack/JSON.pm +++ b/lib/Resource/Pack/JSON.pm @@ -1,20 +1,66 @@ package Resource::Pack::JSON; use Moose; +use Resource::Pack; + +use Resource::Pack::JSON::URL; + +extends 'Resource::Pack::Resource'; =head1 NAME -Resource::Pack::JSON - +Resource::Pack::JSON - Resource::Pack resource for the JSON Javascript library =head1 SYNOPSIS + my $resource = Resource::Pack::JSON->new(install_to => '/var/www/js'); + $resource->installl; =head1 DESCRIPTION +This provides the JSON library as a L<Resource::Pack> resource. + +=cut + +=head1 ATTRIBUTES + +=cut + +=head2 use_bundled + +If true, uses the bundled copy of json2.js that is shipped with this dist. +Otherwise, downloads a copy of the library from L<http://www.json.org/>. =cut +has use_bundled => ( + is => 'ro', + isa => 'Bool', + default => 0, +); + +has '+name' => (default => 'json'); + +sub BUILD { + my $self = shift; + + resource $self => as { + install_from(Path::Class::Dir->new(__FILE__)->parent); + if ($self->use_bundled) { + file js => 'json2.js'; + } + else { + $self->add_service(Resource::Pack::JSON::URL->new( + name => 'js', + url => 'http://www.json.org/json2.js', + parent => $self, + )); + } + }; +} + __PACKAGE__->meta->make_immutable; no Moose; +no Resource::Pack; =head1 BUGS @@ -26,6 +72,9 @@ L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Resource-Pack-JSON>. =head1 SEE ALSO +L<Resource::Pack> + +L<http://www.json.org/> =head1 SUPPORT @@ -66,6 +115,8 @@ 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 json2.js is in the public domain. + =cut 1; |