line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::LocalDir; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1256
|
use strict; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
101
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
75
|
|
5
|
3
|
|
|
3
|
|
52
|
use 5.008004; |
|
3
|
|
|
|
|
10
|
|
6
|
3
|
|
|
3
|
|
365
|
use Alien::Build::Plugin; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
28
|
|
7
|
3
|
|
|
3
|
|
422
|
use File::chdir; |
|
3
|
|
|
|
|
2941
|
|
|
3
|
|
|
|
|
392
|
|
8
|
3
|
|
|
3
|
|
20
|
use Path::Tiny (); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
1567
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Plugin for fetching a local directory |
11
|
|
|
|
|
|
|
our $VERSION = '2.46'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has root => undef; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has ssl => 0; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init |
20
|
|
|
|
|
|
|
{ |
21
|
2
|
|
|
2
|
1
|
11
|
my($self, $meta) = @_; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
50
|
|
|
10
|
my $url = $meta->prop->{start_url} || 'patch'; |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
13
|
$meta->add_requires('configure' => 'Alien::Build::Plugin::Fetch::LocalDir' => '0.72' ); |
26
|
|
|
|
|
|
|
|
27
|
2
|
50
|
|
|
|
8
|
if($url =~ /^file:/) |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
|
|
0
|
$meta->add_requires('share' => 'URI' => 0 ); |
30
|
0
|
|
|
|
|
0
|
$meta->add_requires('share' => 'URI::file' => 0 ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
{ |
34
|
2
|
|
|
|
|
6
|
my $root = $self->root; |
|
2
|
|
|
|
|
14
|
|
35
|
2
|
50
|
|
|
|
7
|
if(defined $root) |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
|
|
0
|
$root = Path::Tiny->new($root)->absolute->stringify; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else |
40
|
|
|
|
|
|
|
{ |
41
|
2
|
|
|
|
|
15
|
$root = "$CWD"; |
42
|
|
|
|
|
|
|
} |
43
|
2
|
|
|
|
|
54
|
$self->root($root); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$meta->register_hook( |
47
|
|
|
|
|
|
|
fetch => sub { |
48
|
2
|
|
|
2
|
|
6
|
my($build, $path, %options) = @_; |
49
|
|
|
|
|
|
|
|
50
|
2
|
50
|
|
|
|
8
|
$build->log("plugin Fetch::LocalDir does not support http_headers option") if $options{http_headers}; |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
33
|
|
|
22
|
$path ||= $url; |
53
|
|
|
|
|
|
|
|
54
|
2
|
50
|
|
|
|
6
|
if($path =~ /^file:/) |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
|
|
0
|
my $root = URI::file->new($self->root); |
57
|
0
|
|
|
|
|
0
|
my $url = URI->new_abs($path, $root); |
58
|
0
|
|
|
|
|
0
|
$path = $url->path; |
59
|
0
|
0
|
|
|
|
0
|
$path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32'; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
19
|
$path = Path::Tiny->new($path)->absolute($self->root); |
63
|
|
|
|
|
|
|
|
64
|
2
|
50
|
|
|
|
217
|
if(-d $path) |
65
|
|
|
|
|
|
|
{ |
66
|
|
|
|
|
|
|
return { |
67
|
2
|
|
|
|
|
63
|
type => 'file', |
68
|
|
|
|
|
|
|
filename => $path->basename, |
69
|
|
|
|
|
|
|
path => $path->stringify, |
70
|
|
|
|
|
|
|
tmp => 0, |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
|
|
|
$build->log("path $path is not a directory"); |
76
|
0
|
|
|
|
|
|
$build->log("(you specified $url with root @{[ $self->root ]})"); |
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
die "$path is not a directory"; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
2
|
|
|
|
|
20
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |