Bug/Location.pm

filter: Statementstmt 77.5% 38 / 49 Branchbran 5.5% 1 / 18 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 88.8% 8 / 9 Podpod 100% 5 / 5 totaltotal 44.4% 52 / 117 CC 18 SCAR 53.0
CC
18
Cov
43%
is_equivalent
306.0
from_obs_xml
2.0
BEGIN
1.0
CRAP 200.5
↑ Summary Bug/Station.pm »
1 package Weather::Bug::Location;
2  
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 our $VERSION = '0.25';
9  
10 12 has 'city' => ( is => 'ro', isa => 'Str', init_arg => '-city' );
11 12 has 'state' => ( is => 'ro', isa => 'Str', init_arg => '-state' );
12 12 has 'zipcode' => ( is => 'ro', isa => 'Str', init_arg => '-zip' );
13 12 has 'latitude' => ( is => 'ro', init_arg => '-lat', predicate => 'has_latitude' );
14 12 has 'longitude' => ( is => 'ro', init_arg => '-long', predicate => 'has_longitude' );
15 12 has 'distance' => ( is => 'ro', init_arg => '-dist', predicate => 'has_distance' );
16 12 has 'zone' => ( is => 'ro', init_arg => '-zone', predicate => 'has_zone' );
17  
18 sub from_station_xml
19 100 ▶{
Subroutine from_station_xml: called CC=1 SCAR=0.0
Pod documented
20 100 my $class = shift;
21 100 my $node = shift;
22  
23 100 return Weather::Bug::Location->new(
24 -city => $node->findvalue( '@city' ),
25 -state => $node->findvalue( '@state' ),
26 -zip => $node->findvalue( '@zipcode' ),
27 -lat => $node->findvalue( '@latitude' ),
28 -long => $node->findvalue( '@longitude' ),
29 -dist => $node->findvalue( '@distance' ),
30 );
31 }
32  
33 sub from_compact_station_xml
34 1 ▶{
Subroutine from_compact_station_xml: called CC=1 SCAR=0.0
Pod documented
35 1 my $class = shift;
36 1 my $node = shift;
37  
38 1 my $state = $node->findvalue( '@state' );
39 1 $state =~ s/^\s+//;
40 1 $state =~ s/\s+$//;
41 1 return Weather::Bug::Location->new(
42 -city => $node->findvalue( '@city' ),
43 -state => $state,
44 -zip => $node->findvalue( '@zipcode' ),
45 );
46 }
47  
48 sub from_obs_xml
49 1 ▶{
Subroutine from_obs_xml: called CC=2 SCAR=7.0
Pod documented
50 1 my $class = shift;
51 1 my $node = shift;
52  
53 1 ▶ die "City/State not formatted as expected.\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $node->findvalue(".") =~ /^(.*?),\s+(\w\w)$/ 0 1 1
54 unless $node->findvalue( '.' ) =~ /^(.*?),\s+(\w\w)$/;
55 1 my ($city,$state) = ($1,$2);
56  
57 1 return Weather::Bug::Location->new(
58 -city => $city,
59 -state => $state,
60 -zip => $node->findvalue( '@zip' ),
61 );
62 }
63  
64 #
65 # Extract the station information from an aws:location node
66 #
67 # $locnode - the aws:location XML node
68 #
69 # Return a new Weather::Bug::Station object
70 sub from_forecast
71 3 ▶{
Subroutine from_forecast: called CC=1 SCAR=0.0
Pod documented
72 3 my $class = shift;
73 3 my $node = shift;
74  
75 3 return Weather::Bug::Location->new(
76 -city => $node->findvalue( 'aws:city' ),
77 -state => $node->findvalue( 'aws:state' ),
78 -zip => $node->findvalue( 'aws:zip' ),
79 -zone => $node->findvalue( 'aws:zone' ),
80 );
81 }
82  
83 sub is_equivalent
84 0 ▶{
Subroutine is_equivalent: not called CC=17 SCAR=57.2
Pod documented
85 0 my $self = shift;
86 0 my $other = shift;
87  
88 0 ▶ return unless $other->isa( __PACKAGE__ );
Branch: 1 branch
BranchTrueFalseTotal
unless $other->isa(__PACKAGE__) 0 0 0
89 # Compare required fields
90 0 ▶ return unless $self->city() eq $other->city();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->city eq $other->city 0 0 0
91 0 ▶ return unless $self->state() eq $other->state();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state eq $other->state 0 0 0
92 0 ▶ return unless $self->zipcode() eq $other->zipcode();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->zipcode eq $other->zipcode 0 0 0
93  
94 # optional fields match if one is missing.
95 0 ▶ return unless !$self->has_latitude() or !$other->has_latitude()
Branch: 1 branch
BranchTrueFalseTotal
unless not $self->has_latitude && $other->has_latitude or $self->latitude == $other->latitude 0 0 0
Condition0%0/6
not $self->has_latitude && $other->has_latitude or $self->latitude == $other->latitude
l!l&&r!l&&!r
000
$self->has_latitude && $other->has_latitude
!ll&&!rl&&r
000
MC/DC0%0/3
not $self->has_latitude && $other->has_latitude or $self->latitude == $other->latitude
$self->has_latitude $other->has_latitude $self->latitude == $other->latitude
Truth table0%0/4
not(A && B) or C
A= $self->has_latitudeB= $other->has_latitudeC= $self->latitude == $other->latitude
ABCresult
0XX1
10X1
1111
1100
96 or $self->latitude() == $other->latitude();
97 0 ▶ return unless !$self->has_longitude() or !$other->has_longitude()
Branch: 1 branch
BranchTrueFalseTotal
unless not $self->has_longitude && $other->has_longitude or $self->longitude == $other->longitude 0 0 0
Condition0%0/6
not $self->has_longitude && $other->has_longitude or $self->longitude == $other->longitude
l!l&&r!l&&!r
000
$self->has_longitude && $other->has_longitude
!ll&&!rl&&r
000
MC/DC0%0/3
not $self->has_longitude && $other->has_longitude or $self->longitude == $other->longitude
$self->has_longitude $other->has_longitude $self->longitude == $other->longitude
Truth table0%0/4
not(A && B) or C
A= $self->has_longitudeB= $other->has_longitudeC= $self->longitude == $other->longitude
ABCresult
0XX1
10X1
1111
1100
98 or $self->longitude() == $other->longitude();
99 0 ▶ return unless !$self->has_distance() or !$other->has_distance()
Branch: 1 branch
BranchTrueFalseTotal
unless not $self->has_distance && $other->has_distance or $self->distance == $other->distance 0 0 0
Condition0%0/6
not $self->has_distance && $other->has_distance or $self->distance == $other->distance
l!l&&r!l&&!r
000
$self->has_distance && $other->has_distance
!ll&&!rl&&r
000
MC/DC0%0/3
not $self->has_distance && $other->has_distance or $self->distance == $other->distance
$self->has_distance $other->has_distance $self->distance == $other->distance
Truth table0%0/4
not(A && B) or C
A= $self->has_distanceB= $other->has_distanceC= $self->distance == $other->distance
ABCresult
0XX1
10X1
1111
1100
100 or $self->distance() == $other->distance();
101 0 ▶ return unless !$self->has_zone() or !$other->has_zone()
Branch: 1 branch
BranchTrueFalseTotal
unless not $self->has_zone && $other->has_zone or $self->zone eq $other->zone 0 0 0
Condition0%0/6
not $self->has_zone && $other->has_zone or $self->zone eq $other->zone
l!l&&r!l&&!r
000
$self->has_zone && $other->has_zone
!ll&&!rl&&r
000
MC/DC0%0/3
not $self->has_zone && $other->has_zone or $self->zone eq $other->zone
$self->has_zone $other->has_zone $self->zone eq $other->zone
Truth table0%0/4
not(A && B) or C
A= $self->has_zoneB= $other->has_zoneC= $self->zone eq $other->zone
ABCresult
0XX1
10X1
1111
1100
102 or $self->zone() eq $other->zone();
103  
104 0 return 1;
105 }
106  
107 12 1; # Magic true value required at end of module
108 __END__
↑ Summary Bug/Station.pm »