| 1 | # | ||||||||||||||||||||||||||||
| 2 | # CA::WAAE - Perl Interface to CA's Workflow Automation AutoSys Edition job control. | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # Original CA::AutoSys code: | ||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2007 Sinisa Susnjar <sini@cpan.org> | ||||||||||||||||||||||||||||
| 6 | # See LICENSE for terms of distribution. | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 9 | # modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||||||||||
| 10 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||||
| 11 | # version 2.1 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||
| 16 | # Lesser General Public License for more details. | ||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||
| 18 | # You should have received a copy of the GNU Lesser General Public | ||||||||||||||||||||||||||||
| 19 | # License along with this library; if not, write to the Free Software | ||||||||||||||||||||||||||||
| 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | package CA::WAAE::JobList; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | my $debug = 0; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 33 | 0 | my $self = {}; | |||||||||||||||||||||||||||
| 34 | 0 | my $class = shift(); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | $self->{parent} = $args{parent} ? $args{parent} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | $self->{dbh} | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | = $args{database_handle} ? $args{database_handle} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | $self->{sth} | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | = $args{statement_handle} ? $args{statement_handle} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $self->{parent_job} = $args{parent_job} ? $args{parent_job} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | $self->{table_prefix} | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | = $args{table_prefix} ? $args{table_prefix} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ($debug) { printf( "DEBUG: Job(%s) created.\n", $self ); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | bless($self); | |||||||||||||||||||||||||||
| 51 | 0 | return $self; | |||||||||||||||||||||||||||
| 52 | } # new() | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub _fetch_next { | ||||||||||||||||||||||||||
|
Subroutine
_fetch_next: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ($debug) { printf( "DEBUG: Job(%s): _fetch_next()\n", $self ); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ( my $h = $self->{sth}->fetchrow_hashref('NAME_lc') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | return CA::WAAE::Job->new( %$self, %$h ); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | else { | ||||||||||||||||||||||||||||
| 61 | 0 | $self->{sth}->finish(); | |||||||||||||||||||||||||||
| 62 | 0 | delete $self->{sth}; | |||||||||||||||||||||||||||
| 63 | 0 | return undef; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | } # _fetch_next() | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub next_job { | ||||||||||||||||||||||||||
|
Subroutine
next_job: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 68 | 0 | my $self = shift(); | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($debug) { printf( "DEBUG: Job(%s): next_job()\n", $self ); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | return $self->_fetch_next(); | |||||||||||||||||||||||||||
| 71 | } # next_job() | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub next_child { | ||||||||||||||||||||||||||
|
Subroutine
next_child: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 74 | 0 | my $self = shift(); | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ($debug) { printf( "DEBUG: Job(%s): next_child()\n", $self ); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | return $self->_fetch_next(); | |||||||||||||||||||||||||||
| 77 | } # next_child() | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | package CA::WAAE::Job; | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | use Time::Piece qw(localtime); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 1 | our %status_names = ( | |||||||||||||||||||||||||||
| 84 | 0 => ' ', # *empty* | ||||||||||||||||||||||||||||
| 85 | 1 => 'RU', # running | ||||||||||||||||||||||||||||
| 86 | 2 => ' 2', # *not defined* | ||||||||||||||||||||||||||||
| 87 | 3 => 'ST', # starting | ||||||||||||||||||||||||||||
| 88 | 4 => 'SU', # success | ||||||||||||||||||||||||||||
| 89 | 5 => 'FA', # failure | ||||||||||||||||||||||||||||
| 90 | 6 => 'TE', # terminated | ||||||||||||||||||||||||||||
| 91 | 7 => 'OI', # on ice | ||||||||||||||||||||||||||||
| 92 | 8 => 'IN', # inactive | ||||||||||||||||||||||||||||
| 93 | 9 => 'AC', # activated | ||||||||||||||||||||||||||||
| 94 | 10 => 'RE', # restart | ||||||||||||||||||||||||||||
| 95 | 11 => 'OH', # on hold | ||||||||||||||||||||||||||||
| 96 | 12 => 'QW', # queue wait | ||||||||||||||||||||||||||||
| 97 | 13 => '13', # *not defined* | ||||||||||||||||||||||||||||
| 98 | 14 => 'RD', # refresh dependencies | ||||||||||||||||||||||||||||
| 99 | 15 => 'RF', # refresh filewatcher | ||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 103 | 1 | NONE => 0, | |||||||||||||||||||||||||||
| 104 | RUNNING => 1, | ||||||||||||||||||||||||||||
| 105 | UNDEF_2 => 2, | ||||||||||||||||||||||||||||
| 106 | STARTING => 3, | ||||||||||||||||||||||||||||
| 107 | SUCCESS => 4, | ||||||||||||||||||||||||||||
| 108 | FAILURE => 5, | ||||||||||||||||||||||||||||
| 109 | TERMINATED => 6, | ||||||||||||||||||||||||||||
| 110 | ON_ICE => 7, | ||||||||||||||||||||||||||||
| 111 | INACTIVE => 8, | ||||||||||||||||||||||||||||
| 112 | ACTIVATED => 9, | ||||||||||||||||||||||||||||
| 113 | RESTART => 10, | ||||||||||||||||||||||||||||
| 114 | ON_HOLD => 11, | ||||||||||||||||||||||||||||
| 115 | QUEUE_WAIT => 12, | ||||||||||||||||||||||||||||
| 116 | UNDEF_13 => 13, | ||||||||||||||||||||||||||||
| 117 | REFRESH_DEP => 14, | ||||||||||||||||||||||||||||
| 118 | REFRESH_FW => 15 | ||||||||||||||||||||||||||||
| 119 | 1 | }; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 1 | our %long_status = ( | |||||||||||||||||||||||||||
| 122 | 0 => "NONE", | ||||||||||||||||||||||||||||
| 123 | 1 => "RUNNING", | ||||||||||||||||||||||||||||
| 124 | 2 => "UNDEF_2", | ||||||||||||||||||||||||||||
| 125 | 3 => "STARTING", | ||||||||||||||||||||||||||||
| 126 | 4 => "SUCCESS", | ||||||||||||||||||||||||||||
| 127 | 5 => "FAILURE", | ||||||||||||||||||||||||||||
| 128 | 6 => "TERMINATED", | ||||||||||||||||||||||||||||
| 129 | 7 => "ON_ICE", | ||||||||||||||||||||||||||||
| 130 | 8 => "INACTIVE", | ||||||||||||||||||||||||||||
| 131 | 9 => "ACTIVATED", | ||||||||||||||||||||||||||||
| 132 | 10 => "RESTART", | ||||||||||||||||||||||||||||
| 133 | 11 => "ON_HOLD", | ||||||||||||||||||||||||||||
| 134 | 12 => "QUEUE_WAIT", | ||||||||||||||||||||||||||||
| 135 | 13 => "UNDEF_13", | ||||||||||||||||||||||||||||
| 136 | 14 => "REFRESH_DEP", | ||||||||||||||||||||||||||||
| 137 | 15 => "REFRESH_FW" | ||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 142 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 143 | 0 | my $self = bless {%args}, $class; | |||||||||||||||||||||||||||
| 144 | 0 | return $self; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 1 | my @command_attr = qw( | |||||||||||||||||||||||||||
| 148 | chk_files | ||||||||||||||||||||||||||||
| 149 | command | ||||||||||||||||||||||||||||
| 150 | envvars | ||||||||||||||||||||||||||||
| 151 | heartbeat_interval | ||||||||||||||||||||||||||||
| 152 | interactive | ||||||||||||||||||||||||||||
| 153 | is_script | ||||||||||||||||||||||||||||
| 154 | over_num | ||||||||||||||||||||||||||||
| 155 | shell | ||||||||||||||||||||||||||||
| 156 | std_err_file | ||||||||||||||||||||||||||||
| 157 | std_in_file | ||||||||||||||||||||||||||||
| 158 | std_out_file | ||||||||||||||||||||||||||||
| 159 | ulimit | ||||||||||||||||||||||||||||
| 160 | userid | ||||||||||||||||||||||||||||
| 161 | elevated | ||||||||||||||||||||||||||||
| 162 | criteria | ||||||||||||||||||||||||||||
| 163 | dbtype | ||||||||||||||||||||||||||||
| 164 | dburl | ||||||||||||||||||||||||||||
| 165 | dbuserid | ||||||||||||||||||||||||||||
| 166 | dbuserrole | ||||||||||||||||||||||||||||
| 167 | monitor_condition | ||||||||||||||||||||||||||||
| 168 | monitor_type | ||||||||||||||||||||||||||||
| 169 | obj_name | ||||||||||||||||||||||||||||
| 170 | params | ||||||||||||||||||||||||||||
| 171 | params_num | ||||||||||||||||||||||||||||
| 172 | rtn_type | ||||||||||||||||||||||||||||
| 173 | trig_condition | ||||||||||||||||||||||||||||
| 174 | trig_type | ||||||||||||||||||||||||||||
| 175 | ); | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 1 | for my $attr (@command_attr) { | |||||||||||||||||||||||||||
| 178 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | *$attr = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 180 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $data = $self->get_data() or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | $data->{$attr}; | |||||||||||||||||||||||||||
| 183 | 27 | }; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub job_type { $_[0]->{job_type_name} } | ||||||||||||||||||||||||||
|
Subroutine
job_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 1 | my %job_table = ( | |||||||||||||||||||||||||||
| 189 | CMD => 'command_job', | ||||||||||||||||||||||||||||
| 190 | SQL => 'sql_job', | ||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub get_data { | ||||||||||||||||||||||||||
|
Subroutine
get_data: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 194 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 195 | 0 | my $job_type = $self->job_type(); | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | my $table = $job_table{$job_type} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | return $self->{JOB} if $self->{JOB}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $job_id = $self->{joid} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return unless defined $job_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $prefix = $self->{table_prefix} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'table_prefix'} || ''
MC/DC0%0/1
$self->{'table_prefix'} || ''
$self->{'table_prefix'}
Truth table0%0/2
A
A= $self->{'table_prefix'}
| |||||||||||||||||||||||||||||
| 202 | 0 | my $sql = <<SQL; | |||||||||||||||||||||||||||
| 203 | select * | ||||||||||||||||||||||||||||
| 204 | from ${prefix}$table | ||||||||||||||||||||||||||||
| 205 | where joid = ? | ||||||||||||||||||||||||||||
| 206 | SQL | ||||||||||||||||||||||||||||
| 207 | 0 | my $sth = $self->{dbh}->prepare($sql); | |||||||||||||||||||||||||||
| 208 | 0 | $sth->execute($job_id); | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | my $command_data = $sth->fetchrow_hashref('NAME_lc') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | $sth->finish; | |||||||||||||||||||||||||||
| 211 | 0 | $self->{JOB} = $command_data; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub find_children { | ||||||||||||||||||||||||||
|
Subroutine
find_children: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | 0 | my $self = shift(); | |||||||||||||||||||||||||||
| 216 | 0 | ▶ | if ($debug) { printf( "DEBUG: Job(%s): find_children()\n", $self ); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 0 | my $query = $self->{parent}->_query() . <<SQL; | |||||||||||||||||||||||||||
| 218 | where j.box_joid = $self->{joid} | ||||||||||||||||||||||||||||
| 219 | order by j.joid | ||||||||||||||||||||||||||||
| 220 | SQL | ||||||||||||||||||||||||||||
| 221 | 0 | my $sth = $self->{dbh}->prepare($query); | |||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($debug) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | printf( "DEBUG: Job(%s): selecting children for joid %d\n", | ||||||||||||||||||||||||||||
| 224 | 0 | $self, $self->{joid} ); | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 0 | $sth->execute(); | |||||||||||||||||||||||||||
| 227 | return CA::WAAE::JobList->new( | ||||||||||||||||||||||||||||
| 228 | parent => $self->{parent}, | ||||||||||||||||||||||||||||
| 229 | database_handle => $self->{dbh}, | ||||||||||||||||||||||||||||
| 230 | 0 | statement_handle => $sth, | |||||||||||||||||||||||||||
| 231 | parent_job => $self | ||||||||||||||||||||||||||||
| 232 | ); | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub children { | ||||||||||||||||||||||||||
|
Subroutine
children: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 237 | 0 | my $h = $self->find_children(); | |||||||||||||||||||||||||||
| 238 | 0 | my @list; | |||||||||||||||||||||||||||
| 239 | 0 | ▶ | while ( my $job = $h->next_job() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 0 | push @list, $job; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 0 | ▶ | return wantarray ? @list : \@list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub status { | ||||||||||||||||||||||||||
|
Subroutine
status: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 247 | 0 | ▶ | my $status = shift || $self->{status}; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->{'status'}
MC/DC0%0/2
shift() || $self->{'status'}
shift()
$self->{'status'}
Truth table0%0/3
A || B
A= shift()B= $self->{'status'}
| |||||||||||||||||||||||||||||
| 248 | 0 | return $status_names{$status}; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub long_status { | ||||||||||||||||||||||||||
|
Subroutine
long_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 252 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | my $status = shift || $self->{status}; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->{'status'}
MC/DC0%0/2
shift() || $self->{'status'}
shift()
$self->{'status'}
Truth table0%0/3
A || B
A= shift()B= $self->{'status'}
| |||||||||||||||||||||||||||||
| 254 | 0 | return $long_status{$status}; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub time { | ||||||||||||||||||||||||||
|
Subroutine
time: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 258 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 259 | 0 | my $tm = shift; | |||||||||||||||||||||||||||
| 260 | 0 | ▶ | $tm = $self->{$tm} if defined($tm) and $tm =~ /\D/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tm and $tm =~ /\D/
MC/DC0%0/2
defined $tm and $tm =~ /\D/
defined $tm
$tm =~ /\D/
Truth table0%0/3
A and B
A= defined $tmB= $tm =~ /\D/
| |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return if !defined($tm) || $tm == 999999999; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $tm or $tm == 999999999
MC/DC0%0/2
not defined $tm or $tm == 999999999
not defined $tm
$tm == 999999999
Truth table0%0/3
not(A) or B
A= not defined $tmB= $tm == 999999999
| |||||||||||||||||||||||||||||
| 262 | 0 | localtime($tm); | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub strftime { | ||||||||||||||||||||||||||
|
Subroutine
strftime: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 266 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 267 | 0 | my $time = shift; | |||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $fmt = shift || "%Y-%m-%d %H:%M:%S"; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || '%Y-%m-%d %H:%M:%S'
MC/DC0%0/1
shift() || '%Y-%m-%d %H:%M:%S'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $tm = $self->time($time) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | return $tm->strftime($fmt); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 1 | 1; | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | __END__ | ||||||||||||||||||||||||||||