blib/lib/WWW/Shorten/Flickr.pm

filter: Statementstmt 100% 34 / 34 Branchbran 70.0% 7 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 94.9% 56 / 59 CC 7 SCAR 10.0
CC
7
Cov
94%
makealongerlink
4.0
makeashorterlink
4.0
BEGIN
1.0
CRAP 2.7
↑ Summary
1 package WWW::Shorten::Flickr;
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 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base qw( WWW::Shorten::generic Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 our @EXPORT = qw( makeashorterlink makealongerlink );
7  
8 3 our $VERSION = '0.03';
9  
10 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Encode::Base58;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶sub makeashorterlink {
Subroutine makeashorterlink: called CC=4 SCAR=13.9
Pod documented
14 3 ▶ my $uri = shift or croak 'No URL passed to makeashorterlink';
Branch: 1 branch
BranchTrueFalseTotal
my $uri = shift() or croak("No URL passed to makeashorterlink") 3 0 3
15  
16 3 my $photo_id;
17 3 ▶ if ( $uri =~ m!^http://www\.flickr\.com/photos/[\w@-]+/(\d+)!i
Branch: 1 branch
BranchTrueFalseTotal
if ($uri =~ m[^http://www\.flickr\.com/photos/[\w\@-]+/(\d+)]i or $uri =~ /^(\d+)$/) { } 2 1 3
Condition100%3/3
$uri =~ m[^http://www\.flickr\.com/photos/[\w\@-]+/(\d+)]i or $uri =~ /^(\d+)$/
l!l&&r!l&&!r
111
MC/DC100%2/2
$uri =~ m[^http://www\.flickr\.com/photos/[\w\@-]+/(\d+)]i or $uri =~ /^(\d+)$/
$uri =~ m[^http://www\.flickr\.com/photos/[\w\@-]+/(\d+)]i $uri =~ /^(\d+)$/
Truth table100%3/3
A or B
A= $uri =~ m[^http://www\.flickr\.com/photos/[\w\@-]+/(\d+)]iB= $uri =~ /^(\d+)$/
ABresult
1X1
011
000
18 || $uri =~ /^(\d+)$/ )
19 {
20 2 $photo_id = $1;
21 }
22 else {
23 1 return;
24 }
25  
26 2 return sprintf( "http://flic.kr/p/%s", encode_base58($photo_id) );
27 }
28  
29 3 ▶sub makealongerlink {
Subroutine makealongerlink: called CC=4 SCAR=14.0
Pod documented
30 3 ▶ my $uri = shift or croak 'No URL passed to makealongerlink';
Branch: 1 branch
BranchTrueFalseTotal
my $uri = shift() or croak("No URL passed to makealongerlink") 3 0 3
31  
32 3 my $ua = __PACKAGE__->ua();
33 3 push @{ $ua->requests_redirectable }, 'GET';
34  
35 3 ▶ $uri = "http://flic.kr/p/$uri" unless $uri =~ m!^http://!i;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri =~ m[^http://]i 1 2 3
36  
37 3 my $res = $ua->get($uri);
38 3 ▶ return if $res->redirects() == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $res->redirects == 0 0 3 3
39 3 return $res->request->uri;
40 }
41  
42 3 1;
43 __END__
↑ Summary