line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Types::Path::Class; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$MooseX::Types::Path::Class::VERSION = '0.06'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1820
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
93
|
|
7
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1891
|
use Path::Class (); |
|
2
|
|
|
|
|
118153
|
|
|
2
|
|
|
|
|
72
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use MooseX::Types |
12
|
2
|
|
|
2
|
|
2650
|
-declare => [qw( Dir File )]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use MooseX::Types::Moose qw(Str ArrayRef); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
class_type('Path::Class::Dir'); |
17
|
|
|
|
|
|
|
class_type('Path::Class::File'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
subtype Dir, as 'Path::Class::Dir'; |
20
|
|
|
|
|
|
|
subtype File, as 'Path::Class::File'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
for my $type ( 'Path::Class::Dir', Dir ) { |
23
|
|
|
|
|
|
|
coerce $type, |
24
|
|
|
|
|
|
|
from Str, via { Path::Class::Dir->new($_) }, |
25
|
|
|
|
|
|
|
from ArrayRef, via { Path::Class::Dir->new(@$_) }; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
for my $type ( 'Path::Class::File', File ) { |
29
|
|
|
|
|
|
|
coerce $type, |
30
|
|
|
|
|
|
|
from Str, via { Path::Class::File->new($_) }, |
31
|
|
|
|
|
|
|
from ArrayRef, via { Path::Class::File->new(@$_) }; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# optionally add Getopt option type |
35
|
|
|
|
|
|
|
eval { require MooseX::Getopt; }; |
36
|
|
|
|
|
|
|
if ( !$@ ) { |
37
|
|
|
|
|
|
|
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $_, '=s', ) |
38
|
|
|
|
|
|
|
for ( 'Path::Class::Dir', 'Path::Class::File', Dir, File, ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
MooseX::Types::Path::Class - A Path::Class type library for Moose |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package MyClass; |
53
|
|
|
|
|
|
|
use Moose; |
54
|
|
|
|
|
|
|
use MooseX::Types::Path::Class; |
55
|
|
|
|
|
|
|
with 'MooseX::Getopt'; # optional |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has 'dir' => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
isa => 'Path::Class::Dir', |
60
|
|
|
|
|
|
|
required => 1, |
61
|
|
|
|
|
|
|
coerce => 1, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has 'file' => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => 'Path::Class::File', |
67
|
|
|
|
|
|
|
required => 1, |
68
|
|
|
|
|
|
|
coerce => 1, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# these attributes are coerced to the |
72
|
|
|
|
|
|
|
# appropriate Path::Class objects |
73
|
|
|
|
|
|
|
MyClass->new( dir => '/some/directory/', file => '/some/file' ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
MooseX::Types::Path::Class creates common L<Moose> types, |
79
|
|
|
|
|
|
|
coercions and option specifications useful for dealing |
80
|
|
|
|
|
|
|
with L<Path::Class> objects as L<Moose> attributes. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Coercions (see L<Moose::Util::TypeConstraints>) are made |
83
|
|
|
|
|
|
|
from both 'Str' and 'ArrayRef' to both L<Path::Class::Dir> and |
84
|
|
|
|
|
|
|
L<Path::Class::File> objects. If you have L<MooseX::Getopt> installed, |
85
|
|
|
|
|
|
|
the Getopt option type ("=s") will be added for both |
86
|
|
|
|
|
|
|
L<Path::Class::Dir> and L<Path::Class::File>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 EXPORTS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
None of these are exported by default. They are provided via |
92
|
|
|
|
|
|
|
L<MooseX::Types>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item Dir, File |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
These exports can be used instead of the full class names. Example: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
package MyClass; |
101
|
|
|
|
|
|
|
use Moose; |
102
|
|
|
|
|
|
|
use MooseX::Types::Path::Class qw(Dir File); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has 'dir' => ( |
105
|
|
|
|
|
|
|
is => 'ro', |
106
|
|
|
|
|
|
|
isa => Dir, |
107
|
|
|
|
|
|
|
required => 1, |
108
|
|
|
|
|
|
|
coerce => 1, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
has 'file' => ( |
112
|
|
|
|
|
|
|
is => 'ro', |
113
|
|
|
|
|
|
|
isa => File, |
114
|
|
|
|
|
|
|
required => 1, |
115
|
|
|
|
|
|
|
coerce => 1, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Note that there are no quotes around Dir or File. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item is_Dir($value), is_File($value) |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns true or false based on whether $value is a valid Dir or File. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item to_Dir($value), to_File($value) |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Attempts to coerce $value to a Dir or File. Returns the coerced value |
127
|
|
|
|
|
|
|
or false if the coercion failed. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SEE ALSO |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<MooseX::Types::Path::Class::MoreCoercions>, L<MooseX::FileAttribute>, L<MooseX::Types::URI> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L<Moose>, L<MooseX::Types>, L<Path::Class> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If you find a bug please either email the author, or add |
145
|
|
|
|
|
|
|
the bug to cpan-RT L<http://rt.cpan.org>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Todd Hepler C<< <thepler@employees.org> >> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Copyright (c) 2007-2012, Todd Hepler C<< <thepler@employees.org> >>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
158
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|