line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Stub; |
2
|
3
|
|
|
3
|
|
2361
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
83
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
60
|
|
4
|
3
|
|
|
3
|
|
635763
|
use Module::Load; |
|
3
|
|
|
|
|
3841
|
|
|
3
|
|
|
|
|
19
|
|
5
|
3
|
|
|
3
|
|
2892
|
use Sub::Name qw/subname/; |
|
3
|
|
|
|
|
2351
|
|
|
3
|
|
|
|
|
258
|
|
6
|
3
|
|
|
3
|
|
2922
|
use version; |
|
3
|
|
|
|
|
7552
|
|
|
3
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
our $VERSION = qv('0.02'); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub stub { |
10
|
16
|
|
|
16
|
1
|
3778
|
my %params = @_; |
11
|
16
|
|
|
|
|
18
|
my @tags; |
12
|
16
|
100
|
|
|
|
33
|
if ($params{TAG}){ |
13
|
9
|
100
|
|
|
|
24
|
@tags = ref($params{TAG}) ? @{$params{TAG}} : ($params{TAG}); |
|
6
|
|
|
|
|
18
|
|
14
|
9
|
|
|
|
|
18
|
delete $params{TAG}; |
15
|
9
|
50
|
|
|
|
31
|
return unless $ENV{STUB_TAG}; |
16
|
0
|
0
|
|
|
|
0
|
return unless grep { $_ eq $ENV{STUB_TAG}} @tags; |
|
0
|
|
|
|
|
0
|
|
17
|
|
|
|
|
|
|
} |
18
|
7
|
|
|
|
|
15
|
my ($name,$code) = %params; |
19
|
3
|
|
|
3
|
|
489
|
no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
91
|
|
20
|
3
|
|
|
3
|
|
17
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
525
|
|
21
|
7
|
|
|
|
|
20
|
my ($pkg,$file,$line) = caller; |
22
|
7
|
|
|
|
|
9
|
my $original = \&{"${pkg}::${name}"}; |
|
7
|
|
|
|
|
21
|
|
23
|
7
|
|
|
|
|
10
|
*{"${pkg}::__original_${name}"} = $original; |
|
7
|
|
|
|
|
29
|
|
24
|
7
|
|
|
|
|
31
|
*{"${pkg}::${name}"} = subname $name,$code; |
|
7
|
|
|
|
|
32
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub import{ |
28
|
4
|
|
|
4
|
|
384
|
my $class = shift; |
29
|
4
|
|
|
|
|
9
|
my %params = @_ ; |
30
|
|
|
|
|
|
|
|
31
|
4
|
50
|
|
|
|
18
|
if ( $params{on} ){ |
32
|
4
|
|
|
|
|
12
|
my ($pkg,$file) = caller; |
33
|
3
|
|
|
3
|
|
16
|
no strict 'refs'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
186
|
|
34
|
4
|
|
|
|
|
7
|
*{"${pkg}::stub"} = \&stub; |
|
4
|
|
|
|
|
19
|
|
35
|
4
|
|
|
|
|
18
|
*{"${pkg}::_original"} = sub { |
36
|
3
|
|
|
3
|
|
15
|
no strict 'refs' ; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
511
|
|
37
|
2
|
|
|
2
|
|
1302
|
my (undef,undef,undef,$subr) = caller(1); |
38
|
2
|
|
|
|
|
11
|
my $name = ( split /::/,$subr )[-1]; |
39
|
2
|
|
|
|
|
3
|
&{"${pkg}::__original_${name}"}(@_); |
|
2
|
|
|
|
|
9
|
|
40
|
4
|
|
|
|
|
17
|
}; |
41
|
4
|
|
|
|
|
6
|
my $pkgpath = $pkg; |
42
|
4
|
|
|
|
|
14
|
$pkgpath =~ s/::/\//g; |
43
|
4
|
|
|
|
|
6
|
$pkgpath .= ".pm"; |
44
|
4
|
|
|
|
|
192
|
$file =~ s/[\w\/]+(\/$pkgpath)$/$params{on}$1/; |
45
|
4
|
|
|
|
|
16
|
load $file; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |