Local/Plugin/Indices.pm

filter: Statementstmt 64.6% 42 / 65 Branchbran 8.3% 1 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 12 / 15 Podpod 100% 3 / 3 totaltotal 58.0% 58 / 100 CC 9 SCAR 29.1
CC
9
Cov
54%
index
56.0
initialise
6.0
BEGIN
2.1
CRAP 18.3
« Local/Plugin/PackagesDetails.pm ↑ Summary Local/Distribution/Role/FromURI.pm »
1 package CPAN::Local::Plugin::Indices;
2 {
3 2 $CPAN::Local::Plugin::Indices::VERSION = '0.010';
4 }
5  
6 # ABSTRACT: [DEPRECATED] Update index files
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 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
12 warn "CPAN::Local::Plugin::Indices is deprecated. "
13 . "Please use PackagesDetails, ModList and MalRc plugins instead."
14 2 ▶ unless $ENV{HARNESS_ACTIVE};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"HARNESS_ACTIVE"} 0 2 2
15 }
16  
17 2 ▶use CPAN::Index::API;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use CPAN::Index::API::File::PackagesDetails;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use CPAN::DistnameInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Path::Class qw(file dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use URI::file;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Perl::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 extends 'CPAN::Local::Plugin';
27 2 with qw(CPAN::Local::Role::Initialise CPAN::Local::Role::Index);
28  
29 2 has 'repo_uri' =>
30 (
31 is => 'ro',
32 isa => 'Str',
33 );
34  
35 2 has 'root' =>
36 (
37 is => 'ro',
38 isa => 'Str',
39 required => 1,
40 );
41  
42 2 has 'auto_provides' =>
43 (
44 is => 'ro',
45 isa => 'Bool',
46 );
47  
48 sub initialise
49 0 ▶{
Subroutine initialise: not called CC=2 SCAR=17.9
Pod documented
50 0 my $self = shift;
51  
52 0 File::Path::make_path( dir($self->root)->stringify );
53  
54 0 my %args = (
55 repo_path => $self->root,
56 files => [qw(PackagesDetails MailRc ModList)],
57 );
58 0 ▶ $args{repo_uri} = $self->repo_uri if $self->repo_uri;
Branch: 1 branch
BranchTrueFalseTotal
if $self->repo_uri 0 0 0
59  
60 0 my $index = CPAN::Index::API->new(%args);
61  
62 0 $index->write_all_files;
63 }
64  
65 sub index
66 0 ▶{
Subroutine index: not called CC=7 SCAR=40.3
Pod documented
67 0 my ($self, @distros) = @_;
68  
69 0 my $packages_details =
70 CPAN::Index::API::File::PackagesDetails->read_from_repo_path($self->root);
71  
72 0 foreach my $distro ( @distros )
73 {
74 0 my %provides = %{ $distro->metadata->provides };
75  
76 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
77 {
78 0 my $distnameinfo = CPAN::DistnameInfo->new(
79 file($distro->filename)->basename
80 );
81  
82 0 ( my $fake_package = $distnameinfo->dist ) =~ s/-/::/g;
83  
84 0 $provides{$fake_package} = { version => $distnameinfo->version };
85 }
86  
87 0 ▶ while( my ($package, $specs) = each %provides )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %provides) 0 0 0
88 {
89 0 my $version = $specs->{version};
90  
91 0 ▶ if ( my $existing_package = $packages_details->package($package) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $existing_package = $packages_details->package($package)) { } 0 0 0
92 {
93 $existing_package->{version} = $version
94 if Perl::Version->new($version) >
95 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
96 }
97 else
98 {
99 0 $packages_details->add_package({
100 name => $package,
101 version => $version,
102 distribution => $distro->path,
103 });
104 }
105 }
106 }
107  
108 0 $packages_details->rebuild_content;
109 0 $packages_details->write_to_tarball;
110 }
111  
112 0 ▶sub requires_distribution_roles { qw(Metadata) }
Subroutine requires_distribution_roles: not called CC=1 SCAR=6.9
Pod documented
113  
114 2 __PACKAGE__->meta->make_immutable;
115  
116  
117  
118 __END__
« Local/Plugin/PackagesDetails.pm ↑ Summary Local/Distribution/Role/FromURI.pm »