line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::Rewrite; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
165839
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
48
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
31
|
use 5.008001; |
|
2
|
|
|
|
|
6
|
|
6
|
2
|
|
|
2
|
|
577
|
use URI; |
|
2
|
|
|
|
|
7008
|
|
|
2
|
|
|
|
|
58
|
|
7
|
2
|
|
|
2
|
|
626
|
use Alien::Build; |
|
2
|
|
|
|
|
60230
|
|
|
2
|
|
|
|
|
57
|
|
8
|
2
|
|
|
2
|
|
477
|
use Alien::Build::Plugin; |
|
2
|
|
|
|
|
3557
|
|
|
2
|
|
|
|
|
12
|
|
9
|
2
|
|
|
2
|
|
630
|
use Alien::Build::Plugin::Fetch::LWP; |
|
2
|
|
|
|
|
881
|
|
|
2
|
|
|
|
|
11
|
|
10
|
2
|
|
|
2
|
|
546
|
use Alien::Build::Plugin::Decode::HTML; |
|
2
|
|
|
|
|
861
|
|
|
2
|
|
|
|
|
13
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Alien::Build plugin to rewrite network requests to local resources |
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
1
|
13666
|
my($self, $meta) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
19
|
unless($meta->prop->{start_url}) |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
|
|
0
|
Alien::Build->log("sorry! this plugin requires a default url to function"); |
23
|
0
|
|
|
|
|
0
|
Alien::Build->log("no rewrites will be possible"); |
24
|
0
|
|
|
|
|
0
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
54
|
Alien::Build::Plugin::Fetch::LWP->new->init($meta); |
28
|
1
|
|
|
|
|
240
|
Alien::Build::Plugin::Decode::HTML->new->init($meta); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$meta->around_hook(fetch => sub { |
31
|
6
|
|
|
6
|
|
90689
|
my($f, $build, $url) = @_; |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
66
|
|
|
28
|
$url ||= $build->meta_prop->{start_url}; |
34
|
|
|
|
|
|
|
|
35
|
6
|
100
|
|
|
|
89
|
if(Alien::Build::rc->can('rewrite')) |
36
|
|
|
|
|
|
|
{ |
37
|
4
|
|
|
|
|
15
|
my $orig = URI->new($url); |
38
|
4
|
|
|
|
|
2623
|
my $copy = $orig->clone; |
39
|
4
|
|
|
|
|
74
|
Alien::Build::rc::rewrite($build, $copy); |
40
|
4
|
50
|
|
|
|
1807
|
if("$copy" ne "$orig") |
41
|
|
|
|
|
|
|
{ |
42
|
4
|
|
|
|
|
37
|
$build->log("rewriting $orig as $copy"); |
43
|
4
|
|
|
|
|
185
|
$url = "$copy"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
38
|
return $f->($build, $url); |
48
|
1
|
|
|
|
|
169
|
}); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |