TropicalCyclone/Resource.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 12 / 12 Conditioncond 80.0% 12 / 15 MC/DCmcdc 70.0% 7 / 10 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 5 totaltotal 87.6% 78 / 89 CC 12 SCAR 13.0
CC
12
Cov
95%
extension_for_type
7.2
__ANON__
4.0
is_valid_file_type
3.0
CRAP 3.7
« TropicalCyclone/Storm.pm ↑ Summary TropicalCyclone.pm »
1 package Weather::NHC::TropicalCyclone::Resource;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Dispatch::Fu qw/dispatch on xdefault xshift_and_deref/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our %TEXT_RESOURCES = map { $_ => 1 } qw/
8 publicAdvisory forecastAdvisory forecastDiscussion windSpeedProbabilities
9 /;
10  
11 4 our %FILE_TYPES = (
12 zipFile => [qw/forecastTrack windWatchesWarnings trackCone initialWindExtent forecastWindRadiiGIS bestTrackGIS potentialStormSurgeFloodingGIS/],
13 kmzFile => [qw/forecastTrack windWatchesWarnings trackCone initialWindExtent forecastWindRadiiGIS bestTrackGIS earliestArrivalTimeTSWindsGIS mostLikelyTimeTSWindsGIS/],
14 zipFile5km => [qw/windSpeedProbabilitiesGIS/],
15 zipFile0p5deg => [qw/windSpeedProbabilitiesGIS/],
16 kmzFile34kt => [qw/windSpeedProbabilitiesGIS/],
17 kmzFile50kt => [qw/windSpeedProbabilitiesGIS/],
18 kmzFile64kt => [qw/windSpeedProbabilitiesGIS/],
19 kmlFile => [qw/stormSurgeWatchWarningGIS peakSurgeKML/],
20 zipFileTidalMask => [qw/potentialStormSurgeFloodingGIS/],
21 );
22  
23 2 ▶sub text_resources { return [ sort keys %TEXT_RESOURCES ] }
Subroutine text_resources: called CC=1 SCAR=0.0
Pod undocumented
24 12 ▶sub file_types { return { map { $_ => [ @{ $FILE_TYPES{$_} } ] } keys %FILE_TYPES } }
Subroutine file_types: called CC=1 SCAR=0.0
Pod undocumented
25  
26 30 ▶sub is_valid_file_type {
Subroutine is_valid_file_type: called CC=3 SCAR=11.0
Pod undocumented
27 30 my ( $class, $resource, $type ) = @_;
28 30 ▶ return 0 if !defined $type || !exists $FILE_TYPES{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and exists $Weather::NHC::TropicalCyclone::Resource::FILE_TYPES{$type} 4 26 30
Condition100%3/3
defined $type and exists $Weather::NHC::TropicalCyclone::Resource::FILE_TYPES{$type}
!ll&&!rl&&r
1326
MC/DC100%2/2
defined $type and exists $Weather::NHC::TropicalCyclone::Resource::FILE_TYPES{$type}
defined $type exists $Weather::NHC::TropicalCyclone::Resource::FILE_TYPES{$type}
Truth table100%3/3
A and B
A= defined $typeB= exists $Weather::NHC::TropicalCyclone::Resource::FILE_TYPES{$type}
ABresult
0X0
100
111
29 26 return scalar grep { $_ eq $resource } @{ $FILE_TYPES{$type} };
30 }
31  
32 13 ▶sub kind {
Subroutine kind: called CC=1 SCAR=0.0
Pod undocumented
33 13 my ( $class, $resource, $type ) = @_;
34  
35 13 ▶ return dispatch {
Subroutine __ANON__: called CC=4 SCAR=13.9
36 13 my ( $resource, $type ) = xshift_and_deref @_;
37 13 ▶ my $candidate = $TEXT_RESOURCES{$resource}
Branch: 2 branches
BranchTrueFalseTotal
$Weather::NHC::TropicalCyclone::Resource::TEXT_RESOURCES{$resource} ? : 10 3 13
defined $type && $class->is_valid_file_type($resource, $type) ? : 1 2 3
Condition100%3/3
defined $type and $class->is_valid_file_type($resource, $type)
!ll&&!rl&&r
111
MC/DC100%2/2
defined $type and $class->is_valid_file_type($resource, $type)
defined $type $class->is_valid_file_type($resource, $type)
Truth table100%3/3
A and B
A= defined $typeB= $class->is_valid_file_type($resource, $type)
ABresult
0X0
100
111
38 ? q{text}
39 : defined $type && $class->is_valid_file_type( $resource, $type )
40 ? q{file}
41 : q{unknown};
42 13 xdefault $candidate, q{unknown};
43 } [ $resource, $type ],
44 10 ▶ on text => sub { return q{text} },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 1 ▶ on file => sub { return q{file} },
Subroutine __ANON__: called CC=1 SCAR=0.0
46 13 ▶ on unknown => sub { return q{unknown} };
Subroutine __ANON__: called CC=1 SCAR=0.0
47 }
48  
49 4 ▶sub extension_for_type {
Subroutine extension_for_type: called CC=7 SCAR=19.7
Pod undocumented
50 4 my ( $class, $type ) = @_;
51 4 ▶ return q{zip} if defined $type && $type =~ /^zipFile/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type =~ /^zipFile/ 1 3 4
Condition66%2/3
defined $type and $type =~ /^zipFile/
!ll&&!rl&&r
031
MC/DC50%1/2
defined $type and $type =~ /^zipFile/
defined $type $type =~ /^zipFile/
Truth table66%2/3
A and B
A= defined $typeB= $type =~ /^zipFile/
ABresult
0X0
100
111
52 3 ▶ return q{kmz} if defined $type && $type =~ /^kmzFile/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type =~ /^kmzFile/ 1 2 3
Condition66%2/3
defined $type and $type =~ /^kmzFile/
!ll&&!rl&&r
021
MC/DC50%1/2
defined $type and $type =~ /^kmzFile/
defined $type $type =~ /^kmzFile/
Truth table66%2/3
A and B
A= defined $typeB= $type =~ /^kmzFile/
ABresult
0X0
100
111
53 2 ▶ return q{kml} if defined $type && $type eq q{kmlFile};
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type eq "kmlFile" 1 1 2
Condition66%2/3
defined $type and $type eq "kmlFile"
!ll&&!rl&&r
011
MC/DC50%1/2
defined $type and $type eq "kmlFile"
defined $type $type eq "kmlFile"
Truth table66%2/3
A and B
A= defined $typeB= $type eq "kmlFile"
ABresult
0X0
100
111
54 1 return undef;
55 }
56  
57 4 1;
58  
59 __END__
« TropicalCyclone/Storm.pm ↑ Summary TropicalCyclone.pm »