X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FScriptRunner.pm;h=c0bb27a85a973c6186d3ed0390ee60122e8e9fec;hb=12a3e3b57d656c7c48fb3b4b5ca444cb3bfc9360;hp=f8c5c51c56427aa9b269ee7c54bcacc2aba3681b;hpb=cc999ce24cf699811485469692101bd6ad1ab27d;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/ScriptRunner.pm b/lib/Catalyst/ScriptRunner.pm index f8c5c51..c0bb27a 100644 --- a/lib/Catalyst/ScriptRunner.pm +++ b/lib/Catalyst/ScriptRunner.pm @@ -1,10 +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"; - Class::MOP::load_class($classtoload); - $classtoload->new_with_options->run; + 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"; + 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