| 1 | package OpenInteract2::Manage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: Manage.pm,v 1.49 2005/03/17 14:57:58 sjn Exp $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( Exporter OpenInteract2::ParamContainer Class::Factory Class::Observable ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 87 | ▶ | use Cwd qw( cwd ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 87 | ▶ | use File::Spec::Functions qw( :ALL ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 87 | ▶ | use Log::Log4perl qw( get_logger :levels ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 87 | ▶ | use OpenInteract2::Constants qw( :log ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 87 | ▶ | use OpenInteract2::Context qw( CTX ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 87 | ▶ | use OpenInteract2::Exception qw( oi_error oi_param_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 87 | ▶ | use OpenInteract2::Setup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 87 | $OpenInteract2::Manage::VERSION = sprintf("%d.%02d", q$Revision: 1.49 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 87 | my $SYSTEM_PACKAGES = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | qw/ base base_box base_error base_group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | base_page base_security base_template base_theme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | base_user comments full_text news | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | lookup object_activity system_doc whats_new / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub SYSTEM_PACKAGES { return $SYSTEM_PACKAGES } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SYSTEM_PACKAGES: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 87 | my %PACKAGE_GROUPS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | SYSTEM => $SYSTEM_PACKAGES, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 87 | ▶ | use constant DEV_LIST => 'openinteract-dev@lists.sourceforge.net'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 87 | ▶ | use constant HELP_LIST => 'openinteract-help@lists.sourceforge.net'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 87 | @OpenInteract2::Manage::EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | SYSTEM_PACKAGES DEV_LIST HELP_LIST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # MAIN EXTERNAL INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 24 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 24 | my ( $pkg, $task_name, $params, @extra ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 24 | my $class = $pkg->get_factory_class( $task_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 20 | my $self = bless( { _status => [] }, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 20 | ▶ | if ( ref $params eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | ▶ | while ( my ( $name, $value ) = each %{ $params } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | $self->param( $name => $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # Check for defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 20 | my $param_metadata = $self->get_parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 20 | foreach my $name ( keys %{ $param_metadata } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 48 | ▶ | next if ( $self->param( $name ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 45 | ▶ | next unless ( $param_metadata->{ $name }{default} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | $self->param( $name => $param_metadata->{ $name }{default} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 20 | $self->init( @extra ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 20 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | $self->check_parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | $self->setup_task; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # Track our current directory so the task can feel free to do what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # it wants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | my $pwd = rel2abs( curdir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | $self->notify_observers( progress => 'Starting task' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | eval { $self->run_task }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | ▶ | if ( $error ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | $self->notify_observers( progress => 'Failed task' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | $self->param( task_failed => 'yes' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $self->param( task_error => "$error" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | $self->tear_down_task; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | chdir( $pwd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | if ( $error ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | oi_error $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | $self->notify_observers( progress => 'Task complete' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | return $self->get_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # STANDARD PARAMETER DESCRIPTIONS AND DESCRIPTORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub get_param_description { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_param_description: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my ( $self, $param_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ( $param_name eq 'source_dir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return "OpenInteract2 source directory, or at least a directory with " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | "the 'pkg/' and 'sample/' directories from the distribution."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | elsif ( $param_name eq 'website_dir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return "Functional OpenInteract2 website directory"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | elsif ( $param_name eq 'package_list_file' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return "Filename with packages to process, one per line"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | elsif ( $param_name eq 'package' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return "One or more packages to process"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return 'no description available'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub _get_source_dir_param { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_source_dir_param: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | description => $self->get_param_description( 'source_dir' ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | is_required => 'yes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | default => cwd(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # PARAMETER CHECKING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # Wrapper for all check methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | ▶ | sub check_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_parameters: called CC=12 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | $self->_init_setup_packages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | $self->param_initialize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | my $params = $self->get_parameters(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # First check parameters that are required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | my @field_notfound = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ▶ | while ( my ( $name, $info ) = each %{ $params } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | ▶ | next unless ( $info->{is_required} eq 'yes' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | ▶ | unless ( $self->param( $name ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | push @field_notfound, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | if ( scalar @field_notfound ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my %err = map { $_ => 'Required parameter not defined' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | @field_notfound; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | oi_param_error "A value for one or more required parameters ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | "was not found.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | { parameter_fail => \%err }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # Now do validatable parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | my %field_invalid = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | ▶ | while ( my ( $name, $info ) = each %{ $params } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | my $do_validate = ( ( defined $info->{is_required} and $info->{is_required} eq 'yes' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | ( defined $info->{do_validate} and $info->{do_validate} eq 'yes' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition22%2/9
defined $info->{'is_required'} && $info->{'is_required'} eq 'yes' || defined $info->{'do_validate'} && $info->{'do_validate'} eq 'yes'
defined $info->{"is_required"} and $info->{"is_required"} eq "yes"
defined $info->{"do_validate"} and $info->{"do_validate"} eq "yes"
MC/DC0%0/4
defined $info->{'is_required'} && $info->{'is_required'} eq 'yes' || defined $info->{'do_validate'} && $info->{'do_validate'} eq 'yes'
defined $info->{"is_required"}
$info->{"is_required"} eq "yes"
defined $info->{"do_validate"}
$info->{"do_validate"} eq "yes"
Truth table14%1/7
A and B || C and D
A= defined $info->{"is_required"}B= $info->{"is_required"} eq "yes"C= defined $info->{"do_validate"}D= $info->{"do_validate"} eq "yes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | ▶ | next unless ( $do_validate ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | my $value = $self->param( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my @errors = grep { defined $_ } $self->validate_param( $name, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | if ( scalar @errors ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $field_invalid{ $name } = \@errors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | ▶ | if ( scalar keys %field_invalid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | oi_param_error "One or more parameters failed a validity check", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { parameter_fail => \%field_invalid }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # Validate the given parameter -- these are built-in for everyone to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub validate_param { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_param: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my ( $self, $param_name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( $param_name eq 'source_dir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | return $self->_check_source_dir( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif ( $param_name eq 'website_dir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | unless ( -d $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return "Value for 'website_dir' ($value) must be a " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | "valid directory"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | elsif ( $param_name eq 'package_file' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | unless ( -f $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return "Value for 'package_file' ($value) must specify " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | "a valid file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub _check_source_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_source_dir: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my ( $self, $source_dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | unless ( -d $source_dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return "Value for 'source_dir' ($source_dir) is not a valid directory"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | foreach my $distrib_dir ( qw( pkg sample ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $full_distrib_dir = catdir( $source_dir, $distrib_dir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | unless ( -d $full_distrib_dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return "The 'source_dir' must contain valid subdirectory " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | "[$distrib_dir]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # PARAMETER INITIALIZATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # If package exist, reads in the SYSTEM value, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # package_list_file, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | ▶ | sub _init_setup_packages { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_setup_packages: called CC=4 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | my $initial_packages = $self->param( 'package' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | return unless ( $initial_packages ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( ref $initial_packages ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $self->param( package => [ $initial_packages ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->_init_setup_comma_packages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->_init_setup_package_groups; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->_init_read_packages_from_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Remove dupes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $packages = $self->param( 'package' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ( ref $packages eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my %names = map { $_ => 1 } @{ $packages }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->param( package => [ sort keys %names ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # allows --package=x,y --package=z to be combined; assumes 'package' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # param is already an arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub _init_setup_comma_packages { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_setup_comma_packages: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $packages = $self->param( 'package' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->param( package => [ split( /\s*,\s*/, join( ',', @{ $packages } ) ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # Allow a special keyword for users to specify all the initial (base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # packages. This allows something like: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # oi_manage --package=SYSTEM ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # oi_manage --package=SYSTEM,mypkg,theirpkg ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # and the keyword 'SYSTEM' will be replaced by all the system | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # packages, which can be found by doing 'oi2_manage system_packages'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # assumes 'package' param is already an arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub _init_setup_package_groups { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_setup_package_groups: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $packages = $self->param( 'package' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | return unless ( ref $packages eq 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my %pkg_names = map { $_ => 1 } @{ $packages }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | foreach my $group_key ( keys %PACKAGE_GROUPS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if ( exists $pkg_names{ $group_key } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $pkg_names{ $_ }++ for ( @{ $PACKAGE_GROUPS{ $group_key } } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | delete $pkg_names{ $group_key }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->param( package => [ sort keys %pkg_names ] ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # assumes 'package' param is already an arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub _init_read_packages_from_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_read_packages_from_file: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $filename = $self->param( 'package_list_file' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return unless ( $filename ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | unless ( -f $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | oi_error "Failure reading package list file [$filename]: ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | "file does not exist"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | eval { open( PKG, '<', $filename ) || die $! }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | oi_error "Failure reading package list file [$filename]: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my @read_packages = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | while ( <PKG> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | next if /^\s*\#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | next if /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | push @read_packages, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | close( PKG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # They can also specify --package, so add those too -- don't worry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # about dupes, they get weeded out later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | $self->param( package => [ @read_packages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | @{ $self->param( 'package' ) } ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # TASK LIST/CHECK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub is_valid_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_task: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my ( $class, $task_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my %tasks = map { $_ => 1 } $class->valid_tasks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return ( defined $tasks{ $task_name } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub valid_tasks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid_tasks: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return __PACKAGE__->get_registered_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub valid_tasks_description { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid_tasks_description: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my %tasks = map { $_ => 1 } $self->valid_tasks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | foreach my $task ( keys %tasks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $task_class = $self->get_factory_class( $task ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $desc = $task_class->get_brief_description; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $tasks{ $task } = $desc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return \%tasks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # Retrieves the parameter hashref for a particular task -- this can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # a class method (needs $task_name filled in) or an object method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub task_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
task_parameters: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my ( $item, $task_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my ( $manage ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if ( ref $item ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $manage = $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | unless ( $task_name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | oi_error "If you call 'task_parameters' as a class method ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | "you must pass the task name as the only argument."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $manage = $item->new( $task_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $params = $manage->get_parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my %basic_params = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | while ( my ( $name, $info ) = each %{ $params } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $info->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $basic_params{ $name } = $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return \%basic_params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # Retrieves all parameter names plus whether they're | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # boolean/multivalued | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub all_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_parameters: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my %all = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | foreach my $task_name ( $class->valid_tasks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $param_data = $class->task_parameters( $task_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | next unless ( ref $param_data eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | while ( my ( $name, $info ) = each %{ $param_data } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | next if ( $all{ $name } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $all{ $name } = $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return \%all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | sub all_parameters_long_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_parameters_long_options: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $all_params = $class->all_parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my @opt = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | while ( my ( $name, $info ) = each %{ $all_params } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if ( defined $info->{is_boolean} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $info->{"is_boolean"} and $info->{"is_boolean"} eq "yes"
MC/DC0%0/2
defined $info->{"is_boolean"} and $info->{"is_boolean"} eq "yes"
defined $info->{"is_boolean"}
$info->{"is_boolean"} eq "yes"
Truth table0%0/3
A and B
A= defined $info->{"is_boolean"}B= $info->{"is_boolean"} eq "yes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | $info->{is_boolean} eq 'yes' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | push @opt, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ▶ | elsif ( defined $info->{is_multivalued} and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $info->{"is_multivalued"} and $info->{"is_multivalued"} eq "yes"
MC/DC0%0/2
defined $info->{"is_multivalued"} and $info->{"is_multivalued"} eq "yes"
defined $info->{"is_multivalued"}
$info->{"is_multivalued"} eq "yes"
Truth table0%0/3
A and B
A= defined $info->{"is_multivalued"}B= $info->{"is_multivalued"} eq "yes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $info->{is_multivalued} eq 'yes' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | push @opt, "$name=s@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | push @opt, "$name=s"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | return @opt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # PARAMETERS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub param_copy_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param_copy_from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my ( $self, $other_task ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->param_assign( $other_task->param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return $self->param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # STATUS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 104 | ▶ | sub _add_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_status: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 104 | my ( $self, @status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 104 | push @{ $self->{_status} }, @status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 104 | foreach my $hr ( @status ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 104 | $self->notify_observers( status => $hr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 104 | return $self->{_status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub _add_status_head { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_status_head: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my ( $self, @status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | unshift @{ $self->{_status} }, @status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | foreach my $hr ( @status ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $self->notify_observers( status => $hr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | return $self->{_status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | ▶ | sub get_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | return @{ $self->{_status} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | sub merge_status_by_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_status_by_action: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ( $item, @status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | if ( scalar @status == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @status == 0 and UNIVERSAL::isa($item, "OpenInteract2::Manage")
MC/DC0%0/2
scalar @status == 0 and UNIVERSAL::isa($item, "OpenInteract2::Manage")
scalar @status == 0
UNIVERSAL::isa($item, "OpenInteract2::Manage")
Truth table0%0/3
A and B
A= scalar @status == 0B= UNIVERSAL::isa($item, "OpenInteract2::Manage")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | and UNIVERSAL::isa( $item, 'OpenInteract2::Manage' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | @status = $item->get_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $current_action = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my @tmp_status = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my @new_status = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | foreach my $s ( @status ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | unless ( $current_action ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $current_action = $s->{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if ( defined $s->{action} and $s->{action} ne $current_action ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $s->{"action"} and $s->{"action"} ne $current_action
MC/DC0%0/2
defined $s->{"action"} and $s->{"action"} ne $current_action
defined $s->{"action"}
$s->{"action"} ne $current_action
Truth table0%0/3
A and B
A= defined $s->{"action"}B= $s->{"action"} ne $current_action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | push @new_status, { action => $current_action, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | status => [ @tmp_status ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | @tmp_status = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $current_action = $s->{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | push @tmp_status, $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if ( scalar @tmp_status > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | push @new_status, { action => $current_action, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | status => \@tmp_status }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return @new_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # shortcut for adding bad/good status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | sub _fail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my ( $self, $action, $msg, %additional ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $self->_add_status({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | is_ok => 'no', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | action => $action, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | message => $msg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | %additional, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub _ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ok: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my ( $self, $action, $msg, %additional ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $self->_add_status({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | is_ok => 'yes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | action => $action, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | message => $msg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | %additional, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # INFRASTRUCTURE (SUBCLASSES) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | sub _setup_context { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_context: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | my ( $self, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # don't recreate the context every time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | eval { OpenInteract2::Context->instance }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | ▶ | return unless ( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | my $log = get_logger(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 1 | ▶ | if ( $self->param( 'debug' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $log->level( $DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | my $website_dir = $self->param( 'website_dir' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 1 | ▶ | unless ( -d $website_dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | oi_error "Cannot open context with invalid website ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | "directory '$website_dir'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 1 | $log->info( "Website directory '$website_dir' exists, setting up context..." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | my $bootstrap = OpenInteract2::Config::Bootstrap->new({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | website_dir => $website_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | $log->info( "Created bootstrap config ok, creating context..." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | OpenInteract2::Context->create( $bootstrap, $params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $log->info( "Context setup for management task(s) ok" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # Creates status entry with all files removed/skipped/updated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | sub _set_copy_file_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_copy_file_status: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my ( $self, $status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | $status->{copied} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status->{"copied"} ||= []
MC/DC0%0/1
$status->{"copied"} ||= []
$status->{"copied"}
Truth table0%0/2
A
A= $status->{"copied"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | $status->{skipped} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status->{"skipped"} ||= []
MC/DC0%0/1
$status->{"skipped"} ||= []
$status->{"skipped"}
Truth table0%0/2
A
A= $status->{"skipped"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | $status->{same} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status->{"same"} ||= []
MC/DC0%0/1
$status->{"same"} ||= []
$status->{"same"}
Truth table0%0/2
A
A= $status->{"same"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | foreach my $file ( @{ $status->{copied} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->_ok( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 'copy updated template files', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | "File $file copied", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | filename => $file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | foreach my $file ( @{ $status->{skipped} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $self->_ok( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 'copy updated template files', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | "File $file skipped, marked as read-only", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | filename => $file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | foreach my $file ( @{ $status->{same} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $self->_ok( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 'copy updated template files', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | "File $file skipped, source and destination same", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | filename => $file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # FACTORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | sub factory_log { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
factory_log: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # no-op so we get around the l4p 'no init' msg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # my ( $self, @msg ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # get_logger()->info( @msg ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 4 | ▶ | sub factory_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
factory_error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 4 | my ( $self, @msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 4 | get_logger()->error( @msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 4 | die @msg, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | ############################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # FIND ALL MANAGEMENT TASKS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 87 | OpenInteract2::Util->find_factory_subclasses( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 'OpenInteract2::Manage', @INC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # All are optional except run_task() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # Run at new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 20 | ▶ | sub init {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # Identify the name by which your task is known | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | sub get_name { return undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # Help out tools using your task and describe what it does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | sub get_brief_description { return 'No description available' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_brief_description: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | # Return parameter information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | sub get_parameters { return {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parameters: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # Do the work! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | sub run_task { die "Define run_task() in subclass" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_task: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # Do work before run_task() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | sub setup_task { return undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_task: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # Do cleanup after run_task() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | sub tear_down_task { return undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tear_down_task: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # Do pre-validation transformations of parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 3 | ▶ | sub param_initialize { return undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param_initialize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 87 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||