blib/lib/WWW/Shorten/Google.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 82.2% 37 / 45 CC 6 SCAR 11.6
CC
6
Cov
78%
makeashorterlink
4.9
makealongerlink
4.1
BEGIN
1.0
CRAP 3.2
↑ Summary
1 package WWW::Shorten::Google;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use base qw( WWW::Shorten::generic Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 our @EXPORT = qw( makeashorterlink makealongerlink );
6  
7 3 our $VERSION = '0.01';
8  
9 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub makeashorterlink {
Subroutine makeashorterlink: called CC=3 SCAR=16.0
Pod documented
12 1 ▶ my $uri = shift or croak 'No URL passed to makeashorterlink';
Branch: 1 branch
BranchTrueFalseTotal
my $uri = shift() or croak("No URL passed to makeashorterlink") 1 0 1
13 1 my $ua = __PACKAGE__->ua();
14 1 my $res = $ua->post(
15 'http://goo.gl/action/shorten',
16 {
17 url => $uri,
18 authed => 1,
19 }
20 );
21  
22 0 ▶ return unless $res->is_redirect;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_redirect 0 0 0
23 0 my($tiny_url) = $res->header('location') =~ /url=(.+)/;
24 0 return $tiny_url;
25 }
26  
27 2 ▶sub makealongerlink {
Subroutine makealongerlink: called CC=4 SCAR=14.0
Pod documented
28 2 ▶ my $uri = shift or croak 'No URL passed to makealongerlink';
Branch: 1 branch
BranchTrueFalseTotal
my $uri = shift() or croak("No URL passed to makealongerlink") 2 0 2
29  
30 2 my $ua = __PACKAGE__->ua();
31  
32 2 ▶ $uri = "http://goo.gl/$uri" unless $uri =~ m!^http://!i;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri =~ m[^http://]i 1 1 2
33  
34 2 my $res = $ua->get($uri);
35 2 ▶ return unless $res->is_redirect;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_redirect 0 2 2
36 2 return $res->header('Location');
37 }
38  
39 3 1;
40 __END__
↑ Summary