line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Pluggable::Dependency; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
29176
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
5
|
2
|
|
|
2
|
|
2078
|
use Module::Pluggable (); |
|
2
|
|
|
|
|
34900
|
|
|
2
|
|
|
|
|
41
|
|
6
|
2
|
|
|
2
|
|
1810
|
use Algorithm::Dependency::Ordered; |
|
2
|
|
|
|
|
24127
|
|
|
2
|
|
|
|
|
72
|
|
7
|
2
|
|
|
2
|
|
1959
|
use Algorithm::Dependency::Source::HoA; |
|
2
|
|
|
|
|
1102
|
|
|
2
|
|
|
|
|
294
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.0.4'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import { |
12
|
3
|
|
|
3
|
|
27
|
my $package = shift; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# let Module::Pluggable install it's normal subroutine |
15
|
3
|
|
|
|
|
10
|
my %args = @_; |
16
|
3
|
|
50
|
|
|
23
|
$args{package} ||= scalar caller; |
17
|
3
|
100
|
33
|
|
|
23
|
$args{require} = 1 if !$args{require} && !$args{instantiate}; |
18
|
3
|
|
|
|
|
33
|
Module::Pluggable->import(%args); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# wrap Module::Pluggable's sub to sort by dependencies |
21
|
3
|
|
100
|
|
|
230
|
my $sub_name = $args{sub_name} || 'plugins'; |
22
|
3
|
|
|
|
|
9
|
my $installed_sub_name = "$args{package}::$sub_name"; |
23
|
|
|
|
|
|
|
{ |
24
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
|
3
|
|
|
|
|
4
|
|
25
|
2
|
|
|
2
|
|
11
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
457
|
|
26
|
3
|
|
|
|
|
7
|
my $original_sub = \&$installed_sub_name; |
27
|
3
|
|
|
|
|
85
|
*{$installed_sub_name} = sub { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# build a dependency hash |
30
|
1
|
|
|
1
|
|
17
|
my %deps; |
31
|
|
|
|
|
|
|
my %objects; |
32
|
1
|
|
|
|
|
8
|
for my $plugin ( $original_sub->(@_) ) { |
33
|
0
|
|
0
|
|
|
0
|
my $plugin_name = ref($plugin) || $plugin; |
34
|
0
|
|
0
|
|
|
0
|
$deps{$plugin_name} = eval { [ $plugin->depends ] } || []; |
35
|
0
|
|
|
|
|
0
|
$objects{$plugin_name} = $plugin; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# calculate plugin order based on dependencies |
39
|
1
|
|
|
|
|
2547
|
my $source = Algorithm::Dependency::Source::HoA->new( \%deps ); |
40
|
1
|
|
|
|
|
24
|
my $deps |
41
|
|
|
|
|
|
|
= Algorithm::Dependency::Ordered->new( source => $source ); |
42
|
1
|
|
|
|
|
13
|
return @objects{ @{ $deps->schedule_all } }; |
|
1
|
|
|
|
|
215
|
|
43
|
3
|
|
|
|
|
13
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |