Bug/CompactWeather.pm

filter: Statementstmt 100% 38 / 38 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 98.0% 50 / 51 CC 3 SCAR 4.7
CC
3
Cov
98%
from_xml
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« Bug/Forecast.pm ↑ Summary Bug/SevenDayForecast.pm »
1 package Weather::Bug::CompactWeather;
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 12 ▶use Weather::Bug::Station;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use Weather::Bug::Temperature;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use Weather::Bug::Quantity;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 12 our $VERSION = '0.25';
12  
13 12 has 'station' => ( is => 'ro', isa => 'Weather::Bug::Station', init_arg => '-station' );
14 12 has 'temp' => ( is => 'ro', isa => 'Weather::Bug::Temperature', init_arg => '-temp' );
15 12 has 'rain_today' => ( is => 'ro', isa => 'Weather::Bug::Quantity', init_arg => '-rain_today' );
16 12 has 'wind_speed' => ( is => 'ro', isa => 'Weather::Bug::Quantity', init_arg => '-wind_speed' );
17 12 has 'wind_dir' => ( is => 'ro', isa => 'Str', init_arg => '-wind_dir' );
18 12 has 'gust_speed' => ( is => 'ro', isa => 'Weather::Bug::Quantity', init_arg => '-gust_speed' );
19 12 has 'gust_dir' => ( is => 'ro', isa => 'Str', init_arg => '-gust_dir' );
20  
21 sub from_xml
22 2 ▶{
Subroutine from_xml: called CC=3 SCAR=11.0
Pod documented
23 2 my $class = shift;
24 2 my $w = shift;
25 2 my $creator = shift;
26  
27 2 ▶ if( $creator->isa( 'Weather::Bug' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($creator->isa("Weather::Bug")) 1 1 2
28 1 my ($station) = $w->findnodes( 'aws:station' );
29 1 $creator = Weather::Bug::Station->from_compact_xml(
30 $creator, $station
31 );
32 }
33 2 ▶ die "Unable to create a Station localizing the CompactWeather.\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $creator->isa("Weather::Bug::Station") 0 2 2
34 unless $creator->isa( 'Weather::Bug::Station' );
35  
36 2 return Weather::Bug::CompactWeather->new(
37 -station => $creator,
38 -temp => Weather::Bug::Temperature->from_xml( ($w->findnodes( 'aws:temp' ))[0] ),
39 -rain_today => Weather::Bug::Quantity->from_xml( ($w->findnodes( 'aws:rain-today' ))[0] ),
40 -wind_speed => Weather::Bug::Quantity->from_xml( ($w->findnodes( 'aws:wind-speed' ))[0] ),
41 -wind_dir => $w->findvalue( 'aws:wind-direction' ),
42 -gust_speed => Weather::Bug::Quantity->from_xml( ($w->findnodes( 'aws:gust-speed' ))[0] ),
43 -gust_dir => $w->findvalue( 'aws:gust-direction' ),
44 );
45 }
46  
47 12 1; # Magic true value required at end of module
48 __END__
« Bug/Forecast.pm ↑ Summary Bug/SevenDayForecast.pm »