OpenWeatherMap/Request/Forecast.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 100% 43 / 43 CC 4 SCAR 3.8
CC
4
Cov
100%
_url_bycode
2.0
_url_bycoord
2.0
_url_byname
2.0
CRAP 1.5
« OpenWeatherMap/Result/Find.pm ↑ Summary OpenWeatherMap/Result/Forecast/Day.pm »
1 package Weather::OpenWeatherMap::Request::Forecast;
2 4 $Weather::OpenWeatherMap::Request::Forecast::VERSION = '0.005001';
3 4 ▶use URI::Escape 'uri_escape_utf8';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Types::Standard -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 extends 'Weather::OpenWeatherMap::Request';
8  
9 has hourly => (
10 lazy => 1,
11 is => 'ro',
12 isa => Bool,
13 3 ▶ builder => sub { 0 },
Subroutine _build_hourly: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
14 4 );
15  
16 has days => (
17 lazy => 1,
18 is => 'ro',
19 isa => Int,
20 3 ▶ builder => sub { 7 },
Subroutine _build_days: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
21 4 );
22  
23  
24 sub _url_bycode {
25 2 ▶ my ($self, $code) = @_;
Subroutine _url_bycode: called CC=2 SCAR=6.9
26 2 ▶ 'http://api.openweathermap.org/data/2.5/forecast/'
Branch: 1 branch
BranchTrueFalseTotal
$self->hourly ? : 1 1 2
27 . ($self->hourly ? '' : 'daily')
28 . '?id=' . uri_escape_utf8($code)
29 . '&units=' . $self->_units
30 . '&cnt=' . $self->days
31 }
32  
33 sub _url_bycoord {
34 2 ▶ my $self = shift;
Subroutine _url_bycoord: called CC=2 SCAR=6.9
35 2 my ($lat, $long) = map {; uri_escape_utf8($_) } @_;
36 2 ▶ 'http://api.openweathermap.org/data/2.5/forecast/'
Branch: 1 branch
BranchTrueFalseTotal
$self->hourly ? : 1 1 2
37 . ($self->hourly ? '' : 'daily')
38 . "?lat=${lat}&lon=${long}"
39 . '&units=' . $self->_units
40 . '&cnt=' . $self->days
41 }
42  
43 sub _url_byname {
44 2 ▶ my ($self, @parts) = @_;
Subroutine _url_byname: called CC=2 SCAR=6.9
45 'http://api.openweathermap.org/data/2.5/forecast/'
46 . ($self->hourly ? '' : 'daily')
47 2 ▶ . '?q=' . join(',', map {; uri_escape_utf8($_) } @parts)
Branch: 1 branch
BranchTrueFalseTotal
$self->hourly ? : 1 1 2
48 . '&units=' . $self->_units
49 . '&cnt=' . $self->days
50 }
51  
52  
53 4 1;
54  
55 =pod
56  
57 =head1 NAME
58  
59 Weather::OpenWeatherMap::Request::Forecast
60  
61 =head1 SYNOPSIS
62  
63 # Usually created by Weather::OpenWeatherMap
64  
65 =head1 DESCRIPTION
66  
67 A L<Weather::OpenWeatherMap::Request> subclass for building a forecast
68 request.
69  
70 =head2 ATTRIBUTES
71  
72 =head3 days
73  
74 The number of days to ask for (up to 16 for daily reports; up to 5 if
75 L</hourly> is true).
76  
77 =head3 hourly
78  
79 Request an hourly (actually 3-hour blocks) forecast.
80  
81 By default, a daily report is requested.
82  
83 =head1 SEE ALSO
84  
85 L<Weather::OpenWeatherMap::Request>
86  
87 L<Weather::OpenWeatherMap::Result>
88  
89 L<Weather::OpenWeatherMap::Result::Forecast>
90  
91 L<Weather::OpenWeatherMap>
92  
93 =head1 AUTHOR
94  
95 Jon Portnoy <avenj@cobaltirc.org>
96  
97 Licensed under the same terms as Perl.
98  
99 =cut
« OpenWeatherMap/Result/Find.pm ↑ Summary OpenWeatherMap/Result/Forecast/Day.pm »