From: Todd Hepler Date: Wed, 28 Nov 2007 19:30:57 +0000 (+0000) Subject: refactored so there's less code X-Git-Tag: 0_04~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Path-Class.git;a=commitdiff_plain;h=52e426e59502b1559aaf3335ca9fec4e4903d88a refactored so there's less code added $AUTHORITY pod tweak --- diff --git a/lib/MooseX/Types/Path/Class.pm b/lib/MooseX/Types/Path/Class.pm index 4adfdeb..1fd8b83 100644 --- a/lib/MooseX/Types/Path/Class.pm +++ b/lib/MooseX/Types/Path/Class.pm @@ -3,7 +3,8 @@ package MooseX::Types::Path::Class; use warnings FATAL => 'all'; use strict; -our $VERSION = '0.02'; +our $VERSION = '0.03'; +our $AUTHORITY = 'cpan:THEPLER'; use MooseX::Getopt; use Path::Class (); @@ -13,53 +14,33 @@ use MooseX::Types use MooseX::Types::Moose qw(Object Str ArrayRef); -subtype Dir, - as Object, where { $_->isa('Path::Class::Dir') }; +for my $type ( Dir, 'Path::Class::Dir' ) { -coerce Dir, - from Str, via { Path::Class::Dir->new($_) }, - from ArrayRef, via { Path::Class::Dir->new(@$_) }; + subtype $type, + as Object, where { $_->isa('Path::Class::Dir') }; -MooseX::Getopt::OptionTypeMap->add_option_type_to_map( - Dir, '=s', -); + coerce $type, + from Str, via { Path::Class::Dir->new($_) }, + from ArrayRef, via { Path::Class::Dir->new(@$_) }; + MooseX::Getopt::OptionTypeMap->add_option_type_to_map( + $type, '=s', + ); +} -subtype 'Path::Class::Dir', - as Object, where { $_->isa('Path::Class::Dir') }; +for my $type ( File, 'Path::Class::File' ) { -coerce 'Path::Class::Dir', - from Str, via { Path::Class::Dir->new($_) }, - from ArrayRef, via { Path::Class::Dir->new(@$_) }; + subtype $type, + as Object, where { $_->isa('Path::Class::File') }; -MooseX::Getopt::OptionTypeMap->add_option_type_to_map( - 'Path::Class::Dir', '=s', -); - - -subtype File, - as Object, where { $_->isa('Path::Class::File') }; - -coerce File, - from Str, via { Path::Class::File->new($_) }, - from ArrayRef, via { Path::Class::File->new(@$_) }; - -MooseX::Getopt::OptionTypeMap->add_option_type_to_map( - File, '=s', -); - - -subtype 'Path::Class::File', - as Object, where { $_->isa('Path::Class::File') }; - -coerce 'Path::Class::File', - from Str, via { Path::Class::File->new($_) }, - from ArrayRef, via { Path::Class::File->new(@$_) }; - -MooseX::Getopt::OptionTypeMap->add_option_type_to_map( - 'Path::Class::File', '=s', -); + coerce $type, + from Str, via { Path::Class::File->new($_) }, + from ArrayRef, via { Path::Class::File->new(@$_) }; + MooseX::Getopt::OptionTypeMap->add_option_type_to_map( + $type, '=s', + ); +} 1; __END__ @@ -131,7 +112,9 @@ L, L, L, L =head1 BUGS AND LIMITATIONS -No bugs have been reported. +All complex software has bugs lurking in it, and this module is +no exception. If you find a bug please either email the author, or add +the bug to cpan-RT L. =head1 AUTHOR