line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nephia::Plugin; |
2
|
11
|
|
|
11
|
|
48187
|
use strict; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
342
|
|
3
|
11
|
|
|
11
|
|
58
|
use warnings; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
252
|
|
4
|
11
|
|
|
11
|
|
61
|
use Carp; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
5266
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
46
|
|
|
46
|
0
|
989
|
my ($class, %opts) = @_; |
8
|
46
|
|
|
|
|
224
|
$class->_check_needs($opts{app}); |
9
|
45
|
|
|
|
|
221
|
$class->_check_requires($opts{app}); |
10
|
44
|
|
|
|
|
262
|
return bless {%opts}, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub app { |
14
|
24
|
|
|
24
|
1
|
111
|
my $self = shift; |
15
|
24
|
|
|
|
|
136
|
return $self->{app}; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub exports { |
19
|
4
|
|
|
4
|
1
|
457
|
my $self = shift; |
20
|
4
|
|
|
|
|
36
|
return (); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
44
|
|
|
44
|
1
|
152
|
sub needs { return () } |
24
|
|
|
|
|
|
|
|
25
|
43
|
|
|
43
|
1
|
148
|
sub requires { return () } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _check_needs { |
28
|
46
|
|
|
46
|
|
226
|
my ($class, $app) = @_; |
29
|
46
|
|
|
|
|
113
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
30
|
46
|
|
|
|
|
530
|
for my $need ($class->needs) { |
31
|
2
|
50
|
|
|
|
14
|
$need = $need =~ /^Nephia::Plugin/ ? $need : "Nephia::Plugin::$need"; |
32
|
2
|
100
|
|
|
|
7
|
croak "$class needs $need, you have to load $need first" unless $app->loaded_plugins->index($need) > 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _check_requires { |
37
|
45
|
|
|
45
|
|
71
|
my ($class, $app) = @_; |
38
|
45
|
100
|
|
|
|
118
|
return unless $app; |
39
|
44
|
|
|
|
|
69
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
40
|
|
|
|
|
|
|
|
41
|
44
|
|
|
|
|
12543
|
my @plugins = $app->loaded_plugins; |
42
|
44
|
|
|
|
|
82
|
my @exports = map { $_->exports } @plugins; |
|
32
|
|
|
|
|
109
|
|
43
|
|
|
|
|
|
|
|
44
|
44
|
|
|
|
|
217
|
for my $requires ($class->requires) { |
45
|
1
|
50
|
|
|
|
4
|
croak "$class requires $requires DSL, you have to load some plugin that provides $requires DSL" unless grep { $_ eq $requires } @exports; |
|
4
|
|
|
|
|
34
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |