| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
71510
|
use 5.008001; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
37
|
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Types::Path::Tiny; |
|
6
|
|
|
|
|
|
|
# ABSTRACT: Path::Tiny types and coercions for Moose and Moo |
|
7
|
|
|
|
|
|
|
our $VERSION = '0.005'; # VERSION |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
10
|
use Path::Tiny qw(); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
31
|
|
|
10
|
1
|
|
|
1
|
|
1046
|
use Type::Library 0.008 -base, -declare => qw( Path AbsPath File AbsFile Dir AbsDir ); |
|
|
1
|
|
|
|
|
30535
|
|
|
|
1
|
|
|
|
|
14
|
|
|
11
|
1
|
|
|
1
|
|
3803
|
use Type::Utils; |
|
|
1
|
|
|
|
|
5345
|
|
|
|
1
|
|
|
|
|
14
|
|
|
12
|
1
|
|
|
1
|
|
2385
|
use Types::Standard qw( Str ArrayRef ); |
|
|
1
|
|
|
|
|
51105
|
|
|
|
1
|
|
|
|
|
14
|
|
|
13
|
1
|
|
|
1
|
|
955
|
use Types::TypeTiny 0.004 StringLike => { -as => "Stringable" }; |
|
|
1
|
|
|
|
|
37
|
|
|
|
1
|
|
|
|
|
10
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#<<< |
|
16
|
|
|
|
|
|
|
class_type Path, { class => "Path::Tiny" }; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
declare AbsPath, |
|
19
|
|
|
|
|
|
|
as Path, where { $_->is_absolute }, |
|
20
|
|
|
|
|
|
|
inline_as { $_[0]->parent->inline_check($_) . "&& ${_}->is_absolute" }, |
|
21
|
|
|
|
|
|
|
message { |
|
22
|
|
|
|
|
|
|
is_Path($_) ? "Path '$_' is not absolute" : Path->get_message($_); |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
declare File, |
|
26
|
|
|
|
|
|
|
as Path, where { $_->is_file }, |
|
27
|
|
|
|
|
|
|
inline_as { $_[0]->parent->inline_check($_) . "&& (-f $_)" }, |
|
28
|
|
|
|
|
|
|
message { |
|
29
|
|
|
|
|
|
|
is_Path($_) ? "File '$_' does not exist" : Path->get_message($_); |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
declare Dir, |
|
33
|
|
|
|
|
|
|
as Path, where { $_->is_dir }, |
|
34
|
|
|
|
|
|
|
inline_as { $_[0]->parent->inline_check($_) . "&& (-d $_)" }, |
|
35
|
|
|
|
|
|
|
message { |
|
36
|
|
|
|
|
|
|
is_Path($_) ? "Directory '$_' does not exist" : Path->get_message($_); |
|
37
|
|
|
|
|
|
|
}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
declare AbsFile, |
|
40
|
|
|
|
|
|
|
as intersection([AbsPath, File]), |
|
41
|
|
|
|
|
|
|
message { |
|
42
|
|
|
|
|
|
|
is_AbsPath($_) ? File->get_message($_) : AbsPath->get_message($_); |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
declare AbsDir, |
|
46
|
|
|
|
|
|
|
as intersection([AbsPath, Dir]), |
|
47
|
|
|
|
|
|
|
message { |
|
48
|
|
|
|
|
|
|
is_AbsPath($_) ? Dir->get_message($_) : AbsPath->get_message($_); |
|
49
|
|
|
|
|
|
|
}; |
|
50
|
|
|
|
|
|
|
#>>> |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
for my $type ( Path, File, Dir ) { |
|
53
|
|
|
|
|
|
|
coerce( |
|
54
|
|
|
|
|
|
|
$type, |
|
55
|
|
|
|
|
|
|
from Str() => q{ Path::Tiny::path($_) }, |
|
56
|
|
|
|
|
|
|
from Stringable() => q{ Path::Tiny::path($_) }, |
|
57
|
|
|
|
|
|
|
from ArrayRef() => q{ Path::Tiny::path(@$_) }, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
for my $type ( AbsPath, AbsFile, AbsDir ) { |
|
62
|
|
|
|
|
|
|
coerce( |
|
63
|
|
|
|
|
|
|
$type, |
|
64
|
|
|
|
|
|
|
from Path => q{ $_->absolute }, |
|
65
|
|
|
|
|
|
|
from Str() => q{ Path::Tiny::path($_)->absolute }, |
|
66
|
|
|
|
|
|
|
from Stringable() => q{ Path::Tiny::path($_)->absolute }, |
|
67
|
|
|
|
|
|
|
from ArrayRef() => q{ Path::Tiny::path(@$_)->absolute }, |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
### optionally add Getopt option type (adapted from MooseX::Types:Path::Class |
|
72
|
|
|
|
|
|
|
##eval { require MooseX::Getopt; }; |
|
73
|
|
|
|
|
|
|
##if ( !$@ ) { |
|
74
|
|
|
|
|
|
|
## MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $_, '=s', ) |
|
75
|
|
|
|
|
|
|
## for ( 'Path::Tiny', Path ); |
|
76
|
|
|
|
|
|
|
##} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 et: |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |