1 package MooseX::Types::Path::Class;
3 use warnings FATAL => 'all';
7 our $AUTHORITY = 'cpan:THEPLER';
13 -declare => [qw( Dir File )];
15 use MooseX::Types::Moose qw(Object Str ArrayRef);
17 for my $type ( Dir, 'Path::Class::Dir' ) {
20 as Object, where { $_->isa('Path::Class::Dir') };
23 from Str, via { Path::Class::Dir->new($_) },
24 from ArrayRef, via { Path::Class::Dir->new(@$_) };
26 MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
31 for my $type ( File, 'Path::Class::File' ) {
34 as Object, where { $_->isa('Path::Class::File') };
37 from Str, via { Path::Class::File->new($_) },
38 from ArrayRef, via { Path::Class::File->new(@$_) };
40 MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
50 MooseX::Types::Path::Class - A Path::Class type library for Moose
57 use MooseX::Types::Path::Class qw( Dir File );
58 with 'MooseX::Getopt'; # if you want the Getopt Role
74 # these attributes are coerced to the
75 # appropriate Path::Class objects
76 MyClass->new( dir => '/some/directory/', file => '/some/file' );
81 This is a utility that creates common L<Moose> subtypes, coercions and
82 option specifications useful for dealing with L<Path::Class> objects
83 as L<Moose> attributes.
85 This module constructs coercions (see L<Moose::Util::TypeConstraints>)
86 from both 'Str' and 'ArrayRef' to both L<Path::Class::Dir> and
87 L<Path::Class::File> objects. It also adds the Getopt option type
88 ("=s") for both L<Path::Class::Dir> and L<Path::Class::File>
89 (see L<MooseX::Getopt>).
91 This is just meant to be a central place for these constructs, so you
92 don't have to worry about whether they've been created or not, and you're
93 not tempted to copy them into yet another class (like I was).
97 See L<MooseX::Types> for how these exports work.
101 =item Dir is_Dir to_Dir
103 =item File is_File to_File
110 L<Moose>, L<MooseX::Types>, L<MooseX::Getopt>, L<Path::Class>
113 =head1 BUGS AND LIMITATIONS
115 All complex software has bugs lurking in it, and this module is
116 no exception. If you find a bug please either email the author, or add
117 the bug to cpan-RT L<http://rt.cpan.org>.
122 Todd Hepler C<< <thepler@employees.org> >>
125 =head1 LICENCE AND COPYRIGHT
127 Copyright (c) 2007, Todd Hepler C<< <thepler@employees.org> >>. All rights reserved.
129 This module is free software; you can redistribute it and/or
130 modify it under the same terms as Perl itself. See L<perlartistic>.