Plugin/Useful/Generic.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran n/a Conditioncond 30.0% 3 / 10 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 66.6% 2 / 3 totaltotal 75.0% 36 / 48 CC 5 SCAR 13.4
CC
5
Cov
78%
export
6.6
BEGIN
1.0
BEGIN
1.0
CRAP 3.8
« Plugin/Host.pm ↑ Summary Plugin/ExportList.pm »
1 #!/usr/bin/perl
2 # $Id: Generic.pm,v 1.6 2003/12/10 03:52:30 nothingmuch Exp $
3  
4 package Object::Meta::Plugin::Useful::Generic; # an extended base class with some logical features $$$ ## rename to Usefull::Generic;
5  
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use base 'Object::Meta::Plugin::Useful';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = 0.01;
12  
13 42 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
14 42 my $pkg = shift;
15
16 42 bless {
17 exports => [],
18 }, $pkg;
19 }
20  
21 41 ▶sub export { # utility method: export a list of method names
Subroutine export: called CC=5 SCAR=18.9
Pod documented
22 41 my $self = shift;
23 41 my @try_export = @_;
24
25 0 my %tested = map { $_, undef } @{ $self->{exports} };
26
27 41 push @{ $self->{exports} }, grep {
28 41 ▶ (not exists $tested{$_}) and $tested{$_} = 1 # make sure we didn't pass this one already
Condition30%3/10
!exists $tested{$_} && ($tested{$_} = 1) && $self->can($_) || warnings::warnif($self, "Export of undefined method $_ attempted") && undef
l!l&&r!l&&!r
9300
not exists $tested{$_} and $tested{$_} = 1 and $self->can($_)
!ll&&!rl&&r
0093
not exists $tested{$_} and $tested{$_} = 1
!ll
093
warnings::warnif($self, "Export of undefined method $_ attempted") and undef
!ll
00
MC/DC0%0/3
!exists $tested{$_} && ($tested{$_} = 1) && $self->can($_) || warnings::warnif($self, "Export of undefined method $_ attempted") && undef
not exists $tested{$_} $self->can($_) warnings::warnif($self, "Export of undefined method $_ attempted")
Truth table20%1/5
not(A) and B || C
A= not exists $tested{$_}B= $self->can($_)C= warnings::warnif($self, "Export of undefined method $_ attempted")
ABCresult
11X1
0X11
1011
0X00
1000
29 and $self->can($_) or (warnings::warnif($self,"Export of undefined method $_ attempted") and undef); # make sure we can use the method. UNIVERSAL::can should be replaced if magic is going on. To shut it up, 'no warnings Plugin::Class'.
30 } @try_export;
31
32 41 @{ $self->{exports} }; # number on scalar, list on list
33 }
34  
35 42 ▶sub exports {
Subroutine exports: called CC=1 SCAR=0.0
Pod documented
36 42 my $self = shift;
37 42 @{ $self->{exports} };
38 }
39  
40 3 1; # Keep your mother happy.
41  
42 __END__
« Plugin/Host.pm ↑ Summary Plugin/ExportList.pm »