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
|
|
4139
|
use strict; |
|
11
|
|
|
|
|
60
|
|
|
11
|
|
|
|
|
275
|
|
6
|
11
|
|
|
11
|
|
100
|
use warnings; |
|
11
|
|
|
|
|
68
|
|
|
11
|
|
|
|
|
454
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Raisin::Plugin; |
9
|
|
|
|
|
|
|
$Raisin::Plugin::VERSION = '0.94'; |
10
|
11
|
|
|
11
|
|
88
|
use Carp; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
1879
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
11
|
|
|
11
|
0
|
520
|
my ($class, $app) = @_; |
14
|
11
|
|
|
|
|
26
|
my $self = bless {}, $class; |
15
|
11
|
|
|
|
|
64
|
$self->{app} = $app; |
16
|
11
|
|
|
|
|
53
|
$self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
57
|
|
|
57
|
0
|
833
|
sub app { shift->{app} } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub build { |
22
|
1
|
|
|
1
|
1
|
10
|
my ($self, %args) = @_; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register { |
26
|
10
|
|
|
10
|
1
|
378
|
my ($self, %items) = @_; |
27
|
|
|
|
|
|
|
|
28
|
10
|
|
|
|
|
53
|
while (my ($name, $item) = each %items) { |
29
|
11
|
|
|
11
|
|
83
|
no strict 'refs'; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
2146
|
|
30
|
|
|
|
|
|
|
#no warnings 'redefine'; |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
|
|
58
|
my $class = ref $self->app; |
33
|
16
|
|
|
|
|
32
|
my $caller = $self->app->{caller}; |
34
|
|
|
|
|
|
|
|
35
|
16
|
|
|
|
|
42
|
my $glob = "${class}::${name}"; |
36
|
16
|
50
|
|
|
|
47
|
my $app_glob = $caller ? "${caller}::${name}" : undef; |
37
|
|
|
|
|
|
|
|
38
|
16
|
50
|
|
|
|
32
|
if ($self->app->can($name)) { |
39
|
0
|
|
|
|
|
0
|
croak "Redefining of $glob not allowed"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
16
|
50
|
|
|
|
47
|
if (ref $item eq 'CODE') { |
43
|
16
|
|
|
|
|
20
|
*{$glob} = $item; |
|
16
|
|
|
|
|
53
|
|
44
|
16
|
50
|
|
|
|
41
|
*{$app_glob} = $item if $app_glob; |
|
16
|
|
|
|
|
117
|
|
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__ |