| 1 | package Astro::App::Satpass2::Geocode; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use 5.008; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | ▶ | use parent qw{ Astro::App::Satpass2::Copier }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | ▶ | use Astro::App::Satpass2::Utils qw{ | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | instance | ||||||||||||||||||||
| 12 | load_package | ||||||||||||||||||||
| 13 | @CARP_NOT | ||||||||||||||||||||
| 14 | 2 | }; | |||||||||||||||||||
| 15 | 2 | ▶ | use Astro::App::Satpass2::Warner; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 2 | our $VERSION = '0.059'; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 20 | 0 | my ( $class, %args ) = @_; | |||||||||||||||||||
| 21 | 0 | ▶ | $class = ref $class || $class; | ||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | my $self = {}; | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | bless $self, $class; | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | $self->warner( delete $args{warner} ); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | ▶ | __PACKAGE__ eq $class | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | and $self->wail( | ||||||||||||||||||||
| 31 | "Class $class may not be instantiated directly", | ||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | my $geocoder_class = $class->GEOCODER_CLASS(); | |||||||||||||||||||
| 35 | 0 | ▶ | load_package( $geocoder_class ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | or $self->wail( | ||||||||||||||||||||
| 37 | "Unable to load $geocoder_class", | ||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | $self->geocoder( delete $args{geocoder} ); | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | $self->init( %args ); | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | return $self; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 2 | ▶ | sub attribute_names { | ||||||||||||||||||
|
Subroutine
attribute_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 48 | 2 | my ( $self ) = @_; | |||||||||||||||||||
| 49 | 2 | return ( qw{ geocoder }, $self->SUPER::attribute_names() ); | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | ▶ | sub geocode { | ||||||||||||||||||
|
Subroutine
geocode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 53 | 0 | my ( $self ) = @_; | |||||||||||||||||||
| 54 | 0 | $self->wail( | |||||||||||||||||||
| 55 | 0 | "The @{[ ref $self ]} class does not support geocoding. Use a subclass" | |||||||||||||||||||
| 56 | ); | ||||||||||||||||||||
| 57 | 0 | return; # wail() does not return, but Perl::Critic does not | |||||||||||||||||||
| 58 | # know this. | ||||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub geocoder { | ||||||||||||||||||
|
Subroutine
geocoder: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 62 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | ▶ | if ( @args ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | 0 | my $geocoder = shift @args; | |||||||||||||||||||
| 66 | 0 | my $geocoder_class = $self->GEOCODER_CLASS(); | |||||||||||||||||||
| 67 | 0 | ▶ | defined $geocoder | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | or $geocoder = $geocoder_class->new(); | ||||||||||||||||||||
| 69 | 0 | ▶ | ref $geocoder | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | or $geocoder = $geocoder->new(); | ||||||||||||||||||||
| 71 | 0 | ▶ | instance( $geocoder, $geocoder_class ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | or $self->wail( | ||||||||||||||||||||
| 73 | "Argument 'geocoder' must be an instance of $geocoder_class" | ||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||
| 75 | 0 | $self->{geocoder} = $geocoder; | |||||||||||||||||||
| 76 | 0 | return $self; | |||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||
| 78 | 0 | return $self->{geocoder}; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | ▶ | sub __geocode_failure { | ||||||||||||||||||
|
Subroutine
__geocode_failure: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 83 | 0 | my ( $self ) = @_; | |||||||||||||||||||
| 84 | 0 | my $geocoder = $self->geocoder(); | |||||||||||||||||||
| 85 | 0 | ▶ | my $resp = $geocoder->response() | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | or $self->wail( 'No HTTP response found' ); | ||||||||||||||||||||
| 87 | 0 | ▶ | $resp->is_success() | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | and $self->wail( 'No match found for location' ); | ||||||||||||||||||||
| 89 | 0 | $self->wail( $resp->status_line() ); | |||||||||||||||||||
| 90 | 0 | return; # wail() does not return, but Perl::Critic does not know | |||||||||||||||||||
| 91 | # this. | ||||||||||||||||||||
| 92 | } | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 2 | __PACKAGE__->create_attribute_methods(); | |||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 2 | 1; | |||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | __END__ | ||||||||||||||||||||