| 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/'
MC/DC0%0/1
$self->{'mirror'} || 'http://www.cpan.org/'
$self->{'mirror'}
Truth table50%1/2
A
A= $self->{'mirror'}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
$self->{"uri"} and $self->{"uri"}->scheme and $self->{"uri"}->scheme =~ /^(http|ftp)$/i
$self->{"uri"} and $self->{"uri"}->scheme
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
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | $self->{time} = '6h' | ||||||||||||||||||||||||||||||||||||||||||
| 24 | unless $self->{time} | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | and grep { $_ eq $self->{time} } @times; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"time"} and grep {$_ eq $self->{"time"};} @times
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | q[Woof]; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||||||||||||||||