| 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
Condition100%3/3
defined $type and exists $Weather::NHC::TropicalCyclone::Resource::FILE_TYPES{$type}
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}
| |||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $type and $class->is_valid_file_type($resource, $type)
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)
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
defined $type and $type =~ /^zipFile/
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/
| |||||||||||||||||||||||||||||||||
| 52 | 3 | ▶ | return q{kmz} if defined $type && $type =~ /^kmzFile/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $type and $type =~ /^kmzFile/
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/
| |||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | return q{kml} if defined $type && $type eq q{kmlFile}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $type and $type eq "kmlFile"
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"
| |||||||||||||||||||||||||||||||||
| 54 | 1 | return undef; | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | 4 | 1; | |||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||||||