PerlActor/CommandFactory.pm

filter: Statementstmt 100% 21 / 21 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 94.1% 32 / 34 CC 6 SCAR 12.4
CC
6
Cov
97%
create
5.0
_compile
2.0
BEGIN
1.0
CRAP 3.4
« PerlActor/Command/RunDir.pm ↑ Summary PerlActor/Runner/Console.pm »
1 package PerlActor::CommandFactory;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use base 'PerlActor::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #===============================================================================================
6 # Public Methods
7 #===============================================================================================
8  
9 sub create
10 19 ▶{
Subroutine create: called CC=5 SCAR=16.1
Pod undocumented
11 19 my $self = shift;
12 19 my $commandName = shift;
13  
14 19 ▶ return $self->create('Null')
Branch: 1 branch
BranchTrueFalseTotal
unless $commandName 1 18 19
15 unless $commandName;
16  
17 18 my @commandArgs = @_;
18 18 my $error = '';
19
20 #TODO Refactor by extracting standard namespaces
21 18 foreach my $class ("PerlActor::Command::$commandName", "PerlActor::Command::Web::$commandName", $commandName)
22 {
23 22 ▶ unless ($error = $self->_compile($class))
Branch: 1 branch
BranchTrueFalseTotal
unless ($error = $self->_compile($class)) 16 6 22
24 {
25 16 return $class->new(@commandArgs)
26 }
27 6 ▶ last unless ($error =~ /Can't locate/);
Branch: 1 branch
BranchTrueFalseTotal
unless $error =~ /Can't locate/ 0 6 6
28 }
29
30 2 return $self->create('Unknown', $error);
31  
32 }
33  
34 #===============================================================================================
35 # Protected Methods - Don't even think about calling these from outside the class.
36 #===============================================================================================
37  
38 sub _compile
39 22 ▶{
Subroutine _compile: called CC=2 SCAR=6.9
40 22 my $self = shift;
41 22 my $class = shift;
42 22 ▶ return if (eval "require $class");
Branch: 1 branch
BranchTrueFalseTotal
if eval "require $class" 16 6 22
43 6 return $@;
44 }
45  
46 # Keep Perl happy.
47 1 1;
« PerlActor/Command/RunDir.pm ↑ Summary PerlActor/Runner/Console.pm »