File Coverage

blib/lib/WWW/IRail/API/Client/LWP.pm
Criterion Covered Total %
statement 14 25 56.0
branch 0 2 0.0
condition 0 3 0.0
subroutine 6 8 75.0
pod 0 2 0.0
total 20 40 50.0


line stmt bran cond sub pod time code
1             package WWW::IRail::API::Client::LWP;
2             BEGIN {
3 1     1   2694 $WWW::IRail::API::Client::LWP::AUTHORITY = 'cpan:ESSELENS';
4             }
5             BEGIN {
6 1     1   22 $WWW::IRail::API::Client::LWP::VERSION = '0.003';
7             }
8 1     1   8 use parent 'Exporter';
  1         3  
  1         11  
9 1     1   58 use strict;
  1         11  
  1         45  
10 1     1   6 use Carp qw/croak/;
  1         2  
  1         64  
11 1     1   5560 use LWP::UserAgent;
  1         36381  
  1         207  
12              
13             our $VERSION;
14              
15             sub new {
16 0     0 0   my ($proto) = @_;
17 0   0       my $class = ref $proto || $proto;
18 0           my %attr = ( _client => new LWP::UserAgent);
19            
20 0           $attr{_client}->timeout(10);
21 0           $attr{_client}->agent("WWW::IRail::API::Client::LWP/$VERSION ");
22            
23 0           return bless {%attr}, $class;
24             }
25              
26             sub process {
27 0     0 0   my $self = shift;
28 0           my $http_req = shift;
29              
30 0           my $response = $self->{_client}->request($http_req);
31 0 0         $response->is_success or croak 'unable to process request: '.$response->status_line;
32              
33 0           return $response;
34             }
35              
36             42;
37              
38             __END__