line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Slackeria::PluginLoader; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9765
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
106
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
107
|
|
5
|
1
|
|
|
1
|
|
160
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
650
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
1
|
|
my ( $obj, %conf ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $ref = {}; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
return bless( $ref, $obj ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
0
|
|
|
0
|
1
|
|
my ( $self, $plugin, %conf ) = @_; |
19
|
0
|
|
|
|
|
|
my $obj; |
20
|
0
|
|
|
|
|
|
eval sprintf( |
21
|
|
|
|
|
|
|
'use App::Slackeria::Plugin::%s;' |
22
|
|
|
|
|
|
|
. '$obj = App::Slackeria::Plugin::%s->new(%%conf);', |
23
|
|
|
|
|
|
|
( ucfirst($plugin) ) x 2, |
24
|
|
|
|
|
|
|
); |
25
|
0
|
0
|
|
|
|
|
if ($@) { |
26
|
0
|
|
|
|
|
|
print STDERR "Cannot load plugin ${plugin}:\n$@\n"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
else { |
29
|
0
|
|
|
|
|
|
$self->{plugin}->{$plugin} = $obj; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub list { |
36
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @list = sort keys %{ $self->{plugin} }; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return @list; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, $conf ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ( $self->{plugin}->{$name} ) { |
47
|
0
|
|
|
|
|
|
return $self->{plugin}->{$name}->run($conf); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |