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 ) = @_;
+no Moose;
- my $self = {%args};
-
- bless $self, $class;
-
- $self->_init;
-
- return $self;
+sub BUILD {
+ shift->_init;
}
sub _init {
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;
$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;
}
my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new(
directory => '/path/to/MyApp',
- regex => '\.yml$|\.yaml$|\.pm$',
+ regex => '\.yml$|\.yaml$|\.conf|\.pm$',
delay => 1,
);
=head1 AUTHORS
-Sebastian Riedel, <sri@cpan.org>
-
-Andy Grundman, <andy@hybridized.org>
+Catalyst Contributors, see Catalyst.pm
=head1 THANKS