blib/lib/WWW/Shorten/MahewinSexyUrl.pm

filter: Statementstmt 53.5% 15 / 28 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 45.6% 21 / 46 CC 6 SCAR 23.9
CC
6
Cov
39%
makealongerlink
20.0
makeashorterlink
12.0
BEGIN
1.0
CRAP 10.9
↑ Summary
1 package WWW::Shorten::MahewinSexyUrl;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw( WWW::Shorten::generic Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 our @EXPORT = qw( makeashorterlink makealongerlink );
8 2 our $VERSION = '0.2';
9  
10 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub makeashorterlink ($) {
Subroutine makeashorterlink: not called CC=3 SCAR=24.8
Pod documented
13 0 ▶ my $url = shift or croak 'No URL passed to makeashorterlink';
Branch: 1 branch
BranchTrueFalseTotal
my $url = shift() or croak("No URL passed to makeashorterlink") 0 0 0
14 0 my $ua = __PACKAGE__->ua();
15 0 my $service_url = 'http://msud.pl';
16  
17 0 my $resp = $ua->post($service_url, [
18 sexy_url => $url,
19 source => "PerlAPI-$VERSION",
20 ]);
21  
22 0 ▶ return undef unless $resp->header('X-ShortUrl');
Branch: 1 branch
BranchTrueFalseTotal
unless $resp->header("X-ShortUrl") 0 0 0
23 0 return $service_url . '/' . $resp->header('X-ShortUrl');
24 }
25  
26 0 ▶sub makealongerlink ($) {
Subroutine makealongerlink: not called CC=4 SCAR=30.0
Pod documented
27 0 ▶ my $msud = shift or croak 'No msud key / url passed to makealongerlink';
Branch: 1 branch
BranchTrueFalseTotal
my $msud = shift() or croak("No msud key / url passed to makealongerlink") 0 0 0
28 0 my $ua = __PACKAGE__->ua();
29  
30 0 ▶ $msud = "http://msud.pl/$msud" unless $msud =~ m/^http:\/\//i;
Branch: 1 branch
BranchTrueFalseTotal
unless $msud =~ m[^http://]i 0 0 0
31  
32 0 my $resp = $ua->get($msud);
33  
34 0 ▶ return undef unless $resp->is_redirect;
Branch: 1 branch
BranchTrueFalseTotal
unless $resp->is_redirect 0 0 0
35 0 my $url = $resp->header('Location');
36  
37 0 return $url;
38 }
39  
40 2 1;
41  
42 __END__
↑ Summary