X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FScriptRunner.pm;h=c0bb27a85a973c6186d3ed0390ee60122e8e9fec;hb=12a3e3b57d656c7c48fb3b4b5ca444cb3bfc9360;hp=ec5555e9e35f3b648764f2938f8e76797559f912;hpb=d24d92d9ed09f3cbd48356058429849e7c66ed73;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/ScriptRunner.pm b/lib/Catalyst/ScriptRunner.pm index ec5555e..c0bb27a 100644 --- a/lib/Catalyst/ScriptRunner.pm +++ b/lib/Catalyst/ScriptRunner.pm @@ -1,15 +1,48 @@ package Catalyst::ScriptRunner; use Moose; +use FindBin; +use lib; +use File::Spec; +use namespace::autoclean; sub run { my ($self, $class, $scriptclass) = @_; - my $classtoload = "${class}::Script::$scriptclass"; - - if ( Class::MOP::load_class($classtoload) ) { - $classtoload->new_with_options->run; - } else { + my $classtoload = "${class}::Script::$scriptclass"; + + lib->import(File::Spec->catdir($FindBin::Bin, '..', 'lib')); + + # FIXME - Error handling / reporting + if ( eval { Class::MOP::load_class($classtoload) } ) { + } + else { $classtoload = "Catalyst::Script::$scriptclass"; - $classtoload->new_with_options->run; + Class::MOP::load_class($classtoload); } + $classtoload->new_with_options( application_name => $class )->run; } -1; + +__PACKAGE__->meta->make_immutable; + +=head1 NAME + +Catalyst::ScriptRunner - The Catalyst Framework Script runner + +=head1 SYNOPSIS + +See L. + +=head1 DESCRIPTION + +This class is responsible for running scripts, either in the application specific namespace +(e.g. C), or the Catalyst namespace (e.g. C) + +=head1 AUTHORS + +Catalyst Contributors, see Catalyst.pm + +=head1 COPYRIGHT + +This library is free software. You can redistribute it and/or modify it under +the same terms as Perl itself. + +=cut