Local/Plugin/PackagesDetails.pm

filter: Statementstmt 60.0% 36 / 60 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 9 / 12 Podpod 100% 3 / 3 totaltotal 52.1% 48 / 92 CC 9 SCAR 34.0
CC
9
Cov
48%
index
72.0
initialise
6.0
requires_distribution_roles
2.0
CRAP 29.9
« Local/App/Command/update.pm ↑ Summary Local/Plugin/Indices.pm »
1 package CPAN::Local::Plugin::PackagesDetails;
2 {
3 2 $CPAN::Local::Plugin::PackagesDetails::VERSION = '0.010';
4 }
5  
6 # ABSTRACT: Update 02packages.details.txt
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 CPAN::Index::API::File::PackagesDetails;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use CPAN::DistnameInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Path::Class qw(file dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use URI::file;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Perl::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 extends 'CPAN::Local::Plugin';
19 2 with qw(CPAN::Local::Role::Initialise CPAN::Local::Role::Index);
20  
21 2 has 'repo_uri' =>
22 (
23 is => 'ro',
24 isa => 'Str',
25 );
26  
27 2 has 'root' =>
28 (
29 is => 'ro',
30 isa => 'Str',
31 required => 1,
32 );
33  
34 2 has 'auto_provides' =>
35 (
36 is => 'ro',
37 isa => 'Bool',
38 );
39  
40 2 has 'no_update' =>
41 (
42 is => 'ro',
43 isa => 'Bool',
44 );
45  
46 sub initialise
47 0 ▶{
Subroutine initialise: not called CC=2 SCAR=17.9
Pod documented
48 0 my $self = shift;
49  
50 0 dir($self->root)->mkpath;
51  
52 0 ▶ my $packages_details = CPAN::Index::API::File::PackagesDetails->new(
Branch: 1 branch
BranchTrueFalseTotal
$self->repo_uri ? : 0 0 0
53 repo_path => $self->root,
54 $self->repo_uri ? ( repo_uri => $self->repo_uri ) : (),
55 );
56  
57 0 $packages_details->write_to_tarball;
58 }
59  
60 sub index
61 0 ▶{
Subroutine index: not called CC=8 SCAR=42.8
Pod documented
62 0 my ($self, @distros) = @_;
63  
64 0 ▶ return if $self->no_update;
Branch: 1 branch
BranchTrueFalseTotal
if $self->no_update 0 0 0
65  
66 0 my $packages_details =
67 CPAN::Index::API::File::PackagesDetails->read_from_repo_path($self->root);
68  
69 0 foreach my $distro ( @distros )
70 {
71 0 my %provides = %{ $distro->metadata->provides };
72  
73 0 ▶ if ( ! %provides and $self->auto_provides )
Branch: 1 branch
BranchTrueFalseTotal
if (not %provides and $self->auto_provides) 0 0 0
Condition0%0/3
not %provides and $self->auto_provides
!ll&&!rl&&r
000
MC/DC0%0/2
not %provides and $self->auto_provides
not %provides $self->auto_provides
Truth table0%0/3
not(A) and B
A= not %providesB= $self->auto_provides
ABresult
0X0
100
111
74 {
75 0 my $distnameinfo = CPAN::DistnameInfo->new(
76 file($distro->filename)->basename
77 );
78  
79 0 ( my $fake_package = $distnameinfo->dist ) =~ s/-/::/g;
80  
81 0 $provides{$fake_package} = { version => $distnameinfo->version };
82 }
83  
84 0 ▶ while( my ($package, $specs) = each %provides )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %provides) 0 0 0
85 {
86 0 my $version = $specs->{version};
87  
88 0 ▶ if ( my $existing_package = $packages_details->package($package) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $existing_package = $packages_details->package($package)) { } 0 0 0
89 {
90 $existing_package->{version} = $version
91 if Perl::Version->new($version) >
92 0 ▶ Perl::Version->new($existing_package->{version});
Branch: 1 branch
BranchTrueFalseTotal
if "Perl::Version"->new($version) > "Perl::Version"->new($existing_package->{"version"}) 0 0 0
93 }
94 else
95 {
96 0 my $path = file($distro->path);
97  
98 # drop 'authors/id' from the distro path
99 0 my $distribution = file(
100 $path->dir->dir_list(2),
101 $path->basename,
102 )->as_foreign('Unix')->stringify;
103  
104 0 $packages_details->add_package({
105 name => $package,
106 version => $version,
107 distribution => $distribution,
108 });
109 }
110 }
111 }
112  
113 0 $packages_details->rebuild_content;
114 0 $packages_details->write_to_tarball;
115 }
116  
117 0 ▶sub requires_distribution_roles { qw(Metadata) }
Subroutine requires_distribution_roles: not called CC=1 SCAR=6.9
Pod documented
118  
119 2 __PACKAGE__->meta->make_immutable;
120  
121  
122  
123 __END__
« Local/App/Command/update.pm ↑ Summary Local/Plugin/Indices.pm »