blib/lib/Weather/Underground/StationHistory.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 49 / 49 CC 3 SCAR 4.4
CC
3
Cov
100%
strip_garbage_from_station_history
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
↑ Summary
1 package Weather::Underground::StationHistory;
2  
3 3 ▶use 5.006000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use version; our $VERSION = qv('v1.0.5');
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Regexp::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 our @EXPORT_OK =
16 qw{
17 &generate_single_day_station_history_url
18 &strip_garbage_from_station_history
19 };
20 3 our %EXPORT_TAGS = (
21 all => [@EXPORT_OK],
22 );
23  
24 3 my $EMPTY_STRING = q<>;
25  
26 2 ▶sub generate_single_day_station_history_url {
Subroutine generate_single_day_station_history_url: called CC=1 SCAR=0.0
Pod documented
27 2 my ($station_id, $year, $month_number, $day_of_month) = @_;
28  
29 return
30 2 sprintf
31 'http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=%s&year=%d&month=%d&day=%d&graphspan=day&format=1',
32 $station_id,
33 $year,
34 $month_number,
35 $day_of_month,
36 ;
37 } # end generate_single_day_station_history_url()
38  
39 2 ▶sub strip_garbage_from_station_history {
Subroutine strip_garbage_from_station_history: called CC=3 SCAR=11.0
Pod documented
40 2 my $original_contents = shift;
41 2 my @original_lines = split m/ [\r\n]+ /xms, $original_contents;
42 2 my $resulting_contents = $EMPTY_STRING;
43  
44 2 foreach my $original_line (@original_lines) {
45 20 $original_line =~ s/ $RE{balanced}{-parens => '<>'} //xmsg;
46 20 $original_line =~ s/ $RE{ws}{crop} //xmsg;
47  
48 20 ▶ if ($original_line ne $EMPTY_STRING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($original_line ne $EMPTY_STRING) 9 11 20
49 9 $resulting_contents .= "$original_line\n";
50 } # end if
51 } # end foreach
52  
53 2 return $resulting_contents;
54 } # end strip_garbage_from_station_history()
55  
56  
57 3 1; # Magic true value required at end of module
58 __END__
↑ Summary