Pad/Type/Path.pm

filter: Statementstmt 96.4% 55 / 57 Branchbran 100% 12 / 12 Conditioncond 91.6% 11 / 12 MC/DCmcdc 85.7% 6 / 7 Subroutinesub 90.9% 10 / 11 Podpod 100% 7 / 7 totaltotal 95.2% 101 / 106 CC 11 SCAR 10.3
CC
11
Cov
96%
prepare
5.0
checkSpecKeys
3.0
check
3.0
CRAP 2.8
« Pad/Spec.pm ↑ Summary Pad/Result.pm »
1 18 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 18 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 18 ▶use Getopt::Pad::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 class Getopt::Pad::Type::Path :isa(Getopt::Pad::Type) :abstract {
7 18 ▶ use constant SPEC_KEYS => ['mustExist', 'createPathIfMissing'];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 our $VERSION = '0.04';
10  
11 2 field $mustExist :param :reader = 0;
12 2 ▶ field $createPathIfMissing :param :reader = 0;
Subroutine mustExist: called CC=1 SCAR=0.4
Pod documented
13  
14 63 ▶ method checkSpecKeys :common (%args) {
Subroutine checkSpecKeys: called CC=3 SCAR=11.0
Subroutine createPathIfMissing: not called CC=1 SCAR=0.0
Pod documented
Pod documented
15 63 ▶ return 'mustExist and createPathIfMissing are mutually exclusive' if $args{mustExist} && $args{createPathIfMissing};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mustExist"} and $args{"createPathIfMissing"} 2 61 63
Condition100%3/3
$args{"mustExist"} and $args{"createPathIfMissing"}
!ll&&!rl&&r
36252
MC/DC100%2/2
$args{"mustExist"} and $args{"createPathIfMissing"}
$args{"mustExist"} $args{"createPathIfMissing"}
Truth table100%3/3
A and B
A= $args{"mustExist"}B= $args{"createPathIfMissing"}
ABresult
0X0
100
111
16 61 return undef;
17 18 }
18  
19 55 ▶ method glSuffix() { return '=s' }
Subroutine glSuffix: called CC=1 SCAR=0.0
Pod documented
20  
21 18 method kind;
22 18 method pathExists($value);
23  
24 # Create the path; return undef, or the reason it could not be created.
25 18 method createPath($value);
26  
27 12 ▶ method check($value) {
Subroutine check: called CC=3 SCAR=11.0
Pod documented
28 12 ▶ return sprintf("%s '%s' does not exist", $self->kind, $value) if $mustExist && !$self->pathExists($value);
Branch: 1 branch
BranchTrueFalseTotal
if $mustExist and not $self->pathExists($value) 3 9 12
Condition100%3/3
$mustExist and not $self->pathExists($value)
!ll&&!rl&&r
723
MC/DC100%2/2
$mustExist and not $self->pathExists($value)
$mustExist not $self->pathExists($value)
Truth table100%3/3
A and not(B)
A= $mustExistB= not $self->pathExists($value)
ABresult
0X0
100
111
29 9 return undef;
30 18 }
31  
32 # A path is created when the parse settles on it, not when a default is
33 # checked at spec build time.
34 11 ▶ method prepare($value) {
Subroutine prepare: called CC=5 SCAR=16.1
Pod documented
35 11 ▶ return undef if !defined $value || !$createPathIfMissing || $self->pathExists($value);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value && $createPathIfMissing or $self->pathExists($value) 3 8 11
Condition83%5/6
not defined $value && $createPathIfMissing or $self->pathExists($value)
l!l&&r!l&&!r
218
defined $value && $createPathIfMissing
!ll&&!rl&&r
029
MC/DC66%2/3
not defined $value && $createPathIfMissing or $self->pathExists($value)
defined $value $createPathIfMissing $self->pathExists($value)
Truth table75%3/4
not(A && B) or C
A= defined $valueB= $createPathIfMissingC= $self->pathExists($value)
ABCresult
0XX1
10X1
1111
1100
36  
37 8 my $reason = $self->createPath($value);
38 8 ▶ return defined $reason ? sprintf("cannot create %s '%s': %s", $self->kind, $value, $reason) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $reason ? : 2 6 8
39 18 }
40  
41 11 ▶ method constraintNotes() {
Subroutine constraintNotes: called CC=3 SCAR=11.0
Pod documented
42 11 ▶ return ('has to exist') if $mustExist;
Branch: 1 branch
BranchTrueFalseTotal
if $mustExist 9 2 11
43 2 ▶ return ('created if missing') if $createPathIfMissing;
Branch: 1 branch
BranchTrueFalseTotal
if $createPathIfMissing 1 1 2
44 1 return ();
45 18 }
46 }
47  
48 18 1;
49  
50 __END__
« Pad/Spec.pm ↑ Summary Pad/Result.pm »