| 1 | package OpenInteract2::Setup::RequireClasses; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # $Id: RequireClasses.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_INIT ); | ||||||||||||||||||||||||||
|
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 | 87 | ▶ | use OpenInteract2::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 87 | $OpenInteract2::Setup::RequireClasses::VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 87 | my ( $log ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 87 | ▶ | sub get_name { | ||||||||||||||||||||||||||
|
Subroutine
get_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 87 | return 'require classes'; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | $log ||= get_logger( LOG_INIT ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.INITIALIZE")
MC/DC0%0/2
$log ||= get_logger("OI2.INITIALIZE")
$log
get_logger("OI2.INITIALIZE")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.INITIALIZE")
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $type = $self->param( 'classes_type' ) || 'Class'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->param('classes_type') || 'Class'
MC/DC0%0/1
$self->param('classes_type') || 'Class'
$self->param('classes_type')
Truth table0%0/2
A
A= $self->param('classes_type')
| |||||||||||||||||||||||||||||
| 24 | 0 | my @to_require = $self->_find_classes_to_require; | |||||||||||||||||||||||||||
| 25 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | $log->debug( "$type to require: ", join( ', ', @to_require ) ); | ||||||||||||||||||||||||||||
| 27 | 0 | foreach my $require_class ( @to_require ) { | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | next unless ( $require_class ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | eval "require $require_class"; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | oi_error "$type: failed to require class '$require_class': $@"; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $log->is_debug && $log->debug( "$type: $require_class: require ok" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 0 | $self->param( required_classes => \@to_require ); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub _find_classes_to_require { | ||||||||||||||||||||||||||
|
Subroutine
_find_classes_to_require: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 39 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( my $class_file = $self->param( 'classes_file' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | $self->param( | |||||||||||||||||||||||||||
| 43 | classes => OpenInteract2::Util->read_file_lines( $class_file ) ); | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # Value in 'classes' can be single class or arrayref of classes | ||||||||||||||||||||||||||||
| 47 | 0 | my $tmp_to_require = $self->param( 'classes' ); | |||||||||||||||||||||||||||
| 48 | 0 | ▶ | return () unless ( $tmp_to_require ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | my $typeof = ref $tmp_to_require; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | return () if ( $typeof and $typeof ne 'ARRAY' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$typeof and $typeof ne "ARRAY"
MC/DC0%0/2
$typeof and $typeof ne "ARRAY"
$typeof
$typeof ne "ARRAY"
Truth table0%0/3
A and B
A= $typeofB= $typeof ne "ARRAY"
| |||||||||||||||||||||||||||||
| 51 | return ( ref $tmp_to_require eq 'ARRAY' ) | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | ? @{ $tmp_to_require } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | : ( $tmp_to_require ); | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 87 | OpenInteract2::Setup->register_factory_type( get_name() => __PACKAGE__ ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 87 | 1; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||