OpenInteract2/Setup/ReadServerConfig.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 79.6% 43 / 54 CC 4 SCAR 8.1
CC
4
Cov
85%
execute
4.4
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« OpenInteract2/Setup/RequireSessionClasses.pm ↑ Summary OpenInteract2/Brick/PackageFromTable.pm »
1 package OpenInteract2::Setup::ReadServerConfig;
2  
3 # $Id: ReadServerConfig.pm,v 1.3 2005/03/18 04:09:51 lachoy Exp $
4  
5 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 87 ▶use base qw( OpenInteract2::Setup );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 87 ▶use Log::Log4perl qw( get_logger );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 87 ▶use OpenInteract2::Constants qw( :log );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 87 ▶use OpenInteract2::Exception qw( oi_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 87 $OpenInteract2::Setup::ReadServerConfig::VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
12  
13 87 my ( $log );
14  
15 174 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod undocumented
16 174 return 'read server configuration';
17 }
18  
19 # This is the only setup action that should return an empty depends...
20  
21 1 ▶sub get_dependencies {
Subroutine get_dependencies: called CC=1 SCAR=0.0
Pod undocumented
22 1 return ();
23 }
24  
25 1 ▶sub execute {
Subroutine execute: called CC=4 SCAR=14.9
Pod undocumented
26 1 my ( $self, $ctx ) = @_;
27 1 ▶ $log ||= get_logger( LOG_INIT );
Condition33%1/3
$log ||= get_logger("OI2.INITIALIZE")
l!l&&r!l&&!r
010
MC/DC0%0/2
$log ||= get_logger("OI2.INITIALIZE")
$log get_logger("OI2.INITIALIZE")
Truth table33%1/3
A ||= B
A= $logB= get_logger("OI2.INITIALIZE")
ABresult
1X1
011
000
28 1 my $bootstrap = $ctx->bootstrap;
29 1 ▶ unless ( ref $bootstrap eq 'OpenInteract2::Config::Bootstrap' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $bootstrap eq "OpenInteract2::Config::Bootstrap") 0 1 1
30 0 oi_error "Cannot read server configuration: 'bootstrap' ",
31 "property of context not set properly";
32 }
33 1 my $server_config_file = $bootstrap->get_server_config_file;
34 1 ▶ unless ( $server_config_file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($server_config_file) 0 1 1
35 0 oi_error "Cannot read server configuration: filename not ",
36 "defined in bootstrap file ", $bootstrap->filename;
37 }
38 1 my $config_type = $bootstrap->config_type;
39 1 $log->info( "Reading server configuration as '$config_type' ",
40 "with '$server_config_file'" );
41 1 my $server_conf = OpenInteract2::Config->new(
42 $config_type, { filename => $server_config_file } );
43 1 $ctx->server_config( $server_conf );
44 1 $log->info( "Read and assigned server config ok" );
45 }
46  
47 87 OpenInteract2::Setup->register_factory_type( get_name() => __PACKAGE__ );
48  
49 87 1;
50  
51 __END__
« OpenInteract2/Setup/RequireSessionClasses.pm ↑ Summary OpenInteract2/Brick/PackageFromTable.pm »