| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::Local; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
1570
|
use strict; |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
216
|
|
|
4
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
170
|
|
|
5
|
7
|
|
|
7
|
|
126
|
use 5.008004; |
|
|
7
|
|
|
|
|
25
|
|
|
6
|
7
|
|
|
7
|
|
462
|
use Alien::Build::Plugin; |
|
|
7
|
|
|
|
|
19
|
|
|
|
7
|
|
|
|
|
52
|
|
|
7
|
7
|
|
|
7
|
|
575
|
use File::chdir; |
|
|
7
|
|
|
|
|
2895
|
|
|
|
7
|
|
|
|
|
728
|
|
|
8
|
7
|
|
|
7
|
|
50
|
use Path::Tiny (); |
|
|
7
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
3949
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Plugin for fetching a local file |
|
11
|
|
|
|
|
|
|
our $VERSION = '2.45'; # 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
|
46
|
my($self, $meta) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
12
|
|
66
|
|
|
52
|
$meta->prop->{start_url} ||= $self->url; |
|
27
|
12
|
|
50
|
|
|
37
|
$self->url($meta->prop->{start_url} || 'patch'); |
|
28
|
|
|
|
|
|
|
|
|
29
|
12
|
100
|
|
|
|
34
|
if($self->url =~ /^file:/) |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
1
|
|
|
|
|
6
|
$meta->add_requires('share' => 'URI' => 0 ); |
|
32
|
1
|
|
|
|
|
3
|
$meta->add_requires('share' => 'URI::file' => 0 ); |
|
33
|
1
|
|
|
|
|
3
|
$meta->add_requires('share' => 'URI::Escape' => 0 ); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
|
37
|
12
|
|
|
|
|
24
|
my $root = $self->root; |
|
|
12
|
|
|
|
|
39
|
|
|
38
|
12
|
100
|
|
|
|
41
|
if(defined $root) |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
1
|
|
|
|
|
8
|
$root = Path::Tiny->new($root)->absolute->stringify; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
else |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
11
|
|
|
|
|
87
|
$root = "$CWD"; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
12
|
|
|
|
|
452
|
$self->root($root); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$meta->register_hook( fetch => sub { |
|
50
|
10
|
|
|
10
|
|
42
|
my($build, $path, %options) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
10
|
50
|
|
|
|
65
|
$build->log("plugin Fetch::Local does not support http_headers option") if $options{http_headers}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
10
|
|
66
|
|
|
67
|
$path ||= $self->url; |
|
55
|
|
|
|
|
|
|
|
|
56
|
10
|
100
|
|
|
|
48
|
if($path =~ /^file:/) |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
2
|
|
|
|
|
10
|
my $root = URI::file->new($self->root); |
|
59
|
2
|
|
|
|
|
225
|
my $url = URI->new_abs($path, $root); |
|
60
|
2
|
|
|
|
|
177
|
$path = URI::Escape::uri_unescape($url->path); |
|
61
|
2
|
50
|
|
|
|
44
|
$path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32'; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
10
|
|
|
|
|
64
|
$path = Path::Tiny->new($path)->absolute($self->root); |
|
65
|
|
|
|
|
|
|
|
|
66
|
10
|
100
|
|
|
|
1095
|
if(-d $path) |
|
|
|
50
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
{ |
|
68
|
|
|
|
|
|
|
return { |
|
69
|
|
|
|
|
|
|
type => 'list', |
|
70
|
|
|
|
|
|
|
list => [ |
|
71
|
14
|
|
|
|
|
130
|
map { { filename => $_->basename, url => $_->stringify } } |
|
72
|
2
|
|
|
|
|
68
|
sort { $a->basename cmp $b->basename } $path->children, |
|
|
26
|
|
|
|
|
995
|
|
|
73
|
|
|
|
|
|
|
], |
|
74
|
|
|
|
|
|
|
}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
elsif(-f $path) |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
|
|
|
|
|
|
return { |
|
79
|
8
|
|
|
|
|
380
|
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
|
|
|
|
|
151
|
}); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |