Shorten/UserAgent.pm

filter: Statementstmt 60.0% 12 / 20 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 54.8% 17 / 31 CC 3 SCAR 13.5
CC
3
Cov
50%
get
6.0
post
6.0
BEGIN
1.0
CRAP 3.9
« Shorten/TinyURL.pm ↑ Summary Shorten/generic.pm »
1 package WWW::Shorten::UserAgent;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use base 'LWP::UserAgent';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 our $VERSION = '3.093';
9 7 $VERSION = eval $VERSION;
10  
11 sub get {
12 0 ▶ my $self = shift;
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
13 0 my $resp = $self->SUPER::get(@_);
14  
15 0 ▶ die $resp->status_line if $resp->is_error;
Branch: 1 branch
BranchTrueFalseTotal
if $resp->is_error 0 0 0
16  
17 0 return $resp;
18 }
19  
20 sub post {
21 0 ▶ my $self = shift;
Subroutine post: not called CC=2 SCAR=17.9
Pod documented
22 0 my $resp = $self->SUPER::post(@_);
23  
24 0 ▶ die $resp->status_line if $resp->is_error;
Branch: 1 branch
BranchTrueFalseTotal
if $resp->is_error 0 0 0
25  
26 0 return $resp;
27 }
28  
29 7 1;
30  
31 =head1 NAME
32  
33 WWW::Shorten::UserAgent - LWP::UserAgent subclass for WWW::Shorten modules.
34  
35 =head1 SYNOPSIS
36  
37 use strict;
38 use warnings;
39 use WWW::Shorten::UserAgent;
40 use Try::Tiny qw(try catch);
41  
42 my $ua = WWW::Shorten::UserAgent->new;
43  
44 my $resp = try {
45 $ua->get($url);
46 }
47 catch {
48 warn "Uh oh: $_";
49 return undef;
50 };
51  
52 =head1 DESCRIPTION
53  
54 Subclass of LWP::UserAgent which works the same way as the superclass
55 except that it throws an exception if the C<get> or C<post> method returns
56 an error.
57  
58 See L<LWP::UserAgent> for the full documentation.
59  
60 =head1 METHODS
61  
62 =head2 get
63  
64 Makes an HTTP GET request and throws an exception on error.
65  
66 =head2 post
67  
68 Makes an HTTP POST request and throws an exception on error.
69  
70 =head1 AUTHOR
71  
72 Dave Cross <dave@mag-sol.com>
73  
74 =head1 LICENSE AND COPYRIGHT
75  
76 Copyright (c) Magnum Solutions Ltd., 2012. All rights reserved.
77  
78 This module is free software. You can redistribute it and/or
79 modify it under the terms of the Artistic License 2.0.
80  
81 This program is distributed in the hope that it will be useful,
82 but without any warranty; without even the implied warranty of
83 merchantability or fitness for a particular purpose.
84  
85 =head1 SEE ALSO
86  
87 L<WWW::Shorten>
88  
89 =cut
« Shorten/TinyURL.pm ↑ Summary Shorten/generic.pm »