| 1 | package CPAN::Local::Plugin::DistroList; | ||||||||||
| 2 | { | ||||||||||
| 3 | 2 | $CPAN::Local::Plugin::DistroList::VERSION = '0.003'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: Populate a mirror with a list of distributions | ||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use Path::Class qw(file dir); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use File::Temp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use LWP::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | ▶ | use CPAN::DistnameInfo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | extends 'CPAN::Local::Plugin'; | |||||||||
| 20 | 2 | with 'CPAN::Local::Role::Gather'; | |||||||||
| 21 | 2 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 2 | has list => | |||||||||
| 24 | ( | ||||||||||
| 25 | is => 'ro', | ||||||||||
| 26 | isa => 'Str', | ||||||||||
| 27 | predicate => 'has_list', | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | 2 | has prefix => | |||||||||
| 31 | ( | ||||||||||
| 32 | is => 'ro', | ||||||||||
| 33 | isa => 'Str', | ||||||||||
| 34 | default => '', | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | 2 | has uris => | |||||||||
| 38 | ( | ||||||||||
| 39 | is => 'ro', | ||||||||||
| 40 | isa => 'ArrayRef', | ||||||||||
| 41 | lazy_build => 1, | ||||||||||
| 42 | traits => ['Array'], | ||||||||||
| 43 | handles => { uri_list => 'elements' }, | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 2 | has cache => | |||||||||
| 47 | ( | ||||||||||
| 48 | is => 'ro', | ||||||||||
| 49 | isa => 'Str', | ||||||||||
| 50 | lazy_build => 1, | ||||||||||
| 51 | ); | ||||||||||
| 52 | |||||||||||
| 53 | 2 | has authorid => | |||||||||
| 54 | ( | ||||||||||
| 55 | is => 'ro', | ||||||||||
| 56 | isa => 'Str', | ||||||||||
| 57 | predicate => 'has_authorid', | ||||||||||
| 58 | ); | ||||||||||
| 59 | |||||||||||
| 60 | 2 | has local => | |||||||||
| 61 | ( | ||||||||||
| 62 | is => 'ro', | ||||||||||
| 63 | isa => 'Bool', | ||||||||||
| 64 | ); | ||||||||||
| 65 | |||||||||||
| 66 | sub _build_uris | ||||||||||
| 67 | 1 | ▶ | { | ||||||||
|
Subroutine
_build_uris: called CC=3 SCAR=11.0
| |||||||||||
| 68 | 1 | my $self = shift; | |||||||||
| 69 | |||||||||||
| 70 | 1 | my $prefix = $self->prefix; | |||||||||
| 71 | |||||||||||
| 72 | 1 | my @uris; | |||||||||
| 73 | |||||||||||
| 74 | 1 | ▶ | if ( $self->has_list ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | { | ||||||||||
| 76 | 1 | foreach my $line ( file( $self->list )->slurp ) | |||||||||
| 77 | { | ||||||||||
| 78 | 2 | chomp $line; | |||||||||
| 79 | 2 | push @uris, $prefix . $line; | |||||||||
| 80 | } | ||||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 1 | return \@uris; | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | sub _build_cache | ||||||||||
| 87 | 0 | ▶ | { | ||||||||
|
Subroutine
_build_cache: not called CC=1 SCAR=6.9
| |||||||||||
| 88 | 0 | return File::Temp::tempdir( CLEANUP => 1 ); | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | sub gather | ||||||||||
| 92 | 3 | ▶ | { | ||||||||
|
Subroutine
gather: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||
| 93 | 3 | my $self = shift; | |||||||||
| 94 | |||||||||||
| 95 | 3 | my @distros; | |||||||||
| 96 | |||||||||||
| 97 | 3 | foreach my $uri ( $self->uri_list ) | |||||||||
| 98 | { | ||||||||||
| 99 | 6 | ▶ | my %args = $self->local | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | ? ( filename => $uri ) | ||||||||||
| 101 | : ( uri => $uri, cache => $self->cache ); | ||||||||||
| 102 | |||||||||||
| 103 | 6 | ▶ | $args{authorid} = $self->authorid if $self->has_authorid; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | my $distro = | ||||||||||
| 105 | 6 | ▶ | try { $self->create_distribution(%args) } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 106 | 0 | ▶ | catch { $self->log($_) }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 107 | |||||||||||
| 108 | 6 | ▶ | push @distros, $distro if $distro; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | 3 | return @distros; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | sub requires_distribution_roles { 'FromURI' } | ||||||||
|
Subroutine
requires_distribution_roles: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 115 | |||||||||||
| 116 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 117 | |||||||||||
| 118 | |||||||||||
| 119 | __END__ | ||||||||||