blib/lib/Siesta/Plugin.pm

filter: Statementstmt 91.8% 34 / 37 Branchbran 80.0% 8 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 83.3% 5 / 6 totaltotal 82.0% 55 / 67 CC 8 SCAR 13.7
CC
8
Cov
88%
pref
7.0
promote
2.0
process
2.0
CRAP 4.0
« blib/lib/Siesta/Plugin/Resume.pm ↑ Summary blib/lib/Siesta/List.pm »
1 # $Id: Plugin.pm 1356 2003-08-14 15:24:00Z richardc $
2 package Siesta::Plugin;
3 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 27 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 27 ▶use base 'Siesta::DBI';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 27 __PACKAGE__->set_up_table('plugin');
7 27 __PACKAGE__->columns( TEMP => qw( member ));
8 27 __PACKAGE__->has_a( list => 'Siesta::List' );
9 27 __PACKAGE__->has_many( prefs => 'Siesta::Pref' );
10  
11 7 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
12 7 my $pkg = shift;
13 7 my ($name) = $pkg =~ /:([^:]+)$/;
14 7 $pkg->create({ name => $name, @_ });
15 }
16  
17 =head1 NAME
18  
19 Siesta::Plugin - base class for Siesta Plugins
20  
21 =head1 SYNOPSIS
22  
23 =head1 DESCRIPTION
24  
25 =head1 Methods
26  
27 =head2 ->list
28  
29 =head2 ->user
30  
31 =head2 ->personal
32  
33 does this plugin also run in the personal queue.
34  
35 =head2 ->process( $message );
36  
37 C<$message> is a Siesta::Message
38  
39 Return a true value to indicate "process no further plugins". use
40 this for message rejection.
41  
42 =cut
43  
44 0 ▶sub process { die "Siesta::Plugin::process called directly" }
Subroutine process: not called CC=1 SCAR=6.9
Pod documented
45  
46 =head2 ->options
47  
48 Returns a hashref, the keys of which are the various config options a
49 plugin accepts. These are:
50  
51 description - a short description of the option
52 type - string, number, list, hash, boolean (1 or 0)
53 default - the default value
54 widget - what widget should be used in a gui to represent this
55  
56 This should be overridden by a deriving class.
57  
58 =cut
59  
60 0 ▶sub options { +{} }
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
61  
62  
63 =head2 ->descripton
64  
65 return a scalar which describes your plugin
66  
67 =cut
68  
69 0 ▶sub description { die "virtual" }
Subroutine description: not called CC=1 SCAR=6.9
Pod undocumented
70  
71 =head2 ->pref( $name )
72 =head2 ->pref( $name, $value );
73  
74 =cut
75  
76 66 ▶sub pref {
Subroutine pref: called CC=7 SCAR=19.5
Pod documented
77 66 my $self = shift;
78 66 my $name = shift;
79  
80 66 ▶ my $config = $self->options->{$name}
Branch: 1 branch
BranchTrueFalseTotal
my $config = $self->options->{$name} or croak("no such config option '${name}'") 66 0 66
81 or croak "no such config option '$name'";
82  
83 66 for my $member ($self->member, 0) {
84 130 ▶ next unless defined $member;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $member 63 67 130
85 67 my %crit = ( name => $name,
86 plugin => $self,
87 member => $member,
88 );
89 67 my ($pref) = Siesta::Pref->search(\%crit);
90 67 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 12 55 67
91 12 ▶ $pref ||= Siesta::Pref->create(\%crit);
Condition66%2/3
$pref ||= "Siesta::Pref"->create(\%crit)
l!l&&r!l&&!r
390
MC/DC0%0/2
$pref ||= "Siesta::Pref"->create(\%crit)
$pref "Siesta::Pref"->create(\%crit)
Truth table66%2/3
A ||= B
A= $prefB= "Siesta::Pref"->create(\%crit)
ABresult
1X1
011
000
92 12 $pref->value( shift );
93 12 $pref->update;
94 }
95 67 ▶ return $pref->value if $pref;
Branch: 1 branch
BranchTrueFalseTotal
if $pref 35 32 67
96 }
97 31 return $config->{default};
98 }
99  
100  
101 =head2 promote
102  
103 Return the Siesta::Plugin::* instance that relates to this object
104  
105 =cut
106  
107 206 ▶sub promote {
Subroutine promote: called CC=2 SCAR=7.0
Pod documented
108 206 my $self = shift;
109 206 my $class = "Siesta::Plugin::". $self->name;
110 206 ▶ $class->require
Branch: 1 branch
BranchTrueFalseTotal
$class->require or die "error '${class}' $UNIVERSAL::require::ERROR" 206 0 206
111 or die "error '$class' $UNIVERSAL::require::ERROR";
112 206 $class->retrieve( $self->id );
113 }
114  
115  
116 27 1;
117  
« blib/lib/Siesta/Plugin/Resume.pm ↑ Summary blib/lib/Siesta/List.pm »