From: Tomas Doran Date: Thu, 26 Nov 2009 02:23:00 +0000 (+0000) Subject: Factor restarter arg assembly out into it's own routine for ease of testing. Use... X-Git-Tag: 5.80014_02~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=3453b9295cbc4a512f28f5130994d698fcc5e250 Factor restarter arg assembly out into it's own routine for ease of testing. Use $self->ARGV instead of $ARGV --- diff --git a/lib/Catalyst/Script/Create.pm b/lib/Catalyst/Script/Create.pm index 361aa26..e65a597 100644 --- a/lib/Catalyst/Script/Create.pm +++ b/lib/Catalyst/Script/Create.pm @@ -34,7 +34,7 @@ has helper_class => ( isa => 'Str', is => 'ro', default => 'Catalyst::Helper' ); sub run { my ($self) = @_; - $self->_exit_with_usage if !$ARGV[0]; + $self->_exit_with_usage if !$self->ARGV->[0]; my $helper_class = $self->helper_class; Class::MOP::load_class($helper_class); diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index c3c6584..68e6b85 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -119,8 +119,26 @@ has follow_symlinks => ( documentation => 'Follow symbolic links', ); +sub _restarter_args { + my $self = shift; + my %args; + $args{follow_symlinks} = $self->follow_symlinks + if $self->follow_symlinks; + $args{directories} = $self->restart_directory + if $self->_has_restart_directory; + $args{sleep_interval} = $self->restart_delay + if $self->_has_restart_delay; + if ($self->_has_restart_regex) { + my $regex = $self->restart_regex; + $args{filter} = qr/$regex/; + } + $args{start_sub} = sub { $self->_run_application }; + $args{argv} = $self->ARGV; + return %args; +} + sub run { - my ($self) = shift; + my $self = shift; local $ENV{CATALYST_DEBUG} = 1 if $self->debug; @@ -141,20 +159,9 @@ sub run { my $subclass = Catalyst::Restarter->pick_subclass; - my %args; - $args{follow_symlinks} = $self->follow_symlinks - if $self->follow_symlinks; - $args{directories} = $self->restart_directory - if $self->_has_restart_directory; - $args{sleep_interval} = $self->restart_delay - if $self->_has_restart_delay; - $args{filter} = qr/$self->restart_regex/ - if $self->_has_restart_regex; - + my $restarter = $subclass->new( - %args, - start_sub => sub { $self->_run_application }, - argv => $self->ARGV, + $self->_restarter_args() ); $restarter->run_and_watch; diff --git a/lib/Catalyst/Script/Test.pm b/lib/Catalyst/Script/Test.pm index a05b182..53473a4 100644 --- a/lib/Catalyst/Script/Test.pm +++ b/lib/Catalyst/Script/Test.pm @@ -10,7 +10,7 @@ sub run { Catalyst::Test->import($self->application_name); - print request($ARGV[0])->content . "\n"; + print request($self->ARGV->[0])->content . "\n"; }