Uploads/Retriever.pm

filter: Statementstmt 100% 40 / 40 Branchbran 50.0% 4 / 8 Conditioncond 36.3% 4 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 77.3% 58 / 75 CC 10 SCAR 17.5
CC
10
Cov
81%
retrieve
11.0
_fetch
3.0
BEGIN
1.0
CRAP 5.8
« Uploads.pm ↑ Summary
1 package CPAN::Recent::Uploads::Retriever;
2 3 $CPAN::Recent::Uploads::Retriever::VERSION = '0.16';
3 #ABSTRACT: Retrieves recentfiles from a CPAN mirror
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use File::Spec::Unix;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 my @times = qw(1h 6h 1d 1W 1M 1Q 1Y);
13  
14 1 ▶sub retrieve {
Subroutine retrieve: called CC=8 SCAR=24.0
Pod documented
15 1 my $class = shift;
16 1 my %opts = @_;
17 1 $opts{lc $_} = delete $opts{$_} for keys %opts;
18 1 my $self = bless \%opts, $class;
19 1 ▶ $self->{uri} = URI->new( $self->{mirror} || 'http://www.cpan.org/' );
Condition50%1/2
$self->{'mirror'} || 'http://www.cpan.org/'
l!l
10
MC/DC0%0/1
$self->{'mirror'} || 'http://www.cpan.org/'
$self->{'mirror'}
Truth table50%1/2
A
A= $self->{'mirror'}
Aresult
11
00
20 croak "Unknown scheme\n"
21 unless $self->{uri} and $self->{uri}->scheme and
22 1 ▶ $self->{uri}->scheme =~ /^(http|ftp)$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uri"} and $self->{"uri"}->scheme and $self->{"uri"}->scheme =~ /^(http|ftp)$/i 0 1 1
Condition33%2/6
$self->{"uri"} and $self->{"uri"}->scheme and $self->{"uri"}->scheme =~ /^(http|ftp)$/i
!ll&&!rl&&r
001
$self->{"uri"} and $self->{"uri"}->scheme
!ll&&!rl&&r
001
MC/DC0%0/3
$self->{"uri"} and $self->{"uri"}->scheme and $self->{"uri"}->scheme =~ /^(http|ftp)$/i
$self->{"uri"} $self->{"uri"}->scheme $self->{"uri"}->scheme =~ /^(http|ftp)$/i
Truth table25%1/4
A and B and C
A= $self->{"uri"}B= $self->{"uri"}->schemeC= $self->{"uri"}->scheme =~ /^(http|ftp)$/i
ABCresult
0XX0
10X0
1100
1111
23 $self->{time} = '6h'
24 unless $self->{time}
25 1 ▶ and grep { $_ eq $self->{time} } @times;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"time"} and grep {$_ eq $self->{"time"};} @times 0 1 1
Condition33%1/3
$self->{"time"} and grep {$_ eq $self->{"time"};} @times
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"time"} and grep {$_ eq $self->{"time"};} @times
$self->{"time"} grep {$_ eq $self->{"time"};} @times
Truth table33%1/3
A and B
A= $self->{"time"}B= grep {$_ eq $self->{"time"};} @times
ABresult
0X0
100
111
26 1 $self->{uri}->path( File::Spec::Unix->catfile( $self->{uri}->path, 'authors', 'RECENT-' . $self->{time} . '.yaml' ) );
27 1 return $self->_fetch();
28 }
29  
30 1 ▶sub _fetch {
Subroutine _fetch: called CC=3 SCAR=11.1
31 1 my $self = shift;
32 1 ▶ open my $fooh, '>', \$self->{foo} or die "$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $fooh, ">", \$self->{"foo"} or die "$!\n" 1 0 1
33 1 my $ua = HTTP::Tiny->new();
34 1 ▶ my $resp = $ua->get( $self->{uri}->as_string, { 'data_callback' => sub { my $data = shift; print {$fooh} $data; } } );
Subroutine __ANON__: called CC=1 SCAR=0.0
35 1 close $fooh;
36 1 ▶ return $self->{foo} if $resp->{success};
Branch: 1 branch
BranchTrueFalseTotal
if $resp->{"success"} 1 0 1
37 }
38  
39 3 q[Woof];
40  
41 __END__
« Uploads.pm ↑ Summary