X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FDaemonize%2FPid%2FFile.pm;h=0f5177e60e73334746fdb968c7542236476646f2;hb=e446b464f9ee6a06c8a4bef8a393cfb96a5db4fe;hp=29ddd1f56647b46f5938eac1d40f0b4326144317;hpb=2db85b1892d3c761c2cdaaa540f1f9117592b349;p=gitmo%2FMooseX-Daemonize.git diff --git a/lib/MooseX/Daemonize/Pid/File.pm b/lib/MooseX/Daemonize/Pid/File.pm index 29ddd1f..0f5177e 100644 --- a/lib/MooseX/Daemonize/Pid/File.pm +++ b/lib/MooseX/Daemonize/Pid/File.pm @@ -1,10 +1,10 @@ +use strict; +use warnings; package MooseX::Daemonize::Pid::File; -use strict; # because Kwalitee is pedantic + use Moose; use Moose::Util::TypeConstraints; -our $VERSION = '0.01'; - use MooseX::Types::Path::Class; use MooseX::Getopt::OptionTypeMap; @@ -12,16 +12,16 @@ use MooseX::Getopt::OptionTypeMap; # set up some basic coercions # that will come in handy # - SL -coerce 'MooseX::Daemonize::Pid::File' - => from 'Str' +coerce 'MooseX::Daemonize::Pid::File' + => from 'Str' + => via { MooseX::Daemonize::Pid::File->new( file => $_ ) } + => from 'ArrayRef' => via { MooseX::Daemonize::Pid::File->new( file => $_ ) } - => from 'ArrayRef' - => via { MooseX::Daemonize::Pid::File->new( file => $_ ) } - => from 'Path::Class::File' + => from 'Path::Class::File' => via { MooseX::Daemonize::Pid::File->new( file => $_ ) }; - + # NOTE: -# make sure this class plays +# make sure this class plays # well with MooseX::Getopt # - SL MooseX::Getopt::OptionTypeMap->add_option_type_to_map( @@ -31,7 +31,7 @@ MooseX::Getopt::OptionTypeMap->add_option_type_to_map( extends 'MooseX::Daemonize::Pid'; has '+pid' => ( - default => sub { + default => sub { my $self = shift; $self->does_file_exist ? $self->file->slurp(chomp => 1) @@ -70,17 +70,17 @@ __END__ =head1 NAME MooseX::Daemonize::Pid::File - PID file management for MooseX::Daemonize - + =head1 DESCRIPTION This object extends L to add persistence in a Pidfile. -This class sets up some basic coercion routines for itself so that it can +This class sets up some basic coercion routines for itself so that it can be created from a I (a file name), I (an array of path components -for a filename) or a I object. +for a filename) or a I object. This class registers it's type with L as well, and is expected -to be passed on the command line as a string (which will then go through the +to be passed on the command line as a string (which will then go through the coercion routines mentioned above). =head1 ATTRIBUTES @@ -89,14 +89,14 @@ coercion routines mentioned above). =item I -This is inherited from L and extended here to +This is inherited from L and extended here to get it's default value from the Pidfile (if available). =item I =back -=head1 METHODS +=head1 METHODS =over @@ -104,7 +104,7 @@ get it's default value from the Pidfile (if available). =item B -Both of these methods are inherited from L see that +Both of these methods are inherited from L see that module for more information. =item B @@ -152,7 +152,7 @@ Stevan Little C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007, Chris Prather C<< >>. All rights +Copyright (c) 2007-2011, Chris Prather C<< >>. All rights reserved. This module is free software; you can redistribute it and/or