Pad/Spec/Arg.pm

filter: Statementstmt 85.1% 46 / 54 Branchbran n/a Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 76.4% 13 / 17 Podpod 8.3% 1 / 12 totaltotal 73.8% 65 / 88 CC 2 SCAR 1.4
CC
2
Cov
86%
typeLabel
2.0
help
1.1
typehint
1.1
CRAP 1.1
« Pad/Type/Dir.pm ↑ Summary Pad/Result/Generator.pm »
1 10 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 10 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 10 ▶use Getopt::Pad::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Getopt::Pad::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 class Getopt::Pad::Spec::Arg :strict(params) {
8 10 ▶ use Getopt::Pad::Util qw(camelize specError isValidName);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 our $VERSION = '0.05';
11  
12 10 field $raw :param;
13  
14 79 ▶ field $short :reader;
Subroutine short: called CC=1 SCAR=0.0
Pod undocumented
15 149 ▶ field $reader :reader;
Subroutine reader: called CC=1 SCAR=0.0
Pod undocumented
16 70 ▶ field $type :reader;
Subroutine type: called CC=1 SCAR=0.0
Pod undocumented
17 1 ▶ field $typeName :reader;
Subroutine typeName: called CC=1 SCAR=0.0
Pod undocumented
18 125 ▶ field $required :reader = 0;
Subroutine required: not called CC=1 SCAR=0.8
Pod undocumented
19 125 ▶ field $multiple :reader = 0;
Subroutine required: called CC=1 SCAR=0.6
Subroutine multiple: not called CC=1 SCAR=0.6
Pod undocumented
Pod undocumented
20 88 ▶ field $help :reader = '';
Subroutine multiple: called CC=1 SCAR=0.6
Subroutine help: not called CC=1 SCAR=0.9
Pod undocumented
Pod undocumented
21 14 ▶ field $typehint :reader;
Subroutine help: called CC=1 SCAR=1.2
Subroutine typehint: not called CC=1 SCAR=1.2
Pod undocumented
Pod undocumented
22  
23 ADJUST {
24 specError("arg: spec must be a hash reference") if ref $raw ne 'HASH';
25  
26 my %spec = $raw->%*;
27 $short = delete $spec{short};
28 specError("arg: missing or invalid 'short' name") if !isValidName($short);
29 $reader = camelize($short);
30 specError("arg '%s': reader '%s' collides with a built-in result method", $short, $reader) if Getopt::Pad::Result->reservesReader($reader);
31  
32 ($type, $typeName) = Getopt::Pad::Type::takeFromSpec(\%spec, 'string', sprintf("arg '%s'", $short));
33 specError("arg '%s': type '%s' cannot be used for a positional arg", $short, $typeName) if !$type->takesValue;
34  
35 $required = delete $spec{required} ? 1 : 0;
36 $multiple = delete $spec{multiple} ? 1 : 0;
37 $help = delete $spec{help} // '';
38 $typehint = delete $spec{typehint};
39  
40 specError("arg '%s': unknown key(s): %s", $short, join(', ', sort keys %spec)) if %spec;
41 specError("arg '%s': typehint must be a non-empty string", $short) if defined $typehint && (ref $typehint || $typehint eq '');
42 }
43  
44 # The tag the help output renders after the help text: the spec's
45 # typehint, or what the type calls itself.
46 14 ▶ method typeLabel() {
Subroutine typeLabel: called CC=2 SCAR=6.9
Pod documented
47 14 ▶ return $typehint // $type->label;
Condition100%3/3
$typehint // $type->label
l!l&&r!l&&!r
662
MC/DC100%2/2
$typehint // $type->label
$typehint $type->label
Truth table100%3/3
A // B
A= $typehintB= $type->label
ABresult
1X1
011
000
48 10 }
49 }
50  
51 10 1;
52  
53 __END__
« Pad/Type/Dir.pm ↑ Summary Pad/Result/Generator.pm »