line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
#PODNAME: Raisin::Plugin |
3
|
|
|
|
|
|
|
#ABSTRACT: Base class for Raisin plugins |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
5144
|
use strict; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
330
|
|
6
|
11
|
|
|
11
|
|
57
|
use warnings; |
|
11
|
|
|
|
|
68
|
|
|
11
|
|
|
|
|
475
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Raisin::Plugin; |
9
|
|
|
|
|
|
|
$Raisin::Plugin::VERSION = '0.93'; |
10
|
11
|
|
|
11
|
|
131
|
use Carp; |
|
11
|
|
|
|
|
108
|
|
|
11
|
|
|
|
|
2376
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
11
|
|
|
11
|
0
|
636
|
my ($class, $app) = @_; |
14
|
11
|
|
|
|
|
36
|
my $self = bless {}, $class; |
15
|
11
|
|
|
|
|
71
|
$self->{app} = $app; |
16
|
11
|
|
|
|
|
47
|
$self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
57
|
|
|
57
|
0
|
1027
|
sub app { shift->{app} } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub build { |
22
|
1
|
|
|
1
|
1
|
9
|
my ($self, %args) = @_; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register { |
26
|
10
|
|
|
10
|
1
|
506
|
my ($self, %items) = @_; |
27
|
|
|
|
|
|
|
|
28
|
10
|
|
|
|
|
67
|
while (my ($name, $item) = each %items) { |
29
|
11
|
|
|
11
|
|
123
|
no strict 'refs'; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
2489
|
|
30
|
|
|
|
|
|
|
#no warnings 'redefine'; |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
|
|
66
|
my $class = ref $self->app; |
33
|
16
|
|
|
|
|
37
|
my $caller = $self->app->{caller}; |
34
|
|
|
|
|
|
|
|
35
|
16
|
|
|
|
|
50
|
my $glob = "${class}::${name}"; |
36
|
16
|
50
|
|
|
|
56
|
my $app_glob = $caller ? "${caller}::${name}" : undef; |
37
|
|
|
|
|
|
|
|
38
|
16
|
50
|
|
|
|
31
|
if ($self->app->can($name)) { |
39
|
0
|
|
|
|
|
0
|
croak "Redefining of $glob not allowed"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
16
|
50
|
|
|
|
56
|
if (ref $item eq 'CODE') { |
43
|
16
|
|
|
|
|
29
|
*{$glob} = $item; |
|
16
|
|
|
|
|
54
|
|
44
|
16
|
50
|
|
|
|
46
|
*{$app_glob} = $item if $app_glob; |
|
16
|
|
|
|
|
132
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
|
$self->app->{$name} = $item; |
48
|
0
|
|
|
0
|
|
|
*{$glob} = sub { shift->{$name} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |