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