X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FScript%2FServer.pm;h=d65a2314125319afe14398ed177b5d8e0f44a7c2;hb=880d1f8b5a10f28ce1142898058a26b6506f1cfe;hp=caa148ac93228bdd6bc8903c77fc64f356a44714;hpb=34be7d45d60869f19ba27d64dc1bbf0df4c6ccba;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index caa148a..d65a231 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -6,7 +6,7 @@ BEGIN { } use Moose; -use MooseX::Types::Moose qw/ArrayRef Str Bool Int/; +use MooseX::Types::Moose qw/ArrayRef Str Bool Int RegexpRef/; use namespace::autoclean; with 'Catalyst::ScriptRole'; @@ -101,14 +101,24 @@ has restart_delay => ( predicate => '_has_restart_delay', ); -has restart_regex => ( - traits => [qw(Getopt)], - cmd_aliases => 'rr', - isa => Str, - is => 'ro', - documentation => 'Restart regex', - predicate => '_has_restart_regex', -); +{ + use Moose::Util::TypeConstraints; + + my $tc = subtype as RegexpRef; + coerce $tc, from Str, via { qr/$_/ }; + + MooseX::Getopt::OptionTypeMap->add_option_type_to_map($tc => '=s'); + + has restart_regex => ( + traits => [qw(Getopt)], + cmd_aliases => 'rr', + isa => $tc, + coerce => 1, + is => 'ro', + documentation => 'Restart regex', + predicate => '_has_restart_regex', + ); +} has follow_symlinks => ( traits => [qw(Getopt)], @@ -129,7 +139,7 @@ sub _restarter_args { ($self->_has_follow_symlinks ? (follow_symlinks => $self->follow_symlinks) : ()), ($self->_has_restart_delay ? (sleep_interval => $self->restart_delay) : ()), ($self->_has_restart_directory ? (directories => $self->restart_directory) : ()), - ($self->_has_restart_regex ? (filter => qr/${\$self->restart_regex}/) : ()), + ($self->_has_restart_regex ? (filter => $self->restart_regex) : ()), ); return %args;