All/Ovi.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 60 CC 5 SCAR 18.9
CC
5
Cov
0%
geocode_local
12.0
_process_response
12.0
reverse_geocode_local
2.0
CRAP 6.6
1 package Geo::Coder::All::Ovi;
2 use Moose;
3 use namespace::autoclean;
4 use Carp;
5 use Geo::Coder::Ovi;
6 use Locale::Codes::Country;
7 use Data::Dumper;
8 with 'Geo::Coder::Role::Geocode';
9  
10 has 'Ovi' =>(
11 is => 'rw',
12 isa => 'Geo::Coder::Ovi',
13 writer => 'set_ovi_geocoder',
14 );
15  
16 sub geocode_local {
17 my ($self,$rh_args) = @_;
18 croak 'Location string required' unless($rh_args->{location});
19 $self->set_ovi_geocoder(Geo::Coder::Ovi->new(
20 appid => $rh_args->{appid},
21 token => $rh_args->{token}
22 ));
23 my $rh_response = $self->Ovi->geocode( location=> $rh_args->{location});
24 print STDERR Dumper($rh_response) if($rh_args->{DEBUG});
25 return $self->_process_response($rh_response);
26 }
27  
28 sub reverse_geocode_local{
29 my ($self,$rh_args) = @_;
30 return 'Reverse Geocode is not available for Ovi';
31 }
32  
33 sub _process_response{
34 my ($self,$rh_response) = @_;
35 return undef unless($rh_response);
36 my $rh_data;
37 $rh_data->{geocoder} = 'Ovi';
38 $rh_data->{address} = $rh_response->{properties}{title};
39 $rh_data->{country} = $rh_response->{properties}{addrCountryName};
40 $rh_data->{country_code} = uc(country2code($rh_response->{properties}{addrCountryName})) if($rh_response->{properties}{addrCountryName});
41 $rh_data->{country_code_alpha_3} = $rh_response->{properties}{addrCountryCode};
42 $rh_data->{coordinates}{lat} = $rh_response->{properties}{geoLatitude};
43 $rh_data->{coordinates}{lon} = $rh_response->{properties}{geoLongitude};
44 return $rh_data;
45 }
46 __PACKAGE__->meta->make_immutable();
47 1;