line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
917369
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
84
|
|
2
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
199
|
|
3
|
|
|
|
|
|
|
package MooseX::Types::Path::Class; # git description: v0.07-6-g6afe19a |
4
|
|
|
|
|
|
|
# ABSTRACT: A Path::Class type library for Moose |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
2169
|
use Path::Class 0.16 (); |
|
3
|
|
|
|
|
144018
|
|
|
3
|
|
|
|
|
103
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use MooseX::Types |
11
|
3
|
|
|
3
|
|
2591
|
-declare => [qw( Dir File )]; |
|
3
|
|
|
|
|
588049
|
|
|
3
|
|
|
|
|
22
|
|
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
15843
|
use MooseX::Types::Moose qw(Str ArrayRef); |
|
3
|
|
|
|
|
46355
|
|
|
3
|
|
|
|
|
28
|
|
14
|
3
|
|
|
3
|
|
14602
|
use if MooseX::Types->VERSION >= 0.42, 'namespace::autoclean'; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
81
|
|
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
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding UTF-8 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
MooseX::Types::Path::Class - A Path::Class type library for Moose |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 VERSION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
version 0.08 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
package MyClass; |
60
|
|
|
|
|
|
|
use Moose; |
61
|
|
|
|
|
|
|
use MooseX::Types::Path::Class; |
62
|
|
|
|
|
|
|
with 'MooseX::Getopt'; # optional |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has 'dir' => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => 'Path::Class::Dir', |
67
|
|
|
|
|
|
|
required => 1, |
68
|
|
|
|
|
|
|
coerce => 1, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has 'file' => ( |
72
|
|
|
|
|
|
|
is => 'ro', |
73
|
|
|
|
|
|
|
isa => 'Path::Class::File', |
74
|
|
|
|
|
|
|
required => 1, |
75
|
|
|
|
|
|
|
coerce => 1, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# these attributes are coerced to the |
79
|
|
|
|
|
|
|
# appropriate Path::Class objects |
80
|
|
|
|
|
|
|
MyClass->new( dir => '/some/directory/', file => '/some/file' ); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
MooseX::Types::Path::Class creates common L<Moose> types, |
85
|
|
|
|
|
|
|
coercions and option specifications useful for dealing |
86
|
|
|
|
|
|
|
with L<Path::Class> objects as L<Moose> attributes. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Coercions (see L<Moose::Util::TypeConstraints>) are made |
89
|
|
|
|
|
|
|
from both C<Str> and C<ArrayRef> to both L<Path::Class::Dir> and |
90
|
|
|
|
|
|
|
L<Path::Class::File> objects. If you have L<MooseX::Getopt> installed, |
91
|
|
|
|
|
|
|
the C<Getopt> option type ("=s") will be added for both |
92
|
|
|
|
|
|
|
L<Path::Class::Dir> and L<Path::Class::File>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 EXPORTS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
None of these are exported by default. They are provided via |
97
|
|
|
|
|
|
|
L<MooseX::Types>. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item Dir, File |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
These exports can be used instead of the full class names. Example: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
package MyClass; |
106
|
|
|
|
|
|
|
use Moose; |
107
|
|
|
|
|
|
|
use MooseX::Types::Path::Class qw(Dir File); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has 'dir' => ( |
110
|
|
|
|
|
|
|
is => 'ro', |
111
|
|
|
|
|
|
|
isa => Dir, |
112
|
|
|
|
|
|
|
required => 1, |
113
|
|
|
|
|
|
|
coerce => 1, |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
has 'file' => ( |
117
|
|
|
|
|
|
|
is => 'ro', |
118
|
|
|
|
|
|
|
isa => File, |
119
|
|
|
|
|
|
|
required => 1, |
120
|
|
|
|
|
|
|
coerce => 1, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Note that there are no quotes around C<Dir> or C<File>. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item is_Dir($value), is_File($value) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns true or false based on whether $value is a valid C<Dir> or C<File>. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item to_Dir($value), to_File($value) |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Attempts to coerce $value to a C<Dir> or C<File>. Returns the coerced value |
132
|
|
|
|
|
|
|
or false if the coercion failed. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SEE ALSO |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<MooseX::Types::Path::Class::MoreCoercions>, L<MooseX::FileAttribute>, L<MooseX::Types::URI> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<Moose>, L<MooseX::Types>, L<Path::Class> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
If you find a bug please either email the author, or add |
147
|
|
|
|
|
|
|
the bug to cpan-RT L<http://rt.cpan.org>. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Todd Hepler <thepler@employees.org> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=for stopwords Karen Etheridge Jonathan Rockway Yuval Kogman |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=over 4 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Jonathan Rockway <jon@jrock.us> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Yuval Kogman <nothingmuch@woobling.org> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Todd Hepler. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
178
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |