[Catalyst-commits] r9987 - Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst

autarch at dev.catalyst.perl.org autarch at dev.catalyst.perl.org
Sat May 2 02:01:05 GMT 2009


Author: autarch
Date: 2009-05-02 02:01:04 +0000 (Sat, 02 May 2009)
New Revision: 9987

Added:
   Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Watcher.pm
Log:
forgot to re-add Watcher.pm

Added: Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Watcher.pm
===================================================================
--- Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Watcher.pm	                        (rev 0)
+++ Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Watcher.pm	2009-05-02 02:01:04 UTC (rev 9987)
@@ -0,0 +1,58 @@
+package Catalyst::Watcher;
+
+use Moose;
+use Moose::Util::TypeConstraints;
+
+use Cwd qw( abs_path );
+use File::Spec;
+use FindBin;
+use namespace::clean -except => 'meta';
+
+has regex => (
+    is      => 'ro',
+    isa     => 'RegexpRef',
+    default => sub { qr/(?:\/|^)(?!\.\#).+(?:\.yml$|\.yaml$|\.conf|\.pm)$/ },
+);
+
+my $dir = subtype
+       as 'Str'
+    => where { -d $_ }
+    => message { "$_ is not a valid directory" };
+
+my $array_of_dirs = subtype
+       as 'ArrayRef[Str]',
+    => where { map { -d } @{$_} }
+    => message { "@{$_} is not a list of valid directories" };
+
+coerce $array_of_dirs
+    => from $dir
+    => via { [ $_ ] };
+
+has directories => (
+    is      => 'ro',
+    isa     => $array_of_dirs,
+    default => sub { [ abs_path( File::Spec->catdir( $FindBin::Bin, '..' ) ) ] },
+    coerce  => 1,
+);
+
+has follow_symlinks => (
+    is      => 'ro',
+    isa     => 'Bool',
+    default => 0,
+);
+
+sub instantiate_subclass {
+    my $class = shift;
+
+    if ( eval { require Catalyst::Watcher::Inotify; 1; } ) {
+        return Catalyst::Watcher::Inotify->new(@_);
+    }
+    else {
+        require Catalyst::Watcher::FileModified;
+        return Catalyst::Watcher::FileModified->new(@_);
+    }
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;


Property changes on: Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Watcher.pm
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Rev
Name: svn:eol-style
   + native




More information about the Catalyst-commits mailing list