line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::Local; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
1660
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
185
|
|
4
|
7
|
|
|
7
|
|
41
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
151
|
|
5
|
7
|
|
|
7
|
|
105
|
use 5.008004; |
|
7
|
|
|
|
|
19
|
|
6
|
7
|
|
|
7
|
|
522
|
use Alien::Build::Plugin; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
49
|
|
7
|
7
|
|
|
7
|
|
437
|
use File::chdir; |
|
7
|
|
|
|
|
2912
|
|
|
7
|
|
|
|
|
657
|
|
8
|
7
|
|
|
7
|
|
43
|
use Path::Tiny (); |
|
7
|
|
|
|
|
40
|
|
|
7
|
|
|
|
|
3344
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Plugin for fetching a local file |
11
|
|
|
|
|
|
|
our $VERSION = '2.47'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has '+url' => ''; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has root => undef; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has ssl => 0; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init |
23
|
|
|
|
|
|
|
{ |
24
|
12
|
|
|
12
|
1
|
43
|
my($self, $meta) = @_; |
25
|
|
|
|
|
|
|
|
26
|
12
|
|
66
|
|
|
36
|
$meta->prop->{start_url} ||= $self->url; |
27
|
12
|
|
50
|
|
|
35
|
$self->url($meta->prop->{start_url} || 'patch'); |
28
|
|
|
|
|
|
|
|
29
|
12
|
100
|
|
|
|
27
|
if($self->url =~ /^file:/) |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
|
|
|
|
6
|
$meta->add_requires('share' => 'URI' => 0 ); |
32
|
1
|
|
|
|
|
4
|
$meta->add_requires('share' => 'URI::file' => 0 ); |
33
|
1
|
|
|
|
|
4
|
$meta->add_requires('share' => 'URI::Escape' => 0 ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
37
|
12
|
|
|
|
|
23
|
my $root = $self->root; |
|
12
|
|
|
|
|
34
|
|
38
|
12
|
100
|
|
|
|
31
|
if(defined $root) |
39
|
|
|
|
|
|
|
{ |
40
|
1
|
|
|
|
|
5
|
$root = Path::Tiny->new($root)->absolute->stringify; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else |
43
|
|
|
|
|
|
|
{ |
44
|
11
|
|
|
|
|
67
|
$root = "$CWD"; |
45
|
|
|
|
|
|
|
} |
46
|
12
|
|
|
|
|
367
|
$self->root($root); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$meta->register_hook( fetch => sub { |
50
|
10
|
|
|
10
|
|
27
|
my($build, $path, %options) = @_; |
51
|
|
|
|
|
|
|
|
52
|
10
|
50
|
|
|
|
29
|
$build->log("plugin Fetch::Local does not support http_headers option") if $options{http_headers}; |
53
|
|
|
|
|
|
|
|
54
|
10
|
|
66
|
|
|
66
|
$path ||= $self->url; |
55
|
|
|
|
|
|
|
|
56
|
10
|
100
|
|
|
|
41
|
if($path =~ /^file:/) |
57
|
|
|
|
|
|
|
{ |
58
|
2
|
|
|
|
|
7
|
my $root = URI::file->new($self->root); |
59
|
2
|
|
|
|
|
184
|
my $url = URI->new_abs($path, $root); |
60
|
2
|
|
|
|
|
148
|
$path = URI::Escape::uri_unescape($url->path); |
61
|
2
|
50
|
|
|
|
36
|
$path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
10
|
|
|
|
|
41
|
$path = Path::Tiny->new($path)->absolute($self->root); |
65
|
|
|
|
|
|
|
|
66
|
10
|
100
|
|
|
|
874
|
if(-d $path) |
|
|
50
|
|
|
|
|
|
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
return { |
69
|
|
|
|
|
|
|
type => 'list', |
70
|
|
|
|
|
|
|
list => [ |
71
|
14
|
|
|
|
|
127
|
map { { filename => $_->basename, url => $_->stringify } } |
72
|
2
|
|
|
|
|
46
|
sort { $a->basename cmp $b->basename } $path->children, |
|
26
|
|
|
|
|
944
|
|
73
|
|
|
|
|
|
|
], |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
elsif(-f $path) |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
return { |
79
|
8
|
|
|
|
|
320
|
type => 'file', |
80
|
|
|
|
|
|
|
filename => $path->basename, |
81
|
|
|
|
|
|
|
path => $path->stringify, |
82
|
|
|
|
|
|
|
tmp => 0, |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
|
die "no such file or directory $path"; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
12
|
|
|
|
|
123
|
}); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |