X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP%2FRestarter%2FWatcher.pm;h=9ab30b8224c86fd981baa12aad005f626a47ad6b;hb=f7174b10f4947f055cabceef2c7c888ba94e5899;hp=c01345003ddefbebb874699bb0c2c58e4de059d9;hpb=951572c08d33e8364f5cc49286f144015b80b5f9;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm b/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm index c013450..9ab30b8 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm @@ -1,31 +1,22 @@ 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_symlinks => (is => 'rw'); -sub new { - my ( $class, %args ) = @_; +no Moose; - my $self = {%args}; - - bless $self, $class; - - $self->_init; - - return $self; +sub BUILD { + shift->_init; } sub _init { @@ -102,7 +93,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; @@ -120,9 +113,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; } @@ -153,7 +147,7 @@ files my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new( directory => '/path/to/MyApp', - regex => '\.yml$|\.yaml$|\.pm$', + regex => '\.yml$|\.yaml$|\.conf|\.pm$', delay => 1, ); @@ -184,9 +178,7 @@ L, L, L =head1 AUTHORS -Sebastian Riedel, - -Andy Grundman, +Catalyst Contributors, see Catalyst.pm =head1 THANKS