| 1 | package Parse::BACKPAN::Packages; | ||||||||||
| 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 | our $VERSION = '0.40'; | |||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Mouse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use BackPAN::Index::Types; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | has no_cache => | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | isa => 'Bool', | ||||||||||
| 14 | default => 0; | ||||||||||
| 15 | |||||||||||
| 16 | 2 | has only_authors => | |||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | isa => 'Bool', | ||||||||||
| 19 | default => 1 | ||||||||||
| 20 | ; | ||||||||||
| 21 | |||||||||||
| 22 | 2 | has _delegate => | |||||||||
| 23 | is => 'rw', | ||||||||||
| 24 | isa => 'BackPAN::Index'; | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||
| 28 | 2 | my $self = shift; | |||||||||
| 29 | 2 | my $args = shift; | |||||||||
| 30 | |||||||||||
| 31 | # Translate from PBP options to BackPAN::Index | ||||||||||
| 32 | 2 | ▶ | if( exists $args->{no_cache} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | $args->{update} = $args->{no_cache}; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 2 | ▶ | if( exists $args->{only_authors} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | $args->{releases_only_from_authors} = $args->{only_authors}; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 2 | require BackPAN::Index; | |||||||||
| 41 | 2 | $self->_delegate( BackPAN::Index->new($args) ); | |||||||||
| 42 | |||||||||||
| 43 | 2 | return $self; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 2 | our $AUTOLOAD; | |||||||||
| 47 | 7 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.0
| |||||||||||
| 48 | 7 | my $self = shift; | |||||||||
| 49 | 7 | my($method) = $AUTOLOAD =~ /:: ([^:]+) $/x; | |||||||||
| 50 | |||||||||||
| 51 | # Skip things like DESTROY | ||||||||||
| 52 | 7 | ▶ | return if uc $method eq $method; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 7 | $self->_delegate->$method(@_); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub files { | ||||||||
|
Subroutine
files: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 58 | 0 | my $self = shift; | |||||||||
| 59 | |||||||||||
| 60 | 0 | my %files; | |||||||||
| 61 | 0 | my $rs = $self->_delegate->files; | |||||||||
| 62 | 0 | ▶ | while( my $file = $rs->next ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $files{$file->path} = $file; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | return \%files; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 1 | ▶ | sub file { | ||||||||
|
Subroutine
file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | 1 | my ( $self, $path ) = @_; | |||||||||
| 71 | |||||||||||
| 72 | 1 | return $self->_delegate->files->single({ path => $path }); | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 1 | ▶ | sub releases { | ||||||||
|
Subroutine
releases: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 76 | 1 | my($self, $dist) = @_; | |||||||||
| 77 | |||||||||||
| 78 | 1 | return $self->_delegate->releases($dist)->all; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | 0 | ▶ | sub distributions { | ||||||||
|
Subroutine
distributions: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 83 | 0 | my $self = shift; | |||||||||
| 84 | |||||||||||
| 85 | # For backwards compatibilty when releases() was distributions() | ||||||||||
| 86 | 0 | ▶ | return $self->releases(shift) if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | |||||||||||
| 88 | 0 | return [$self->_delegate->distributions->get_column("name")->all]; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 4 | ▶ | sub distributions_by { | ||||||||
|
Subroutine
distributions_by: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 92 | 4 | my ( $self, $author ) = @_; | |||||||||
| 93 | 4 | ▶ | return unless $author; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | |||||||||||
| 95 | 3 | my $dists = $self->db->dbh->selectcol_arrayref(q[ | |||||||||
| 96 | SELECT DISTINCT dist | ||||||||||
| 97 | FROM releases | ||||||||||
| 98 | WHERE cpanid = ? | ||||||||||
| 99 | ORDER BY dist | ||||||||||
| 100 | ], | ||||||||||
| 101 | undef, | ||||||||||
| 102 | $author | ||||||||||
| 103 | ); | ||||||||||
| 104 | |||||||||||
| 105 | 3 | return @$dists; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 1 | ▶ | sub authors { | ||||||||
|
Subroutine
authors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 109 | 1 | my $self = shift; | |||||||||
| 110 | |||||||||||
| 111 | 1 | my $authors = $self->db->dbh->selectcol_arrayref(q[ | |||||||||
| 112 | SELECT DISTINCT cpanid | ||||||||||
| 113 | FROM releases | ||||||||||
| 114 | ORDER BY cpanid | ||||||||||
| 115 | ]); | ||||||||||
| 116 | |||||||||||
| 117 | 1 | return @$authors; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub size { | ||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 121 | 0 | my $self = shift; | |||||||||
| 122 | |||||||||||
| 123 | 0 | my $size = $self->db->dbh->selectcol_arrayref(q[ | |||||||||
| 124 | SELECT SUM(size) FROM files | ||||||||||
| 125 | ]); | ||||||||||
| 126 | |||||||||||
| 127 | 0 | return $size->[0]; | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 2 | 1; | |||||||||
| 131 | |||||||||||
| 132 | __END__ | ||||||||||