blib/lib/WWW/Shorten/VGd.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 42.6% 26 / 61 CC 9 SCAR 30.1
CC
9
Cov
37%
makeashorterlink
30.0
makealongerlink
30.0
BEGIN
1.0
CRAP 20.3
↑ Summary
1 package WWW::Shorten::VGd;
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  
9 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use HTML::Entities qw(decode_entities);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $VERSION = '0.005';
13 2 $VERSION = eval $VERSION;
14  
15 0 ▶sub makeashorterlink {
Subroutine makeashorterlink: not called CC=5 SCAR=34.0
Pod documented
16 0 ▶ my $url = shift or Carp::croak('No URL passed to makeashorterlink');
Branch: 1 branch
BranchTrueFalseTotal
my $url = shift() or Carp::croak("No URL passed to makeashorterlink") 0 0 0
17 0 my $ua = __PACKAGE__->ua();
18 0 my $response = $ua->post('https://v.gd/create.php', {
19 url => $url,
20 format => 'simple',
21 });
22  
23 0 ▶ return unless $response->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $response->is_success 0 0 0
24 0 my $shorturl = $response->decoded_content();
25 0 ▶ return undef unless $shorturl;
Branch: 1 branch
BranchTrueFalseTotal
unless $shorturl 0 0 0
26 0 ▶ return undef if $shorturl =~ m/^\s*Error/;
Branch: 1 branch
BranchTrueFalseTotal
if $shorturl =~ /^\s*Error/ 0 0 0
27 0 return $shorturl;
28 }
29  
30 0 ▶sub makealongerlink {
Subroutine makealongerlink: not called CC=5 SCAR=34.0
Pod documented
31 0 ▶ my $url = shift or Carp::croak('No v.gd key/URL passed to makealongerlink');
Branch: 1 branch
BranchTrueFalseTotal
my $url = shift() or Carp::croak("No v.gd key/URL passed to makealongerlink") 0 0 0
32 0 my $ua = __PACKAGE__->ua();
33  
34 0 $url =~ s{\Qhttps?://v.gd/\E}{}i;
35 0 my $res = $ua->post('https://v.gd/forward.php', {
36 shorturl => $url,
37 format => 'simple',
38 });
39  
40 0 ▶ return undef unless $res->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_success 0 0 0
41 0 my $longurl = $res->decoded_content;
42 0 ▶ return undef unless $longurl;
Branch: 1 branch
BranchTrueFalseTotal
unless $longurl 0 0 0
43 0 ▶ return undef if $longurl =~ m/^\s*Error/;
Branch: 1 branch
BranchTrueFalseTotal
if $longurl =~ /^\s*Error/ 0 0 0
44 0 return decode_entities($longurl);
45 }
46  
47 2 1;
48  
49 __END__
↑ Summary