line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Registry; |
2
|
1
|
|
|
1
|
|
2020
|
use Spoon::Registry '-Base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
sub add { |
5
|
|
|
|
|
|
|
my ($key, $value) = @_; |
6
|
|
|
|
|
|
|
return super |
7
|
|
|
|
|
|
|
unless $key eq 'preference' and @_ == 2; |
8
|
|
|
|
|
|
|
super($key, $value->id, object => $value); |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub not_a_plugin { |
12
|
|
|
|
|
|
|
my $class_name = shift; |
13
|
|
|
|
|
|
|
die <
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Error: |
16
|
|
|
|
|
|
|
$class_name is not a plugin class. |
17
|
|
|
|
|
|
|
see: http://www.kwiki.org/?InstallingPlugins |
18
|
|
|
|
|
|
|
END |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub plugin_redefined { |
22
|
|
|
|
|
|
|
my ($class_id, $class_name, $prev_name) = @_; |
23
|
|
|
|
|
|
|
die <
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Error: |
26
|
|
|
|
|
|
|
Plugin class $class_name defined twice. |
27
|
|
|
|
|
|
|
see: http://www.kwiki.org/?InstallingPlugins |
28
|
|
|
|
|
|
|
END |
29
|
|
|
|
|
|
|
die <
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Error: |
32
|
|
|
|
|
|
|
Can't use two plugins with the same class id. |
33
|
|
|
|
|
|
|
$prev_name and $class_name both have a class id of '$class_id'. |
34
|
|
|
|
|
|
|
see: http://www.kwiki.org/?InstallingPlugins |
35
|
|
|
|
|
|
|
END |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub validate { |
39
|
|
|
|
|
|
|
$self->validate_prerequisite or return; |
40
|
|
|
|
|
|
|
return 1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub validate_prerequisite { |
44
|
|
|
|
|
|
|
for my $hashlet (@{$self->lookup->{plugins}}) { |
45
|
|
|
|
|
|
|
my $class_id = $hashlet->{id}; |
46
|
|
|
|
|
|
|
my $prereqs = $self->lookup->{add_order}{$class_id}{prerequisite} |
47
|
|
|
|
|
|
|
or next; |
48
|
|
|
|
|
|
|
for my $prereq (@$prereqs) { |
49
|
|
|
|
|
|
|
$self->missing_prerequisite($class_id, $prereq) |
50
|
|
|
|
|
|
|
unless defined $self->lookup->{classes}{$prereq}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub missing_prerequisite { |
57
|
|
|
|
|
|
|
my ($class_id, $prereq) = @_; |
58
|
|
|
|
|
|
|
my $class_name = $self->lookup->{classes}{$class_id}; |
59
|
|
|
|
|
|
|
die "Missing prerequisite plugin '$prereq' for $class_name\n"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__DATA__ |