Geocodio.pm

filter: Statementstmt 44.0% 26 / 59 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.1% 7 / 17 Podpod 100% 6 / 6 totaltotal 39.0% 39 / 100 CC 10 SCAR 21.7
CC
10
Cov
34%
geocode
20.0
reverse_geocode
20.0
_format
12.0
CRAP 8.7
« Geocodio/Location.pm ↑ Summary Geocodio/Request.pm »
1 6 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package WebService::Geocodio;
7 6 $WebService::Geocodio::VERSION = '0.05';
8 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 with('WebService::Geocodio::Request');
13  
14 # ABSTRACT: A Perl interface to Geocod.io
15  
16  
17  
18 has 'api_key' => (
19 is => 'ro',
20 0 ▶ isa => sub { confess "$_[0] doesn't look like a valid api key\n" unless $_[0] =~ /[0-9a-f]+/ },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ /[0-9a-f]+/u 0 0 0
21 6 required => 1,
22 );
23  
24  
25 has 'locations' => (
26 is => 'rw',
27 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 6 );
29  
30  
31 has 'fields' => (
32 is => 'rw',
33 predicate => 1,
34 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 6 );
36  
37  
38 0 ▶sub add_location {
Subroutine add_location: not called CC=1 SCAR=6.9
Pod documented
39 0 my $self = shift;
40  
41 0 push @{ $self->locations }, @_;
42 }
43  
44  
45 0 ▶sub show_locations {
Subroutine show_locations: not called CC=1 SCAR=6.9
Pod documented
46 0 my $self = shift;
47  
48 0 return @{ $self->locations };
49 }
50  
51  
52 0 ▶sub clear_locations {
Subroutine clear_locations: not called CC=1 SCAR=6.9
Pod documented
53 0 my $self = shift;
54  
55 0 $self->locations([]);
56 }
57  
58  
59 0 ▶sub add_field {
Subroutine add_field: not called CC=1 SCAR=6.9
Pod documented
60 0 my $self = shift;
61  
62 0 push @{ $self->fields }, grep { /cd|cd113|cd114|cd115|stateleg|timezone|school|census/ } @_;
63 }
64  
65  
66 0 ▶sub geocode {
Subroutine geocode: not called CC=4 SCAR=30.0
Pod documented
67 0 my $self = shift;
68  
69 0 ▶ $self->add_location(@_) if scalar @_;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ 0 0 0
70  
71 0 ▶ return undef if scalar @{$self->locations} < 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->locations;} < 1 0 0 0
72  
73 0 my @r = $self->send_forward( $self->_format('forward') );
74  
75 0 ▶ wantarray ? return @r : return \@r;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
76 }
77  
78  
79 0 ▶sub reverse_geocode {
Subroutine reverse_geocode: not called CC=4 SCAR=30.0
Pod documented
80 0 my $self = shift;
81  
82 0 ▶ $self->add_location(@_) if scalar @_;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ 0 0 0
83  
84 0 ▶ return undef if scalar @{$self->locations} < 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->locations;} < 1 0 0 0
85  
86 0 my @r = $self->send_reverse( $self->_format('reverse') );
87  
88 0 ▶ wantarray ? return @r : return \@r;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
89 }
90  
91 0 ▶sub _format {
Subroutine _format: not called CC=3 SCAR=24.8
92 0 my $self = shift;
93 0 my $direction = shift;
94  
95 0 ▶ my $method = $direction eq 'forward' ? '_forward_formatting'
Branch: 1 branch
BranchTrueFalseTotal
$direction eq 'forward' ? : 0 0 0
96 : '_reverse_formatting';
97  
98 0 ▶ return [ map {; blessed $_ ? $_->$method : $_ } @{$self->locations} ];
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_) ? : 0 0 0
99 }
100  
101 6 1;
102  
103 __END__
« Geocodio/Location.pm ↑ Summary Geocodio/Request.pm »