File Coverage

blib/lib/WWW/hmaip.pm
Criterion Covered Total %
statement 20 21 95.2
branch 1 2 50.0
condition 0 4 0.0
subroutine 7 7 100.0
pod 1 1 100.0
total 29 35 82.8


line stmt bran cond sub pod time code
1 1     1   123398 use strict;
  1         3  
  1         38  
2 1     1   5 use warnings;
  1         1  
  1         55  
3             package WWW::hmaip;
4             $WWW::hmaip::VERSION = '0.02';
5 1     1   1022 use HTTP::Tiny;
  1         74811  
  1         39  
6 1     1   21 use 5.008;
  1         3  
  1         49  
7              
8             # ABSTRACT: Returns your ip address using L
9              
10              
11             BEGIN {
12 1     1   5 require Exporter;
13 1     1   5 use base 'Exporter';
  1         2  
  1         85  
14 1         3 our @EXPORT = 'get_ip';
15 1         95 our @EXPORT_OK = ();
16             }
17              
18              
19             sub get_ip {
20 1     1 1 20 my $response = HTTP::Tiny->new->get('http://geoip.hidemyass.com/ip/');
21 1 50       178065 return $response->{content} if $response->{success};
22 0   0       die join(' ', 'Error fetching ip: ',
      0        
23             ($response->{status} or ''),
24             ($response->{reason} or ''));
25             }
26              
27              
28             1;
29              
30             __END__