lib/Test/File/ShareDir/Utils.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 85.7% 42 / 49 CC 7 SCAR 15.8
CC
7
Cov
88%
extract_dashes
7.6
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
↑ Summary lib/Test/File/ShareDir.pm »
1 12 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Test::File::ShareDir::Utils;
6  
7 12 our $VERSION = '1.001002';
8  
9 12 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
10  
11 # ABSTRACT: Simple utilities for File::ShareDir testing
12  
13 12 ▶use Exporter 5.57 qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 12 our @EXPORT_OK = qw( extract_dashes );
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41 5 ▶sub extract_dashes {
Subroutine extract_dashes: called CC=7 SCAR=20.2
Pod documented
42 5 my ( $undashed_to, $source ) = @_;
43 5 ▶ if ( not ref $source or 'HASH' ne ref $source ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $source or "HASH" ne ref $source) 0 5 5
Condition33%1/3
not ref $source or "HASH" ne ref $source
l!l&&r!l&&!r
005
MC/DC0%0/2
not ref $source or "HASH" ne ref $source
not ref $source "HASH" ne ref $source
Truth table33%1/3
not(A) or B
A= not ref $sourceB= "HASH" ne ref $source
ABresult
1X1
011
000
44 0 return croak(q[Must pass a hashref]);
45 }
46 5 my %input_config = %{$source};
47 5 my $params = {};
48 5 for my $key ( keys %input_config ) {
49 7 ▶ next unless $key =~ /\A-(.*)\z/msx;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /\A-(.*)\z/msx 5 2 7
50 2 $params->{$1} = delete $input_config{$key};
51 }
52 5 ▶ $params->{$undashed_to} = {} if not exists $params->{$undashed_to};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params->{$undashed_to} 5 0 5
53 5 for my $key ( keys %input_config ) {
54 5 $params->{$undashed_to}->{$key} = $input_config{$key};
55 }
56 5 return $params;
57 }
58  
59 12 1;
60  
61 __END__
↑ Summary lib/Test/File/ShareDir.pm »