[Catalyst-commits] r12065 -
Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Sun Nov 29 14:00:26 GMT 2009
Author: rafl
Date: 2009-11-29 14:00:25 +0000 (Sun, 29 Nov 2009)
New Revision: 12065
Modified:
Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm
Log:
Properly validate restart regexen.
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-29 14:00:19 UTC (rev 12064)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm 2009-11-29 14:00:25 UTC (rev 12065)
@@ -6,7 +6,7 @@
}
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,15 +101,25 @@
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)],
cmd_aliases => 'sym',
@@ -129,7 +139,7 @@
($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;
More information about the Catalyst-commits
mailing list