reverting (most of) the whitespace changes
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / HTTP / Restarter / Watcher.pm
index 3062dc6..847fb0d 100644 (file)
@@ -1,20 +1,17 @@
 package Catalyst::Engine::HTTP::Restarter::Watcher;
 
-use strict;
-use warnings;
-use base 'Class::Accessor::Fast';
+use Moose;
 use File::Find;
 use File::Modified;
 use File::Spec;
 use Time::HiRes qw/sleep/;
 
-__PACKAGE__->mk_accessors(
-    qw/delay
-      directory
-      modified
-      regex
-      watch_list/
-);
+has delay => (is => 'rw');
+has regex => (is => 'rw');
+has modified => (is => 'rw');
+has directory => (is => 'rw');
+has watch_list => (is => 'rw');
+has follow_simlinks => (is => 'rw');
 
 sub new {
     my ( $class, %args ) = @_;
@@ -47,8 +44,10 @@ sub watch {
 
     my @changes;
     my @changed_files;
+    
+    my $delay = ( defined $self->delay ) ? $self->delay : 1;
 
-    sleep $self->delay || 1;
+    sleep $delay if $delay > 0;
 
     eval { @changes = $self->modified->changed };
     if ($@) {
@@ -100,7 +99,9 @@ sub watch {
 sub _index_directory {
     my $self = shift;
 
-    my $dir   = $self->directory || die "No directory specified";
+    my $dir   = $self->directory;
+    die "No directory specified" if !$dir or ref($dir) && !@{$dir};
+
     my $regex = $self->regex     || '\.pm$';
     my %list;
 
@@ -118,9 +119,10 @@ sub _index_directory {
                 $cur_dir =~ s{/script/..}{};
                 $list{$cur_dir} = 1;
             },
+            follow_fast => $self->follow_symlinks ? 1 : 0,
             no_chdir => 1
         },
-        $dir
+        ref $dir eq 'ARRAY' ? @{$dir} : $dir
     );
     return \%list;
 }