[Catalyst-commits] r12031 - Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Thu Nov 26 02:23:00 GMT 2009


Author: t0m
Date: 2009-11-26 02:23:00 +0000 (Thu, 26 Nov 2009)
New Revision: 12031

Modified:
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Create.pm
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm
Log:
Factor restarter arg assembly out into it's own routine for ease of testing. Use $self->ARGV instead of $ARGV

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Create.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Create.pm	2009-11-26 01:53:20 UTC (rev 12030)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Create.pm	2009-11-26 02:23:00 UTC (rev 12031)
@@ -34,7 +34,7 @@
 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);

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm	2009-11-26 01:53:20 UTC (rev 12030)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm	2009-11-26 02:23:00 UTC (rev 12031)
@@ -119,8 +119,26 @@
     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 @@
 
         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;

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm	2009-11-26 01:53:20 UTC (rev 12030)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm	2009-11-26 02:23:00 UTC (rev 12031)
@@ -10,7 +10,7 @@
 
     Catalyst::Test->import($self->application_name);
 
-    print request($ARGV[0])->content  . "\n";
+    print request($self->ARGV->[0])->content  . "\n";
 }
 
 




More information about the Catalyst-commits mailing list