| 1 | package Kwiki::Weather; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Kwiki::Plugin -Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use mixin 'Kwiki::Installer'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | our $VERSION = '0.05'; | ||||||||||
| 9 | |||||||||||
| 10 | const class_title => 'Weather Report'; | ||||||||||
| 11 | const class_id => 'weather'; | ||||||||||
| 12 | const cgi_class => 'Kwiki::Weather::CGI'; | ||||||||||
| 13 | field 'geo_weather'; | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub register { | ||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 0 | my $registry = shift; | |||||||||
| 17 | 0 | $registry->add( action => 'weather' ); | |||||||||
| 18 | 0 | $registry->add( | |||||||||
| 19 | toolbar => 'weather', | ||||||||||
| 20 | template => 'weather_button.html' | ||||||||||
| 21 | ); | ||||||||||
| 22 | 0 | $registry->add( wafl => weather => 'Kwiki::Weather::Wafl' ); | |||||||||
| 23 | 0 | $registry->add( prerequisite => 'zipcode' ); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub weather { | ||||||||
|
Subroutine
weather: not called CC=2 SCAR=17.9
| |||||||||||
| 27 | 0 | my $zipcode = $self->cgi->zipcode; | |||||||||
| 28 | 0 | ▶ | return $self->render_screen( content_pane => 'weather_error.html' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | unless $zipcode =~ /^\d{5}$/; | ||||||||||
| 30 | 0 | require Geo::Weather; | |||||||||
| 31 | 0 | my $weather = Geo::Weather->new; | |||||||||
| 32 | 0 | $weather->get_weather($zipcode); | |||||||||
| 33 | 0 | $self->geo_weather($weather); | |||||||||
| 34 | 0 | $self->render_screen; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | package Kwiki::Weather::Wafl; | ||||||||||
| 38 | 2 | ▶ | use base 'Spoon::Formatter::WaflPhrase'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub to_html { | ||||||||
|
Subroutine
to_html: not called CC=2 SCAR=17.9
| |||||||||||
| 41 | 0 | my $zipcode = $self->arguments; | |||||||||
| 42 | 0 | ▶ | return $self->wafl_error | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | unless $zipcode =~ /^\d{5}$/; | ||||||||||
| 44 | 0 | require Geo::Weather; | |||||||||
| 45 | 0 | my $weather = Geo::Weather->new; | |||||||||
| 46 | 0 | $weather->get_weather($zipcode); | |||||||||
| 47 | 0 | $self->hub->template->process( 'weather_report.html', weather => $weather, | |||||||||
| 48 | ); | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | package Kwiki::Weather::CGI; | ||||||||||
| 52 | 0 | ▶ | use Kwiki::CGI -base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||||||||||
| 53 | cgi 'zipcode'; | ||||||||||
| 54 | |||||||||||
| 55 | package Kwiki::Weather; | ||||||||||
| 56 | |||||||||||
| 57 | __DATA__ | ||||||||||