line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Fetch::Rewrite; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
202012
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
45
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
34
|
|
5
|
2
|
|
|
2
|
|
27
|
use 5.008001; |
|
2
|
|
|
|
|
6
|
|
6
|
2
|
|
|
2
|
|
778
|
use URI; |
|
2
|
|
|
|
|
6712
|
|
|
2
|
|
|
|
|
44
|
|
7
|
2
|
|
|
2
|
|
878
|
use Alien::Build; |
|
2
|
|
|
|
|
66364
|
|
|
2
|
|
|
|
|
58
|
|
8
|
2
|
|
|
2
|
|
631
|
use Alien::Build::Plugin; |
|
2
|
|
|
|
|
16700
|
|
|
2
|
|
|
|
|
11
|
|
9
|
2
|
|
|
2
|
|
795
|
use Alien::Build::Plugin::Fetch::LWP; |
|
2
|
|
|
|
|
1060
|
|
|
2
|
|
|
|
|
9
|
|
10
|
2
|
|
|
2
|
|
670
|
use Alien::Build::Plugin::Decode::HTML; |
|
2
|
|
|
|
|
970
|
|
|
2
|
|
|
|
|
14
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Alien::Build plugin to rewrite network requests to local resources |
13
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
1
|
15576
|
my($self, $meta) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
4
|
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
|
|
|
|
|
11
|
Alien::Build::Plugin::Fetch::LWP->new->init($meta); |
28
|
1
|
|
|
|
|
120
|
Alien::Build::Plugin::Decode::HTML->new->init($meta); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$meta->around_hook(fetch => sub { |
31
|
6
|
|
|
6
|
|
84324
|
my($f, $build, $url) = @_; |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
66
|
|
|
20
|
$url ||= $build->meta_prop->{start_url}; |
34
|
|
|
|
|
|
|
|
35
|
6
|
100
|
|
|
|
87
|
if(Alien::Build::rc->can('rewrite')) |
36
|
|
|
|
|
|
|
{ |
37
|
4
|
|
|
|
|
13
|
my $orig = URI->new($url); |
38
|
4
|
|
|
|
|
2741
|
my $copy = $orig->clone; |
39
|
4
|
|
|
|
|
77
|
Alien::Build::rc::rewrite($build, $copy); |
40
|
4
|
50
|
|
|
|
1721
|
if("$copy" ne "$orig") |
41
|
|
|
|
|
|
|
{ |
42
|
4
|
|
|
|
|
31
|
$build->log("rewriting $orig as $copy"); |
43
|
4
|
|
|
|
|
293
|
$url = "$copy"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
36
|
return $f->($build, $url); |
48
|
1
|
|
|
|
|
99
|
}); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |