line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::Corpus; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
641
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
6
|
use Alien::Build::Plugin; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
14
|
|
7
|
1
|
|
|
1
|
|
4
|
use Path::Tiny (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
913
|
|
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
30
|
sub _path { Path::Tiny::path(@_) } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+url' => sub { |
12
|
|
|
|
|
|
|
Carp::croak "url is required"; |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has return_listing_as => 'list'; # or html or dir_listing |
16
|
|
|
|
|
|
|
has return_file_as => 'content'; # or path |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has regex => qr/\.tar\.gz$/; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init |
21
|
|
|
|
|
|
|
{ |
22
|
5
|
|
|
5
|
1
|
28
|
my($self, $meta) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $list = { |
25
|
|
|
|
|
|
|
type => 'list', |
26
|
|
|
|
|
|
|
list => [ |
27
|
|
|
|
|
|
|
map { |
28
|
530
|
|
|
|
|
1220
|
my %h = ( |
29
|
|
|
|
|
|
|
filename => $_, |
30
|
|
|
|
|
|
|
url => "http://test1.test/foo/bar/baz/$_", |
31
|
|
|
|
|
|
|
); |
32
|
530
|
|
|
|
|
878
|
\%h; |
33
|
5
|
|
|
|
|
12
|
} ((map { $_->basename } grep { -f $_ } _path('corpus/dist')->children), map { sprintf "foo-0.%02d.tar.gz", $_ } 0..99), |
|
30
|
|
|
|
|
593
|
|
|
35
|
|
|
|
|
2153
|
|
|
500
|
|
|
|
|
1098
|
|
34
|
|
|
|
|
|
|
], |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$meta->register_hook( |
38
|
|
|
|
|
|
|
fetch => sub { |
39
|
8
|
|
|
8
|
|
20
|
my(undef, $url) = @_; |
40
|
|
|
|
|
|
|
|
41
|
8
|
|
66
|
|
|
45
|
$url ||= $self->url; |
42
|
|
|
|
|
|
|
|
43
|
8
|
100
|
|
|
|
118
|
if($url =~ qr!^http://test1\.test/foo/bar/baz/?$!) |
|
|
50
|
|
|
|
|
|
44
|
|
|
|
|
|
|
{ |
45
|
3
|
100
|
|
|
|
19
|
if($self->return_listing_as eq 'list') |
|
|
50
|
|
|
|
|
|
46
|
|
|
|
|
|
|
{ |
47
|
1
|
|
|
|
|
5
|
return $list; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif($self->return_listing_as =~ /^(?:html|dir_listing)$/) |
50
|
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
|
return { |
52
|
2
|
|
|
|
|
6
|
type => $self->return_listing_as, |
53
|
|
|
|
|
|
|
base => 'http://test1.test/foo/bar/baz/', |
54
|
|
|
|
|
|
|
content => 'test content', |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
|
|
0
|
die "todo: @{[ $self->return_listing_as ]}"; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif($url =~ qr!^http://test1\.test/foo/bar/baz/(.*)$!) |
63
|
|
|
|
|
|
|
{ |
64
|
5
|
|
|
|
|
26
|
my $path = _path "corpus/dist/$1"; |
65
|
5
|
50
|
|
|
|
180
|
if(-f $path) |
66
|
|
|
|
|
|
|
{ |
67
|
5
|
|
|
|
|
146
|
my %hash = ( |
68
|
|
|
|
|
|
|
type => 'file', |
69
|
|
|
|
|
|
|
filename => $path->basename, |
70
|
|
|
|
|
|
|
); |
71
|
5
|
100
|
|
|
|
164
|
if($self->return_file_as eq 'content') |
|
|
50
|
|
|
|
|
|
72
|
|
|
|
|
|
|
{ |
73
|
4
|
|
|
|
|
16
|
$hash{content} = $path->slurp_raw; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif($self->return_file_as eq 'path') |
76
|
|
|
|
|
|
|
{ |
77
|
1
|
|
|
|
|
6
|
$hash{path} = $path->stringify; |
78
|
|
|
|
|
|
|
} |
79
|
5
|
|
|
|
|
789
|
return \%hash; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
|
|
0
|
die "bad file: @{[ $path->basename ]}"; |
|
0
|
|
|
|
|
0
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
|
|
0
|
die "bad url: $url"; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
}, |
91
|
5
|
|
|
|
|
122
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$meta->register_hook( |
94
|
|
|
|
|
|
|
decode => sub { |
95
|
2
|
|
|
2
|
|
10
|
return $list; |
96
|
|
|
|
|
|
|
} |
97
|
5
|
|
|
|
|
25
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$meta->register_hook( |
100
|
|
|
|
|
|
|
prefer => sub { |
101
|
3
|
|
|
3
|
|
10
|
my(undef, $res) = @_; |
102
|
|
|
|
|
|
|
|
103
|
342
|
|
|
|
|
422
|
my @list = sort { $b->{filename} cmp $a->{filename} } |
104
|
318
|
|
|
|
|
633
|
grep { $_->{filename} =~ $self->regex } |
105
|
3
|
|
|
|
|
18
|
@{ $res->{list} }; |
|
3
|
|
|
|
|
9
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
return { |
108
|
3
|
|
|
|
|
58
|
type => 'list', |
109
|
|
|
|
|
|
|
list => \@list, |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
} |
112
|
5
|
|
|
|
|
24
|
); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|