From: Jesse Luehrs Date: Thu, 15 Apr 2010 20:25:28 +0000 (-0500) Subject: convert the resource classes to use the new Resource::Pack api X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5f71bb62ca1f6f8e51d3b9fd59d536e2a4593e21;p=gitmo%2Fmoose-website.git convert the resource classes to use the new Resource::Pack api --- diff --git a/lib/Moose/Website.pm b/lib/Moose/Website.pm index 95e0f09..3c93f3f 100644 --- a/lib/Moose/Website.pm +++ b/lib/Moose/Website.pm @@ -47,18 +47,19 @@ has 'template_resource' => ( default => sub { Moose::Website::Resource::Templates->new }, - handles => { - 'template_root' => 'dir' - } ); +sub template_root { + shift->template_resource->fetch('template_dir')->install_from_absolute; +} + has 'web_file_resource' => ( traits => [ 'NoGetopt' ], is => 'ro', isa => 'Moose::Website::Resource::WebFiles', lazy => 1, default => sub { - Moose::Website::Resource::WebFiles->new + Moose::Website::Resource::WebFiles->new(install_to => shift->outdir) }, ); @@ -128,7 +129,7 @@ sub run { } $self->log( "Copying web resources to " . $self->outdir ); - $self->web_file_resource->copy( to => $self->outdir, include_deps => 1 ); + $self->web_file_resource->install; } sub build_template_params { diff --git a/lib/Moose/Website/Resource/Templates.pm b/lib/Moose/Website/Resource/Templates.pm index ba8dfa2..cab2a89 100644 --- a/lib/Moose/Website/Resource/Templates.pm +++ b/lib/Moose/Website/Resource/Templates.pm @@ -1,18 +1,30 @@ package Moose::Website::Resource::Templates; use Moose; +use Resource::Pack; our $VERSION = '0.01'; our $AUTHORITY = 'cpan:STEVAN'; -with 'Resource::Pack' => { - traits => [ - 'Resource::Pack::Dir' - ] -}; +extends 'Resource::Pack::Resource'; + +has '+name' => (default => 'templates'); + +sub BUILD { + my $self = shift; + + resource $self => as { + install_from(Path::Class::File->new(__FILE__)->parent + ->subdir('Templates')); + dir template_dir => ( + dir => '.', + install_as => '', + ); + }; +} __PACKAGE__->meta->make_immutable; -no Moose; 1; +no Moose; no Resource::Pack; 1; __END__ diff --git a/lib/Moose/Website/Resource/WebFiles.pm b/lib/Moose/Website/Resource/WebFiles.pm index f1fb51f..763bc0e 100644 --- a/lib/Moose/Website/Resource/WebFiles.pm +++ b/lib/Moose/Website/Resource/WebFiles.pm @@ -1,21 +1,37 @@ package Moose::Website::Resource::WebFiles; use Moose; +use Resource::Pack; + +use Moose::Website::Resource::jQuery; our $VERSION = '0.01'; our $AUTHORITY = 'cpan:STEVAN'; -with 'Resource::Pack' => { - traits => [ - 'Resource::Pack::Dir' - ], - depends_on => [ - 'Moose::Website::Resource::jQuery' - ] -}; +extends 'Resource::Pack::Resource'; + +has '+name' => (default => 'webfiles'); + +sub BUILD { + my $self = shift; + + resource $self => as { + install_from(Path::Class::File->new(__FILE__)->parent + ->subdir('WebFiles')); + + resource(Moose::Website::Resource::jQuery->new); + + dir 'css'; + dir 'images'; + dir js => ( + dir => 'js', + dependencies => ['jquery/core'], + ); + }; +} __PACKAGE__->meta->make_immutable; -no Moose; 1; +no Moose; no Resource::Pack; 1; __END__ diff --git a/lib/Moose/Website/Resource/jQuery.pm b/lib/Moose/Website/Resource/jQuery.pm index 330e9ff..2d3ca74 100644 --- a/lib/Moose/Website/Resource/jQuery.pm +++ b/lib/Moose/Website/Resource/jQuery.pm @@ -1,21 +1,26 @@ package Moose::Website::Resource::jQuery; use Moose; +use Resource::Pack; our $VERSION = '0.01'; our $AUTHORITY = 'cpan:STEVAN'; -with 'Resource::Pack' => { - traits => [ - 'Resource::Pack::URL' => { - url => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', - sub_dir => 'js' - } - ] -}; +extends 'Resource::Pack::Resource'; + +has '+name' => (default => 'jquery'); + +sub BUILD { + my $self = shift; + + resource $self => as { + install_to 'js'; + url core => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'; + }; +} __PACKAGE__->meta->make_immutable; -no Moose; 1; +no Moose; no Resource::Pack; 1; __END__