Pad/Spec/Config.pm

filter: Statementstmt 100% 31 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 42 / 42 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Pad/ExitRequest.pm ↑ Summary
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::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Getopt::Pad::Config::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 class Getopt::Pad::Spec::Config :strict(params) {
8 10 ▶ use Getopt::Pad::Util qw(specError);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 our $VERSION = '0.04';
11  
12 10 field $raw :param;
13  
14 10 field $format;
15 65 ▶ field $formatName :reader;
Subroutine formatName: called CC=1 SCAR=0.0
Pod documented
16 10 field $paths;
17 67 ▶ field $defaultPath :reader;
Subroutine defaultPath: called CC=1 SCAR=0.0
Pod documented
18 field $autoload = 1;
19 56 ▶ field $io :reader;
Subroutine io: called CC=1 SCAR=0.0
Pod documented
20  
21 ADJUST {
22 specError("config: expects a hash reference") if ref $raw ne 'HASH';
23 my %spec = $raw->%*;
24  
25 $formatName = delete $spec{format};
26 specError("config: missing 'format'") if !defined $formatName;
27 $format = Getopt::Pad::Config::Format::registry()->resolve($formatName)->new;
28  
29 $paths = delete $spec{paths} // [];
30 specError("config: 'paths' must be an array reference") if ref $paths ne 'ARRAY';
31  
32 $defaultPath = delete $spec{defaultPath};
33 $autoload = (delete $spec{autoload} ? 1 : 0) if exists $spec{autoload};
34  
35 specError("config: unknown key(s): %s", join(', ', sort keys %spec)) if %spec;
36  
37 $io = Getopt::Pad::Config->new(
38 format => $format,
39 formatName => $formatName,
40 paths => $paths,
41 defaultPath => $defaultPath,
42 autoload => $autoload,
43 );
44 }
45 10 }
46  
47 10 1;
48  
49 __END__
« Pad/ExitRequest.pm ↑ Summary