| 1 | package MyCPAN::App::DPAN::Reporter::Minimal; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use base qw(MyCPAN::Indexer::Reporter::Base); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use vars qw($VERSION $reporter_logger $collator_logger); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | $VERSION = '1.281'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use File::Spec::Functions qw(catfile rel2abs file_name_is_absolute); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Log::Log4perl; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | $reporter_logger = Log::Log4perl->get_logger( 'Reporter' ); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | $collator_logger = Log::Log4perl->get_logger( 'Collator' ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | MyCPAN::App::DPAN::Reporter::Minimal - Save the minimum information that dpan needs | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | Use this in the C<dpan> config by specifying it as the reporter class: | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # in dpan.config | ||||||||||||||||||||||||||||||||||||||||||
| 32 | reporter_class MyCPAN::App::DPAN::Reporter::Minimal | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | This class takes the result of examining a distribution and saves only | ||||||||||||||||||||||||||||||||||||||||||
| 37 | the information that dpan needs to create the PAUSE index files. It's | ||||||||||||||||||||||||||||||||||||||||||
| 38 | a very small text file with virtually no processing overhead compared | ||||||||||||||||||||||||||||||||||||||||||
| 39 | to YAML. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =head2 Methods | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =item get_reporter | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | C<get_reporter> sets the C<reporter> key in the notes. The value is a | ||||||||||||||||||||||||||||||||||||||||||
| 48 | code reference that takes the information collected about a | ||||||||||||||||||||||||||||||||||||||||||
| 49 | distribution and dumps it as a YAML file. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | See L<MyCPAN::Indexer::Tutorial> for details about what | ||||||||||||||||||||||||||||||||||||||||||
| 52 | C<get_reporter> expects and should do. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | If C<relative_paths_in_report> is true, the reports removes the base | ||||||||||||||||||||||||||||||||||||||||||
| 55 | path up to I<author/id>. | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =item get_report_file_extension | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | Returns the extension for report files. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub get_report_file_extension { 'txt' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_report_file_extension: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | sub get_reporter | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_reporter: not called CC=2 SCAR=16.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # why is this here? | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $base_dir = $self->get_config->dpan_dir; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if( $self->get_config->organize_dists ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $base_dir = catfile( $base_dir, qw(authors id) ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $reporter = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=13 SCAR=48.9
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my( $info ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | unless( defined $info ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $reporter_logger->error( "info is undefined!" ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my( %Found_canonical, %Current_version, @packages_to_write ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | MODULE: foreach my $module ( @{ $info->{dist_info}{module_info} || [] } ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'dist_info'}{'module_info'} || []
MC/DC0%0/1
$info->{'dist_info'}{'module_info'} || []
$info->{'dist_info'}{'module_info'}
Truth table0%0/2
A
A= $info->{'dist_info'}{'module_info'}
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # skip if we are ignoring those packages? | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my $version = $module->{version_info}{value} || 'undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$module->{'version_info'}{'value'} || 'undef'
MC/DC0%0/1
$module->{'version_info'}{'value'} || 'undef'
$module->{'version_info'}{'value'}
Truth table0%0/2
A
A= $module->{'version_info'}{'value'}
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $version = $version->numify if eval { $version->can('numify') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | unless( defined $module->{primary_package} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $reporter_logger->warn( "No primary package for $module->{name}" ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | next MODULE; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | next MODULE if $Found_canonical{ $module->{primary_package} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | no warnings qw(uninitialized numeric); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | next MODULE if $version < $Current_version{ $module->{primary_package} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $Current_version{ $module->{primary_package} } = $version; | |||||||||||||||||||||||||||||||||||||||||
| 107 | $Found_canonical{ $module->{primary_package} } = 1 if | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | $module->{primary_package} eq $module->{module_name_from_file_guess}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | # this should be an absolute path | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $dist_file = $info->{dist_info}{dist_file}; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if( $self->get_config->relative_paths_in_report ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # XXX: what if there isn't an authors/id? | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $dist_file =~ s/^.*authors.id.//; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $dist_file =~ tr|\\|/|; # translate windows \ to Unix /, cheating | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $reporter_logger->warn( "No dist file for $module->{name}" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | unless defined $dist_file; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | push @packages_to_write, [ | ||||||||||||||||||||||||||||||||||||||||||
| 124 | $module->{primary_package}, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $version, | |||||||||||||||||||||||||||||||||||||||||
| 126 | $dist_file, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if( $info->{run_info}{completed} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->_write_success_file( $info, \@packages_to_write ); | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | else | ||||||||||||||||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->_write_error_file( $info ); | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->set_note( 'reporter', $reporter ); | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | sub _write_success_file | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_success_file: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my( $self, $info, $packages ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $out_path = $self->get_report_path( $info ); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | open my($fh), ">:utf8", $out_path or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | $reporter_logger->fatal( "Could not open $out_path to record success report: $!" ); | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | print $fh "# Primary package [TAB] version [TAB] dist file [newline]\n"; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | foreach my $tuple ( @$packages ) | |||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | print $fh join "\t", @$tuple; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | print $fh "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | # check that the file is where it should be | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $reporter_logger->error( "$out_path is missing!" ) unless -e $out_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | sub _write_error_file | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_error_file: not called CC=4 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my( $self, $info ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $out_path = $self->get_report_path( $info ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | open my($fh), ">:utf8", $out_path or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | $reporter_logger->fatal( "Could not open $out_path to record error report: $!" ); | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | print $fh "ERRORS:\n", | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | map { sprintf "%s: %s\n", $_, $info->{run_info}{$_} || '' } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'run_info'}{$_} || ''
MC/DC0%0/1
$info->{'run_info'}{$_} || ''
$info->{'run_info'}{$_}
Truth table0%0/2
A
A= $info->{'run_info'}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | qw( error fatal_error extraction_error ); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | print $fh '-' x 73, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | print $fh Dumper( $info ); | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | # check that the file is where it should be | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $reporter_logger->error( "$out_path is missing!" ) unless -e $out_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =item get_collator | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | This Reporter class also implements its Collator since the two are | ||||||||||||||||||||||||||||||||||||||||||
| 195 | coupled by the report format. It's a wrapper around C<final_words>, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | which previously did the same thing. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | sub get_collator | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_collator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | #TRACE( sub { get_caller_info } ); | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | my $collator = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $self->final_words; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | unless( eval { $self->create_index_files } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->set_note( 'epic_fail', $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $self->set_note( $_[0]->collator_type, $collator ); | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =item final_words | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | Runs after all the reporting for all distributions has finished. This | ||||||||||||||||||||||||||||||||||||||||||
| 224 | creates a C<CPAN::PackageDetails> object and stores it as the C<package_details> | ||||||||||||||||||||||||||||||||||||||||||
| 225 | notes. It store the list of directories that need fresh F<CHECKSUMS> files | ||||||||||||||||||||||||||||||||||||||||||
| 226 | in the C<dirs_needing_checksums> note. | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | The checksums and index file creation are split across two steps so that | ||||||||||||||||||||||||||||||||||||||||||
| 229 | C<dpan> has a chance to do something between the analysis and their creation. | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | sub final_words | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
final_words: not called CC=23 SCAR=60.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | # This is where I want to write 02packages and CHECKSUMS | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $collator_logger->trace( "Final words from the DPAN Reporter" ); | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my %dirs_needing_checksums; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | ▶ | use CPAN::PackageDetails 0.22; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $package_details = CPAN::PackageDetails->new( | |||||||||||||||||||||||||||||||||||||||||
| 244 | allow_packages_only_once => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $collator_logger->info( "Creating index files" ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $self->_init_skip_package_from_config; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | require version; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | FILE: foreach my $file ( $self->get_latest_module_reports ) | |||||||||||||||||||||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $collator_logger->debug( "Processing output file $file" ); | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | unless( -e $file ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $collator_logger->debug( "No success report for [$file]" ); | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | next FILE; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | open my($fh), '<:utf8', $file or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $collator_logger->error( "Could not open [$file]: $!" ); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | next FILE; | |||||||||||||||||||||||||||||||||||||||||
| 265 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my @packages; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | PACKAGE: while( <$fh> ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | next PACKAGE if /^\s*#/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my( $package, $version, $dist_file ) = split /\t/; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $version = undef if $version eq 'undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $collator_logger->warn( "$package has no distribution file: $file" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | unless defined $dist_file; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | unless( defined $package && length $package ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $package and length $package
MC/DC0%0/2
defined $package and length $package
defined $package
length $package
Truth table0%0/3
A and B
A= defined $packageB= length $package
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $collator_logger->debug( "File $file line $.: no package! Line is [$_]" ); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | next PACKAGE; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $full_path = $dist_file; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | unless( file_name_is_absolute( $full_path ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $dpan_dir = $self->get_config->dpan_dir; | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | # if we're using organize_dists, we created an authors/id | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # directory under dpan_dir, so we have to put those | ||||||||||||||||||||||||||||||||||||||||||
| 292 | # three pieces together | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if( $self->get_config->organize_dists ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $full_path = catfile( | |||||||||||||||||||||||||||||||||||||||||
| 296 | $dpan_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | qw(authors id), | ||||||||||||||||||||||||||||||||||||||||||
| 298 | $dist_file | ||||||||||||||||||||||||||||||||||||||||||
| 299 | ) ; | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # otherwise, every path should be relative to $dpan_dir | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # I'm not sure that is actually true though if dpan_dir | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # is the current directory, and there is an authors/id | ||||||||||||||||||||||||||||||||||||||||||
| 304 | # under it | ||||||||||||||||||||||||||||||||||||||||||
| 305 | elsif( $self->get_config->relative_paths_in_report ) | ||||||||||||||||||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $f1 = catfile( | |||||||||||||||||||||||||||||||||||||||||
| 308 | $dpan_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | $dist_file | ||||||||||||||||||||||||||||||||||||||||||
| 310 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $f2 = catfile( | |||||||||||||||||||||||||||||||||||||||||
| 313 | $dpan_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | qw(authors id), | ||||||||||||||||||||||||||||||||||||||||||
| 315 | $dist_file | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ( $full_path ) = grep { -e } ( $f1, $f2 ) | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $collator_logger->debug( "dist_file is now [$dist_file]" ); | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $collator_logger->debug( "full_path is now [$full_path]" ); | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | next PACKAGE unless defined $full_path && -e $full_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $full_path and -e $full_path
MC/DC0%0/2
defined $full_path and -e $full_path
defined $full_path
-e $full_path
Truth table0%0/3
A and B
A= defined $full_pathB= -e $full_path
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $dist_dir = dirname( $full_path ); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $dirs_needing_checksums{ $dist_dir }++; | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | # broken crap that works on Unix and Windows to make cpanp | ||||||||||||||||||||||||||||||||||||||||||
| 333 | # happy. It assumes that authors/id/ is in front of the path | ||||||||||||||||||||||||||||||||||||||||||
| 334 | # in 02packages.details.txt | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ( my $path = $dist_file ) =~ s/.*authors.id.//g; | |||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $path =~ s|\\+|/|g; # no windows paths. | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if( $self->skip_package( $package ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $collator_logger->debug( "Skipping $package: excluded by config" ); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | next PACKAGE; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | push @packages, [ $package, $version, $path ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$package and $version and $path
$package and $version
MC/DC0%0/3
$package and $version and $path
$package
$version
$path
Truth table0%0/4
A and B and C
A= $packageB= $versionC= $path
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | if( $package and $version and $path ); | ||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | # Some distros declare the same package in multiple files. We | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # only want the one with the defined or highest version | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my %Seen; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 3 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | my @filtered_packages = | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | grep { ! $Seen{$_->[0]}++ } | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | map { my $s = $_; $s->[1] = 'undef' unless defined $s->[1]; $s } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | sort { | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $a->[0] cmp $b->[0] | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$MyCPAN::App::DPAN::Reporter::Minimal::a->[0] cmp $MyCPAN::App::DPAN::Reporter::Minimal::b->[0] || $MyCPAN::App::DPAN::Reporter::Minimal::b->[1] cmp $MyCPAN::App::DPAN::Reporter::Minimal::a->[1]
MC/DC0%0/2
$MyCPAN::App::DPAN::Reporter::Minimal::a->[0] cmp $MyCPAN::App::DPAN::Reporter::Minimal::b->[0] || $MyCPAN::App::DPAN::Reporter::Minimal::b->[1] cmp $MyCPAN::App::DPAN::Reporter::Minimal::a->[1]
$MyCPAN::App::DPAN::Reporter::Minimal::a->[0] cmp $MyCPAN::App::DPAN::Reporter::Minimal::b->[0]
$MyCPAN::App::DPAN::Reporter::Minimal::b->[1] cmp $MyCPAN::App::DPAN::Reporter::Minimal::a->[1]
Truth table0%0/3
A || B
A= $MyCPAN::App::DPAN::Reporter::Minimal::a->[0] cmp $MyCPAN::App::DPAN::Reporter::Minimal::b->[0]B= $MyCPAN::App::DPAN::Reporter::Minimal::b->[1] cmp $MyCPAN::App::DPAN::Reporter::Minimal::a->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | || | ||||||||||||||||||||||||||||||||||||||||||
| 361 | $b->[1] cmp $a->[1] # yes, versions are strings | ||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | @packages; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | foreach my $tuple ( @filtered_packages ) | |||||||||||||||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my( $package, $version, $path ) = @$tuple; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | eval { $package_details->add_entry( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 'package name' => $package, | ||||||||||||||||||||||||||||||||||||||||||
| 371 | version => $version, | ||||||||||||||||||||||||||||||||||||||||||
| 372 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 373 | ) } or warn "Could not add $package $version from $path! $@\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $self->set_note( 'package_details', $package_details ); | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $self->set_note( 'dirs_needing_checksums', [ keys %dirs_needing_checksums ] ); | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | =item get_latest_module_reports | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | Return the list of interesting reports for this indexing run. This | ||||||||||||||||||||||||||||||||||||||||||
| 386 | re-runs the queuer to get the final list of distributions in | ||||||||||||||||||||||||||||||||||||||||||
| 387 | dpan_dir (some things might have moved around), gets the reports for | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | sub get_latest_module_reports | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_latest_module_reports: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | $reporter_logger->info( "In get_latest_module_reports" ); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 4 | my $report_names_by_dist_names = $self->_get_report_names_by_dist_names; | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | my $all_reports = $self->_get_all_reports; | |||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 4 | my %Seen = (); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 4 | my $report_dir = $self->get_success_report_dir; | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | my @files = | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 10 | map { catfile( $report_dir, $_->[-1] ) } | |||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | grep { ! $Seen{$_->[0]}++ } | |||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | map { [ /^(.*)-(.*)\.txt\z/, $_ ] } | |||||||||||||||||||||||||||||||||||||||||
| 408 | reverse | ||||||||||||||||||||||||||||||||||||||||||
| 409 | sort | ||||||||||||||||||||||||||||||||||||||||||
| 410 | keys %$report_names_by_dist_names; | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 4 | ▶ | my $extra_reports = $self->_get_extra_reports || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_get_extra_reports || []
MC/DC0%0/1
$self->_get_extra_reports || []
$self->_get_extra_reports
Truth table50%1/2
A
A= $self->_get_extra_reports
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 4 | push @files, @$extra_reports; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 4 | $reporter_logger->debug( "Adding extra reports [@$extra_reports]" ); | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | @files; | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | sub _get_all_reports | ||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_all_reports: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my $report_dir = $self->get_success_report_dir; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $reporter_logger->debug( "Report dir is $report_dir" ); | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | opendir my($dh), $report_dir or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | $reporter_logger->fatal( "Could not open directory [$report_dir]: $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my @reports = readdir( $dh ); | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | \@reports; | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | # this generates a list of report names based on what should | ||||||||||||||||||||||||||||||||||||||||||
| 436 | # be there according to the dist that we just indexed. There | ||||||||||||||||||||||||||||||||||||||||||
| 437 | # might be many reports for different versions or modules no | ||||||||||||||||||||||||||||||||||||||||||
| 438 | # longer in the DPAN, so we don't want those | ||||||||||||||||||||||||||||||||||||||||||
| 439 | sub _get_report_names_by_dist_names | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_report_names_by_dist_names: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | # We have to recreate the queue because we might have moved | ||||||||||||||||||||||||||||||||||||||||||
| 444 | # things around with organize_dists | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $queuer = $self->get_coordinator->get_component( 'queue' ); | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | # these are the directories to index | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my @dirs = $self->get_config->dpan_dir; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $reporter_logger->debug( "Queue directories are [@dirs]" ); | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | # This is the list of distributions in the indexed directories | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $dists = $queuer->_get_file_list( @dirs ); | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | # The code in this map is duplicated from MyCPAN::Indexer::Reporter::Base | ||||||||||||||||||||||||||||||||||||||||||
| 455 | # in get_report_filename. That method assumes it's getting a big data | ||||||||||||||||||||||||||||||||||||||||||
| 456 | # structure, so I need to refactor out this bit to _dist2report or | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # something. I'll get it to work here first. | ||||||||||||||||||||||||||||||||||||||||||
| 458 | my %dist_reports = map { | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ( my $basename = basename( $_ ) ) =~ s/\.(tgz|tar\.gz|zip)$//; | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $report_name = join '.', $basename, $self->get_report_file_extension; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ( $report_name, $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 462 | } @$dists; | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return \%dist_reports; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | sub _get_extra_reports | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_extra_reports: not called CC=4 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | return [] unless $self->get_config->exists( 'extra_reports_dir' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $dir = $self->get_config->extra_reports_dir; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | return [] unless defined $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $reporter_logger->debug( "Extra reports directory is [$dir]" ); | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $cwd = cwd(); | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $reporter_logger->debug( "Extra reports directory does not exist! Cwd is [$cwd]" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $glob = catfile( | |||||||||||||||||||||||||||||||||||||||||
| 482 | $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 483 | "*." . $self->get_report_file_extension | ||||||||||||||||||||||||||||||||||||||||||
| 484 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $reporter_logger->debug( "glob pattern is [$glob]" ); | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | my @reports = glob( $glob ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $reporter_logger->debug( "Got extra reports [@reports]" ); | |||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return \@reports; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =item create_index_files | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | Creates the F<02packages.details.txt.gz> and F<03modlist.txt.gz> | ||||||||||||||||||||||||||||||||||||||||||
| 496 | files. If there is a problem, it logs a fatal message and returns | ||||||||||||||||||||||||||||||||||||||||||
| 497 | nothing. If everything works, it returns true. | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | It initially creates the F<02packages.details.txt.gz> as a temporary | ||||||||||||||||||||||||||||||||||||||||||
| 500 | file. Before it moves it to its final name, it checks the file with | ||||||||||||||||||||||||||||||||||||||||||
| 501 | C<CPAN::PackageDetails::check_file> to ensure it is valid. If it | ||||||||||||||||||||||||||||||||||||||||||
| 502 | isn't, it stops the process. | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | sub create_index_files | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_index_files: called CC=12 SCAR=25.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 4 | my $index_dir = do { | |||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | my $d = $self->get_config->dpan_dir; | |||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | # there might be more than one if we pull from multiple sources | ||||||||||||||||||||||||||||||||||||||||||
| 513 | # so make the index in the first one. | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 4 | my $abs = rel2abs( $d ); | |||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | $abs =~ s/authors.id.*//; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 4 | catfile( $abs, 'modules' ); | |||||||||||||||||||||||||||||||||||||||||
| 517 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 4 | ▶ | mkpath( $index_dir ) unless -d $index_dir; # XXX | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 4 | my $_02packages_name = '02packages.details.txt.gz'; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 4 | my $packages_file = catfile( $index_dir, $_02packages_name ); | |||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 4 | my $package_details = $self->get_note( 'package_details' ); | |||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | ▶ | if( -e catfile( $index_dir, '.svn' ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | { | ||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $package_details->set_header( 'X-SVN-Id', '$Id$' ); | |||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | # inside write_file, the module writes to a temp file then renames | ||||||||||||||||||||||||||||||||||||||||||
| 531 | # it. It doesn't do any other checking. Should some of this be in | ||||||||||||||||||||||||||||||||||||||||||
| 532 | # there, though? | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | # before we start, ensure that there are some entries. check_files | ||||||||||||||||||||||||||||||||||||||||||
| 535 | # checks this too, but I want to die earlier with a better message | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 4 | my $count = $package_details->count; | |||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 4 | ▶ | unless( $count > 0 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | $collator_logger->fatal( "There are no entries to put into $_02packages_name!" ); | |||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | # now, write the file. Even though write_file writes to a temporary | ||||||||||||||||||||||||||||||||||||||||||
| 545 | # file first, that doesn't protect us from overwriting a good 02packages | ||||||||||||||||||||||||||||||||||||||||||
| 546 | # with a bad one at this level. | ||||||||||||||||||||||||||||||||||||||||||
| 547 | { # scope for $temp_file | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 3 | my $temp_file = "$packages_file-$$-trial"; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 3 | $collator_logger->info( "Writing $temp_file" ); | |||||||||||||||||||||||||||||||||||||||||
| 550 | 3 | $package_details->write_file( $temp_file ); | |||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | # We tell it to start in $index_dir, but that might have authors/id under it | ||||||||||||||||||||||||||||||||||||||||||
| 553 | # and that prefix won't show up in 02packages. That's a problem when we want | ||||||||||||||||||||||||||||||||||||||||||
| 554 | # to find packages and compare their paths. CPAN::PackageDetails might consider | ||||||||||||||||||||||||||||||||||||||||||
| 555 | # stripping authors/id | ||||||||||||||||||||||||||||||||||||||||||
| 556 | # | ||||||||||||||||||||||||||||||||||||||||||
| 557 | # Note: CPANPLUS always assumes authors/id, even for full paths. | ||||||||||||||||||||||||||||||||||||||||||
| 558 | 3 | my $dpan_dir = dirname( $index_dir ); | |||||||||||||||||||||||||||||||||||||||||
| 559 | 3 | my $dpan_authors_id = catfile( $dpan_dir, qw( authors id ) ); | |||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | # if there is an authors/id under the dpan_dir, let's give that path to | ||||||||||||||||||||||||||||||||||||||||||
| 562 | # check_file | ||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | ▶ | $dpan_dir = $dpan_authors_id if -d $dpan_authors_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 3 | $collator_logger->debug( "Using dpan_dir => $dpan_dir" ); | |||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | # Check the trial file for errors | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | ▶ | unless( $self->get_config->i_ignore_errors_at_my_peril ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | { | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 3 | $collator_logger->info( "Checking validity of $temp_file" ); | |||||||||||||||||||||||||||||||||||||||||
| 571 | 3 | my $at; | |||||||||||||||||||||||||||||||||||||||||
| 572 | 3 | ▶ | my $result = eval { $package_details->check_file( $temp_file, $dpan_dir ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | or $at = $@; | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 3 | ▶ | if( defined $at ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||
| 577 | # _interpret_check_file_error can nerf an error based | ||||||||||||||||||||||||||||||||||||||||||
| 578 | # on configuration. Maybe you don't care about a | ||||||||||||||||||||||||||||||||||||||||||
| 579 | # particular error. | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | my $error = $self->_interpret_check_file_error( $at ); | |||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | ▶ | if( defined $error ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | { | ||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | ▶ | unlink $temp_file unless $collator_logger->is_debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | ▶ | $collator_logger->logdie( "$temp_file has a problem and I have to abort:\n". | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | "Deleting file (unless you're debugging)\n" . | ||||||||||||||||||||||||||||||||||||||||||
| 587 | "$error" | ||||||||||||||||||||||||||||||||||||||||||
| 588 | ) if defined $error; | ||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | # if we are this far, 02packages must be okay | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 2 | ▶ | unless( rename( $temp_file => $packages_file ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | { | ||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | $collator_logger->fatal( "Could not rename $temp_file => $packages_file" ); | |||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | # there are no worries about 03modlist because it is just a stub. | ||||||||||||||||||||||||||||||||||||||||||
| 602 | # there are no real data in it. | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 1 | $collator_logger->info( 'Writing 03modlist.txt.gz' ); | |||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | $self->create_modlist( $index_dir ); | |||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | 1 | $collator_logger->info( 'Creating CHECKSUMS files' ); | |||||||||||||||||||||||||||||||||||||||||
| 607 | 1 | $self->create_checksums( $self->get_note( 'dirs_needing_checksums' ) ); | |||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 1 | $collator_logger->info( 'Updating mailrc and whois files' ); | |||||||||||||||||||||||||||||||||||||||||
| 610 | 1 | $self->update_whois; | |||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | sub _interpret_check_file_error | ||||||||||||||||||||||||||||||||||||||||||
| 616 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_interpret_check_file_error: called CC=6 SCAR=31.5
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | my( $self, $at ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | my $error_message = do { | |||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | ▶ | if( not ref $at ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | $at; | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | # eventually this will filter the missing files and still | ||||||||||||||||||||||||||||||||||||||||||
| 625 | # complain for the left over ones | ||||||||||||||||||||||||||||||||||||||||||
| 626 | elsif( exists $at->{missing_in_file} ) | ||||||||||||||||||||||||||||||||||||||||||
| 627 | { | ||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | if( $self->get_config->ignore_missing_dists ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 631 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 632 | "Some distributions in the repository do not show up in the file\n\t" . | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | join( "\n\t", @{ $at->{missing_in_file} } ) | |||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | # eventually this will filter the missing dists and still | ||||||||||||||||||||||||||||||||||||||||||
| 637 | # complain for the left over ones | ||||||||||||||||||||||||||||||||||||||||||
| 638 | elsif( exists $at->{missing_in_repo} ) | ||||||||||||||||||||||||||||||||||||||||||
| 639 | { | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if( $self->get_config->ignore_extra_dists ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 644 | "The file has distributions that do not appear in the repository\n\t" . | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | join( "\n\t", @{ $at->{missing_in_repo} } ) | |||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | else { 'Unknown error!' } | |||||||||||||||||||||||||||||||||||||||||
| 649 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | =item skip_package( PACKAGE ) | ||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | Returns true if the indexer should ignore PACKAGE. | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | By default, this skips the Perl special packages specified by the | ||||||||||||||||||||||||||||||||||||||||||
| 658 | ignore_packages configuration. By default, ignore packages is: | ||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | main | ||||||||||||||||||||||||||||||||||||||||||
| 661 | MY | ||||||||||||||||||||||||||||||||||||||||||
| 662 | MM | ||||||||||||||||||||||||||||||||||||||||||
| 663 | DB | ||||||||||||||||||||||||||||||||||||||||||
| 664 | bytes | ||||||||||||||||||||||||||||||||||||||||||
| 665 | DynaLoader | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | To set a different list, configure ignore_packages with a space | ||||||||||||||||||||||||||||||||||||||||||
| 668 | separated list of packages to ignore: | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | ignore_packages main Foo Bar::Baz Test | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | Note that this only ignores those exact packages. You can't configure | ||||||||||||||||||||||||||||||||||||||||||
| 673 | this with regex or wildcards (yet). | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | 3 | my $initialized = 0; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 3 | my %skip_packages; | |||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | sub _skip_package_initialized { $initialized } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_skip_package_initialized: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | sub _init_skip_package_from_config | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_skip_package_from_config: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my( $self, $Notes ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | %skip_packages = | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | map { $_, 1 } | |||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | grep { defined } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_config->ignore_packages || ''
MC/DC0%0/1
$self->get_config->ignore_packages || ''
$self->get_config->ignore_packages
Truth table0%0/2
A
A= $self->get_config->ignore_packages
| |||||||||||||||||||||||||||||||||||||||||||
| 690 | split /\s+/, | ||||||||||||||||||||||||||||||||||||||||||
| 691 | $self->get_config->ignore_packages || ''; | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $initialized = 1; | |||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | sub skip_package | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip_package: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | my( $self, $package ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | exists $skip_packages{ $package } | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | =item create_package_details | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | Not yet implemented. Otehr code needs to be refactored and show up | ||||||||||||||||||||||||||||||||||||||||||
| 707 | here. | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | sub create_package_details | ||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_package_details: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my( $self, $index_dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | =item create_modlist | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | If a modules/03modlist.data.gz does not already exist, this creates a | ||||||||||||||||||||||||||||||||||||||||||
| 722 | placeholder which defines the CPAN::Modulelist package and the method | ||||||||||||||||||||||||||||||||||||||||||
| 723 | C<data> in that package. The C<data> method returns an empty hash | ||||||||||||||||||||||||||||||||||||||||||
| 724 | reference. | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | sub create_modlist | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_modlist: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my( $self, $index_dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my $module_list_file = catfile( $index_dir, '03modlist.data.gz' ); | |||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $collator_logger->debug( "modules list file is [$module_list_file]"); | |||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | if( -e $module_list_file ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | { | ||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $collator_logger->debug( "File [$module_list_file] already exists!" ); | |||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my $fh = IO::Compress::Gzip->new( $module_list_file ); | |||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | print $fh <<"HERE"; | |||||||||||||||||||||||||||||||||||||||||
| 743 | File: 03modlist.data | ||||||||||||||||||||||||||||||||||||||||||
| 744 | Description: This a placeholder for CPAN.pm | ||||||||||||||||||||||||||||||||||||||||||
| 745 | Modcount: 0 | ||||||||||||||||||||||||||||||||||||||||||
| 746 | Written-By: Id: $0 | ||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | Date: @{ [ scalar localtime ] } | |||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | package CPAN::Modulelist; | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | sub data { {} } | ||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | 1; | ||||||||||||||||||||||||||||||||||||||||||
| 754 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | =item update_whois | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 00whois.xml 01mailrc.txt.gz | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | sub update_whois | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_whois: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my( $self, $index_dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | require MyCPAN::App::DPAN::CPANUtils; | |||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my $success = 0; | |||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | # no matter the situation, start over. I don't like this situation | ||||||||||||||||||||||||||||||||||||||||||
| 774 | # so much, but it's more expedient then parsing the xml file to look | ||||||||||||||||||||||||||||||||||||||||||
| 775 | # for missing users | ||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | unlink map { my $f = catfile( | |||||||||||||||||||||||||||||||||||||||||
| 777 | $self->get_config->dpan_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 778 | 'authors', | ||||||||||||||||||||||||||||||||||||||||||
| 779 | MyCPAN::App::DPAN::CPANUtils->$_() | ||||||||||||||||||||||||||||||||||||||||||
| 780 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | $f; | |||||||||||||||||||||||||||||||||||||||||
| 783 | } qw( mailrc_filename whois_filename ); | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | if( $self->get_config->use_real_whois ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | { | ||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my $result = MyCPAN::App::DPAN::CPANUtils->pull_latest_whois( | |||||||||||||||||||||||||||||||||||||||||
| 788 | $self->get_config->dpan_dir, $collator_logger | ||||||||||||||||||||||||||||||||||||||||||
| 789 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | if( $result == 2 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | { | ||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | $success = 1; | |||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | else | ||||||||||||||||||||||||||||||||||||||||||
| 795 | { | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | warn "Could not pull whois files from CPAN\n"; | |||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | unless( $success ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | { | ||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | MyCPAN::App::DPAN::CPANUtils->make_fake_whois( | |||||||||||||||||||||||||||||||||||||||||
| 805 | $self->get_config->dpan_dir, $collator_logger | ||||||||||||||||||||||||||||||||||||||||||
| 806 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | my %authors = $self->get_all_authors; | |||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | $self->update_01mailrc( \%authors ); | |||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $self->update_00whois( \%authors ); | |||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | =item get_all_authors | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | Walk the repository and extract all of the actual authors in the repo. | ||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | sub get_all_authors | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_authors: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $author_map = do { | |||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my $file = $self->get_config->author_map; | |||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | if( defined $file ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | { | ||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my $hash; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | unless( -e $file ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | { | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | $collator_logger->error( "Author map file [$file] does not exist" ); | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | {}; | |||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||
| 838 | elsif( open my($fh), '<:utf8', $file ) | ||||||||||||||||||||||||||||||||||||||||||
| 839 | { | ||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | while( <$fh> ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | { | ||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | my( $pause_id, $full_name ) = split /\s+/, $_, 2; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | $hash->{uc $pause_id} = $full_name || $self->get_config->pause_full_name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$full_name || $self->get_config->pause_full_name
MC/DC0%0/2
$full_name || $self->get_config->pause_full_name
$full_name
$self->get_config->pause_full_name
Truth table0%0/3
A || B
A= $full_nameB= $self->get_config->pause_full_name
| |||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | $hash; | |||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | else | ||||||||||||||||||||||||||||||||||||||||||
| 849 | { | ||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | $collator_logger->error( "Could not open author map file [$file]: $!" ); | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | {}; | |||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | else { {} } | |||||||||||||||||||||||||||||||||||||||||
| 855 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $old_cwd = cwd(); | |||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | my $id_dir = catfile( $self->get_config->dpan_dir, 'authors', 'id' ); | |||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | chdir $id_dir; | |||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | my @authors_in_repo = map { basename( $_ ) } glob( "*/*/*" ); | |||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | chdir $old_cwd; | |||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | my %authors = map { | ||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $_, | |||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | ▶ | $author_map->{$_} || $self->get_config->pause_full_name | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$author_map->{$_} || $self->get_config->pause_full_name
MC/DC0%0/2
$author_map->{$_} || $self->get_config->pause_full_name
$author_map->{$_}
$self->get_config->pause_full_name
Truth table0%0/3
A || B
A= $author_map->{$_}B= $self->get_config->pause_full_name
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | } @authors_in_repo; | ||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | %authors; | |||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | =item update_01mailrc | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | Ensure that every PAUSE ID that's in the repository shows up in the | ||||||||||||||||||||||||||||||||||||||||||
| 875 | F<authors/01mailrc.txt.gz> file. Any new IDs show up with the name | ||||||||||||||||||||||||||||||||||||||||||
| 876 | from the C<pause_full_name> configuration. | ||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||
| 878 | TO DO: offer a way to configure multiple new IDs | ||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||
| 880 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | sub update_01mailrc | ||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_01mailrc: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my( $self, $authors ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | require IO::Uncompress::Gunzip; | |||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | require IO::Compress::Gzip; | |||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $d = $self->get_config->dpan_dir; | |||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my $mailrc_fh = do { | |||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | my $file = catfile( $d, 'authors', '01mailrc.txt.gz' ); | |||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | IO::Uncompress::Gunzip->new( $file ) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
'IO::Uncompress::Gunzip'->new($file) || do {
carp("Could not open ${file}: $IO::Uncompress::Gunzip::GunzipError\n");
undef
}
MC/DC0%0/2
'IO::Uncompress::Gunzip'->new($file) || do {
carp("Could not open ${file}: $IO::Uncompress::Gunzip::GunzipError\n");
undef
}
'IO::Uncompress::Gunzip'->new($file)
do {
carp("Could not open ${file}: $IO::Uncompress::Gunzip::GunzipError\n");
undef
}
Truth table0%0/3
A || B
A= 'IO::Uncompress::Gunzip'->new($file)B= do {
carp("Could not open ${file}: $IO::Uncompress::Gunzip::GunzipError\n");
undef
}
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | carp "Could not open $file: $IO::Uncompress::Gunzip::GunzipError\n"; | |||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 895 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 896 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | my $new_mailrc_fh = do { | |||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $file = catfile( $d, 'authors', 'new-01mailrc.txt.gz' ); | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | my $z = IO::Compress::Gzip->new( $file ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
(my $z = 'IO::Compress::Gzip'->new($file)) || carp("gzip failed: $IO::Compress::Gzip::GzipError\n")
MC/DC0%0/2
(my $z = 'IO::Compress::Gzip'->new($file)) || carp("gzip failed: $IO::Compress::Gzip::GzipError\n")
(my $z = 'IO::Compress::Gzip'->new($file))
carp("gzip failed: $IO::Compress::Gzip::GzipError\n")
Truth table0%0/3
A || B
A= (my $z = 'IO::Compress::Gzip'->new($file))B= carp("gzip failed: $IO::Compress::Gzip::GzipError\n")
| |||||||||||||||||||||||||||||||||||||||||||
| 901 | or carp "gzip failed: $IO::Compress::Gzip::GzipError\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 902 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | while( <$mailrc_fh> ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | { | ||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | my( $pause_id, $name, $email ) = m/^ | |||||||||||||||||||||||||||||||||||||||||
| 907 | alias \s+ | ||||||||||||||||||||||||||||||||||||||||||
| 908 | (\S+) \s+ | ||||||||||||||||||||||||||||||||||||||||||
| 909 | " | ||||||||||||||||||||||||||||||||||||||||||
| 910 | (.*) \s+ | ||||||||||||||||||||||||||||||||||||||||||
| 911 | < | ||||||||||||||||||||||||||||||||||||||||||
| 912 | (.*?) | ||||||||||||||||||||||||||||||||||||||||||
| 913 | > | ||||||||||||||||||||||||||||||||||||||||||
| 914 | "/x; | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | delete $authors->{$pause_id}; | |||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | print { $new_mailrc_fh } $_; | |||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | foreach my $author ( keys %$authors ) | |||||||||||||||||||||||||||||||||||||||||
| 921 | { | ||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | print { $new_mailrc_fh } qq|alias $author "$authors->{$author}"\n|; | |||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | close $new_mailrc_fh; | |||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | rename | |||||||||||||||||||||||||||||||||||||||||
| 928 | catfile( $d, 'authors', 'new-01mailrc.txt.gz' ), | ||||||||||||||||||||||||||||||||||||||||||
| 929 | catfile( $d, 'authors', '01mailrc.txt.gz' ); | ||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | =item update_00whois | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | Ensure that every PAUSE ID that's in the repository shows up in the | ||||||||||||||||||||||||||||||||||||||||||
| 935 | F<authors/00whois.xml> file. Any new IDs show up with the name | ||||||||||||||||||||||||||||||||||||||||||
| 936 | from the C<pause_full_name> configuration. | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | sub update_00whois | ||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_00whois: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | my( $self, $authors ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my $d = $self->get_config->dpan_dir; | |||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $file = catfile( $d, 'authors', '00whois.xml' ); | |||||||||||||||||||||||||||||||||||||||||
| 947 | open my( $whois_fh ), "+<:utf8", $file | ||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | carp "Could not open $file: $!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 951 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my $file_end = "</cpan-whois>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | seek $whois_fh, - length( $file_end ), 2; | |||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | foreach my $author ( keys %$authors ) | |||||||||||||||||||||||||||||||||||||||||
| 957 | { | ||||||||||||||||||||||||||||||||||||||||||
| 958 | my( $name, $email ) = # XXX need to encode | ||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | map { my $x = $_; | |||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $x =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | $x =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $x =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $x =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | $x; | |||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | } $authors->{$author} =~ m/\s*(.+)\s+<(.+?)>/; | |||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | print { $whois_fh } <<"AUTHOR"; | |||||||||||||||||||||||||||||||||||||||||
| 968 | <cpanid> | ||||||||||||||||||||||||||||||||||||||||||
| 969 | <id>$author</id> | ||||||||||||||||||||||||||||||||||||||||||
| 970 | <type>author</type> | ||||||||||||||||||||||||||||||||||||||||||
| 971 | <fullname>$name</fullname> | ||||||||||||||||||||||||||||||||||||||||||
| 972 | <email>$email</email> | ||||||||||||||||||||||||||||||||||||||||||
| 973 | </cpanid> | ||||||||||||||||||||||||||||||||||||||||||
| 974 | AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | print { $whois_fh } $file_end; | |||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | close $whois_fh; | |||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | =item create_checksums | ||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | Creates the CHECKSUMS file that goes in each author directory in CPAN. | ||||||||||||||||||||||||||||||||||||||||||
| 987 | This is mostly a wrapper around CPAN::Checksums since that already handles | ||||||||||||||||||||||||||||||||||||||||||
| 988 | updating an entire tree. We just do a little logging. | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | sub create_checksums | ||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_checksums: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my( $self, $dirs ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | require CPAN::Checksums; | |||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | foreach my $dir ( @$dirs ) | |||||||||||||||||||||||||||||||||||||||||
| 998 | { | ||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | my $rc = eval{ CPAN::Checksums::updatedir( $dir ) }; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | $reporter_logger->error( "Couldn't create CHECKSUMS for $dir: $@" ) if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | $reporter_logger->info( | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | do { | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | if( $rc == 1 ) { "Valid CHECKSUMS file is already present" } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | elsif( $rc == 2 ) { "Wrote new CHECKSUMS file in $dir" } | |||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | else { "updatedir unexpectedly returned an error" } | |||||||||||||||||||||||||||||||||||||||||
| 1006 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||
| 1010 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | =head1 TO DO | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | How much time do you have? | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | =head1 SOURCE AVAILABILITY | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||
| 1018 | This code is in Github: | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | git://github.com/briandfoy/mycpan-app-dpan.git | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||
| 1024 | brian d foy, C<< <bdfoy@cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | Copyright © 2009-2018, brian d foy <bdfoy@cpan.org>. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | You may redistribute this under the terms of the Artistic License 2.0. | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||