| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ###################### | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright (C) 2011 TU Clausthal, Institut fuer Maschinenwesen, Joachim Langenbach | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ###################### | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # Pod::Weaver infos | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # ABSTRACT: Object to represant the changes of an option | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | package CAD::Firemen::Change; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | $CAD::Firemen::Change::VERSION = '0.7.1'; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | ▶ | use CAD::Firemen::Common qw(strip); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 6 | ▶ | use CAD::Firemen::Change::Type; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my ($class) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my (%params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # check parameters | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if(!exists($params{"name"})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $params{"name"} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if(!exists($params{"valueOld"})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $params{"valueOld"} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if(!exists($params{"valueNew"})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $params{"valueNew"} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | '_option' => $params{"name"}, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | '_valueOld' => $params{"valueOld"}, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | '_valueNew' => $params{"valueNew"}, | |||||||||||||||||||||||||||||||||||||||||
| 55 | '_changeType' => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | '_changeDescription' => "", | ||||||||||||||||||||||||||||||||||||||||||
| 57 | '_possibleValuesOld' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 58 | '_possibleValuesNew' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 59 | '_defaultValueOld' => "", | ||||||||||||||||||||||||||||||||||||||||||
| 60 | '_defaultValueNew' => "" | ||||||||||||||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->evalChange(); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | sub setOption { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setOption: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if(!defined($name)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $self->{'_option'} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | sub option { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
option: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return $self->{'_option'}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | sub setValueOld { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setValueOld: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->{'_valueOld'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | sub valueOld { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valueOld: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return $self->{'_valueOld'}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | sub setValueNew { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setValueNew: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->{'_valueNew'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | sub valueNew { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valueNew: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return $self->{'_valueNew'}; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | sub setPossibleValuesOld { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setPossibleValuesOld: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $valuesRef = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if(!defined($valuesRef) || (ref($valuesRef) ne "ARRAY")){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $valuesRef or ref $valuesRef ne "ARRAY"
MC/DC0%0/2
not defined $valuesRef or ref $valuesRef ne "ARRAY"
not defined $valuesRef
ref $valuesRef ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not defined $valuesRefB= ref $valuesRef ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $self->{'_possibleValuesOld'} = $valuesRef; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | sub possibleValuesOld { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
possibleValuesOld: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return $self->{'_possibleValuesOld'}; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | sub setPossibleValuesNew { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setPossibleValuesNew: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $valuesRef = shift; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if(!defined($valuesRef) || (ref($valuesRef) ne "ARRAY")){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $valuesRef or ref $valuesRef ne "ARRAY"
MC/DC0%0/2
not defined $valuesRef or ref $valuesRef ne "ARRAY"
not defined $valuesRef
ref $valuesRef ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not defined $valuesRefB= ref $valuesRef ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->{'_possibleValuesNew'} = $valuesRef; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | sub possibleValuesNew { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
possibleValuesNew: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return $self->{'_possibleValuesNew'}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | sub setDefaultValueOld { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDefaultValueOld: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # default value must be an possible value | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | foreach my $posValue (@{$self->possibleValuesOld()}){ | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if($value eq $posValue){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if(!$found){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->{'_defaultValueOld'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | sub defaultValueOld { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultValueOld: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return $self->{'_defaultValueOld'}; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | sub setDefaultValueNew { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDefaultValueNew: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # default value must be an possible value | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | foreach my $posValue (@{$self->possibleValuesNew()}){ | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if($value eq $posValue){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if(!$found){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $self->{'_defaultValueNew'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | sub defaultValueNew { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultValueNew: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | return $self->{'_defaultValueNew'}; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | sub setChangeDescription { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setChangeDescription: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->{'_changeDescription'} = strip($value); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | sub changeDescription { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
changeDescription: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | return $self->{'_changeDescription'}; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | sub evalChange { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evalChange: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # reset change type | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->_setChangeType(CAD::Firemen::Change::Type->NoChange); | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | # determine whether values or default values have changed | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $valuesChanged = 0; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $defaultChanged = 0; | |||||||||||||||||||||||||||||||||||||||||
| 217 | # check for removed options | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | foreach my $value (@{$self->possibleValuesOld()}){ | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $exist = 0; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | foreach my $newValue (@{$self->possibleValuesNew()}){ | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if($value eq $newValue){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $exist = 1; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if(!$exist){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $self->setChangeDescription($self->changeDescription() ."\nRemoved ". $value); | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $valuesChanged = 1; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | # check for added options | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | foreach my $value (@{$self->possibleValuesNew()}){ | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $exist = 0; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | foreach my $oldValue (@{$self->possibleValuesOld()}){ | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if($value eq $oldValue){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $exist = 1; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if(!$exist){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->setChangeDescription($self->changeDescription() ."\nAdded ". $value); | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $valuesChanged = 1; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | # check for changed default value | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if($self->defaultValueNew() ne $self->defaultValueOld()){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $self->setChangeDescription($self->changeDescription() ."\nDefault value changed from ". $self->defaultValueOld() ." to ". $self->defaultValueNew()); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $defaultChanged = 1; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | # evaluate results | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if(($self->valueOld() ne $self->valueNew()) && (uc($self->valueOld()) eq uc($self->valueNew()))){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->valueOld ne $self->valueNew and uc $self->valueOld eq uc $self->valueNew
MC/DC0%0/2
$self->valueOld ne $self->valueNew and uc $self->valueOld eq uc $self->valueNew
$self->valueOld ne $self->valueNew
uc $self->valueOld eq uc $self->valueNew
Truth table0%0/3
A and B
A= $self->valueOld ne $self->valueNewB= uc $self->valueOld eq uc $self->valueNew
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->_addChangeType(CAD::Firemen::Change::Type->Case); | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if(($self->valueOld() =~ m/^[A-Za-z]:[\\\/]/) && ($self->valueNew() =~ m/^[A-Za-z]:[\\\/]/)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->valueOld =~ m[^[A-Za-z]:[\\/]] and $self->valueNew =~ m[^[A-Za-z]:[\\/]]
MC/DC0%0/2
$self->valueOld =~ m[^[A-Za-z]:[\\/]] and $self->valueNew =~ m[^[A-Za-z]:[\\/]]
$self->valueOld =~ m[^[A-Za-z]:[\\/]]
$self->valueNew =~ m[^[A-Za-z]:[\\/]]
Truth table0%0/3
A and B
A= $self->valueOld =~ m[^[A-Za-z]:[\\/]]B= $self->valueNew =~ m[^[A-Za-z]:[\\/]]
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->_addChangeType(CAD::Firemen::Change::Type->Path); | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | # NoSpecial means only valueOld and valueNew have changed | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # therefore it is NoSpecial, if values are not equal and it is not Case or Path | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if(($self->valueOld() ne $self->valueNew()) && !$self->changeType(CAD::Firemen::Change::Type->Case) && !$self->changeType(CAD::Firemen::Change::Type->Case)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->valueOld ne $self->valueNew and not $self->changeType("CAD::Firemen::Change::Type"->Case) and not $self->changeType("CAD::Firemen::Change::Type"->Case)
$self->valueOld ne $self->valueNew and not $self->changeType("CAD::Firemen::Change::Type"->Case)
MC/DC0%0/3
$self->valueOld ne $self->valueNew and not $self->changeType("CAD::Firemen::Change::Type"->Case) and not $self->changeType("CAD::Firemen::Change::Type"->Case)
$self->valueOld ne $self->valueNew
not $self->changeType("CAD::Firemen::Change::Type"->Case)
not $self->changeType("CAD::Firemen::Change::Type"->Case)
Truth table0%0/4
A and not(B) and not(C)
A= $self->valueOld ne $self->valueNewB= not $self->changeType("CAD::Firemen::Change::Type"->Case)C= not $self->changeType("CAD::Firemen::Change::Type"->Case)
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->_addChangeType(CAD::Firemen::Change::Type->NoSpecial); | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if($valuesChanged){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $self->_addChangeType(CAD::Firemen::Change::Type->ValuesChanged); | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if($defaultChanged){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->_addChangeType(CAD::Firemen::Change::Type->DefaultValueChanged); | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | sub _setChangeType { | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setChangeType: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | delete($self->{'_changeType'}); | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->{'_changeType'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return $self->_addChangeType($value); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | sub _addChangeType { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_addChangeType: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if(!defined($value)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->{'_changeType'}->{$value} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 294 | # if we have a change now, remove NoChange | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if($value ne CAD::Firemen::Change::Type->NoChange){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if(exists($self->{'_changeType'}->{CAD::Firemen::Change::Type->NoChange})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | delete($self->{'_changeType'}->{CAD::Firemen::Change::Type->NoChange}); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | sub changeType { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
changeType: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if(!defined($type)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if(exists($self->{'_changeType'}->{$type})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | sub highlightColor { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
highlightColor: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | if($self->changeType(CAD::Firemen::Change::Type->Case)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return "CYAN"; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | elsif($self->changeType(CAD::Firemen::Change::Type->Path)){ | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return "MAGENTA"; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | return "YELLOW"; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | __END__ | ||||||||||||||||||||||||||||||||||||||||||