Bug/Forecast.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 95.2% 40 / 42 CC 3 SCAR 5.7
CC
3
Cov
94%
from_xml
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« Bug/Weather.pm ↑ Summary Bug/CompactWeather.pm »
1 package Weather::Bug::Forecast;
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::Temperature;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 our $VERSION = '0.25';
10  
11 12 has 'title' => ( is => 'ro', isa => 'Str', init_arg => '-title' );
12 12 has 'short_title' => ( is => 'ro', isa => 'Str', init_arg => '-short' );
13 12 has 'imageurl' => ( is => 'ro', isa => 'Str', init_arg => '-image' );
14 12 has 'description' => ( is => 'ro', isa => 'Str', init_arg => '-desc' );
15 12 has 'prediction' => ( is => 'ro', isa => 'Str', init_arg => '-pred' );
16 12 has 'high' => ( is => 'ro', isa => 'Weather::Bug::Temperature', init_arg => '-high' );
17 12 has 'low' => ( is => 'ro', isa => 'Weather::Bug::Temperature', init_arg => '-low' );
18  
19 sub from_xml
20 39 ▶{
Subroutine from_xml: called CC=3 SCAR=11.2
Pod documented
21 39 my $class = shift;
22 39 my $node = shift;
23  
24 39 my ($hi) = $node->findnodes( 'aws:high' );
25 39 my ($lo) = $node->findnodes( 'aws:low' );
26  
27 39 ▶ die "No 'aws:high' node found.\n" unless defined $hi;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hi 0 39 39
28 39 ▶ die "No 'aws:low' node found.\n" unless defined $lo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lo 0 39 39
29  
30 39 return Weather::Bug::Forecast->new(
31 -title => $node->findvalue( 'aws:title' ),
32 -short => $node->findvalue( 'aws:short-title' ),
33 -image => $node->findvalue( 'aws:image' ),
34 -desc => $node->findvalue( 'aws:description' ),
35 -pred => $node->findvalue( 'aws:prediction' ),
36 -high => Weather::Bug::Temperature->from_xml( $hi ),
37 -low => Weather::Bug::Temperature->from_xml( $lo ),
38 );
39 }
40  
41 12 1; # Magic true value required at end of module
42 __END__
« Bug/Weather.pm ↑ Summary Bug/CompactWeather.pm »