| 1 | 23 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 23 | ▶ | use Object::Pad; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 23 | ▶ | 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 | 23 | ▶ | use constant SPEC_KEYS => ['mustExist', 'createPathIfMissing']; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 23 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | field $mustExist :param :reader = 0; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | field $createPathIfMissing :param :reader = 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mustExist: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | 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 | 73 | ▶ | return 'mustExist and createPathIfMissing are mutually exclusive' if $args{mustExist} && $args{createPathIfMissing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args{"mustExist"} and $args{"createPathIfMissing"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 71 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 63 | ▶ | method glSuffix() { return '=s' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
glSuffix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 23 | method kind; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 23 | method pathExists($value); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # Create the path; return undef, or the reason it could not be created. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 23 | method createPath($value); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # Whether a path exists depends on the machine, so it is asked of the | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # value a parse settles on, never of a default when the spec is built. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # A path of the wrong kind can neither be used nor created. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 18 | ▶ | method verify($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 18 | ▶ | return undef if !defined $value || (!$mustExist && !$createPathIfMissing); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $value and $mustExist || $createPathIfMissing
$mustExist or $createPathIfMissing
MC/DC66%2/3
defined $value and $mustExist || $createPathIfMissing
defined $value
$mustExist
$createPathIfMissing
Truth table75%3/4
A and B or C
A= defined $valueB= $mustExistC= $createPathIfMissing
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 16 | ▶ | return undef if $self->pathExists($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | ▶ | return sprintf("'%s' is not a %s", $value, $self->kind) if -e $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | ▶ | return sprintf("%s '%s' does not exist", $self->kind, $value) if $mustExist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 11 | ▶ | method prepare($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 11 | ▶ | return undef if !defined $value || !$createPathIfMissing || $self->pathExists($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $value && $createPathIfMissing or $self->pathExists($value)
defined $value && $createPathIfMissing
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)
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 7 | my $reason = $self->createPath($value); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | ▶ | return defined $reason ? sprintf("cannot create %s '%s': %s", $self->kind, $value, $reason) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | ▶ | method constraintNotes() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
constraintNotes: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | ▶ | return ('has to exist') if $mustExist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | return ('created if missing') if $createPathIfMissing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||||||||||||||||