| 1 | package MyCPAN::Indexer::Queue::ErrorReports; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use parent qw(MyCPAN::Indexer::Queue); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use vars qw($VERSION $logger); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | $VERSION = '1.282'; | |||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use File::Find; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Log::Log4perl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use YAML qw(LoadFile); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | $logger = Log::Log4perl->get_logger( 'Queue' ); | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | =encoding utf8 | ||||||||||
| 18 | |||||||||||
| 19 | =head1 NAME | ||||||||||
| 20 | |||||||||||
| 21 | MyCPAN::Indexer::Queue::ErrorReports - Try to index distributions with error reports | ||||||||||
| 22 | |||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||
| 24 | |||||||||||
| 25 | Use this in backpan_indexer.pl by specifying it as the queue class: | ||||||||||
| 26 | |||||||||||
| 27 | # in backpan_indexer.config | ||||||||||
| 28 | queue_class MyCPAN::Indexer::Queue::ErrorReports | ||||||||||
| 29 | |||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||
| 31 | |||||||||||
| 32 | This class returns a list of Perl distributions for the BackPAN | ||||||||||
| 33 | indexer to process. It selects the distributions that had previous | ||||||||||
| 34 | indexing errors by extracting the distribution path from the error | ||||||||||
| 35 | report. If the distribution isn't in the same place it was during | ||||||||||
| 36 | the original indexing, it won't be in the queue. | ||||||||||
| 37 | |||||||||||
| 38 | =head2 Methods | ||||||||||
| 39 | |||||||||||
| 40 | =over 4 | ||||||||||
| 41 | |||||||||||
| 42 | =item get_queue | ||||||||||
| 43 | |||||||||||
| 44 | C<get_queue> sets the key C<queue> in C<$Notes> hash reference. It | ||||||||||
| 45 | finds all of the tarballs or zip archives in under the directories | ||||||||||
| 46 | named in C<backpan_dir> and C<merge_dirs> in the configuration. | ||||||||||
| 47 | |||||||||||
| 48 | It specifically skips files that end in C<.txt.gz> or C<.data.gz> | ||||||||||
| 49 | since PAUSE creates those meta files near the actual module | ||||||||||
| 50 | installations. | ||||||||||
| 51 | |||||||||||
| 52 | If the C<organize_dists> configuration value is true, it also copies | ||||||||||
| 53 | any distributions it finds into a PAUSE-like structure using the | ||||||||||
| 54 | value of the C<pause_id> configuration to create the path. | ||||||||||
| 55 | |||||||||||
| 56 | =cut | ||||||||||
| 57 | |||||||||||
| 58 | sub _get_file_list | ||||||||||
| 59 | 0 | ▶ | { | ||||||||
|
Subroutine
_get_file_list: not called CC=3 SCAR=24.8
| |||||||||||
| 60 | 0 | my( $self ) = @_; | |||||||||
| 61 | |||||||||||
| 62 | 0 | my @dirs = $self->get_coordinator->get_component( 'reporter' )->get_error_report_dir; | |||||||||
| 63 | |||||||||||
| 64 | 0 | $logger->debug( "Taking dists from [@dirs]" ); | |||||||||
| 65 | 0 | my( $wanted, $reporter ) = | |||||||||
| 66 | File::Find::Closures::find_by_regex( qr/\.(?:yml)$/ ); | ||||||||||
| 67 | |||||||||||
| 68 | 0 | $logger->debug( "Running File::Find" ); | |||||||||
| 69 | 0 | find( $wanted, @dirs ); | |||||||||
| 70 | |||||||||||
| 71 | 0 | my @files = $reporter->(); | |||||||||
| 72 | 0 | $logger->debug( "Found " . @files . " error reports" ); | |||||||||
| 73 | |||||||||||
| 74 | 0 | my @queue; | |||||||||
| 75 | 0 | foreach my $file ( @files ) | |||||||||
| 76 | { | ||||||||||
| 77 | 0 | $logger->debug( "Trying to read $file" ); | |||||||||
| 78 | 0 | my $yaml = LoadFile( $file ); | |||||||||
| 79 | 0 | my $dist_file = $yaml->{dist_info}{dist_file}; | |||||||||
| 80 | 0 | $logger->debug( "Dist file is $dist_file" ); | |||||||||
| 81 | 0 | ▶ | if( -e $dist_file ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | { | ||||||||||
| 83 | 0 | push @queue, $dist_file; | |||||||||
| 84 | } | ||||||||||
| 85 | else | ||||||||||
| 86 | { | ||||||||||
| 87 | 0 | $logger->error( "Could not find $dist_file" ); | |||||||||
| 88 | } | ||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 0 | $" = "\n"; | |||||||||
| 92 | 0 | print "@queue\n"; exit; | |||||||||
| 93 | 0 | return \@queue; | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 1 | 1; | |||||||||
| 97 | |||||||||||
| 98 | =back | ||||||||||
| 99 | |||||||||||
| 100 | |||||||||||
| 101 | =head1 SEE ALSO | ||||||||||
| 102 | |||||||||||
| 103 | MyCPAN::Indexer, MyCPAN::Indexer::Tutorial, MyCPAN::Indexer::Queue | ||||||||||
| 104 | |||||||||||
| 105 | =head1 SOURCE AVAILABILITY | ||||||||||
| 106 | |||||||||||
| 107 | This code is in Github: | ||||||||||
| 108 | |||||||||||
| 109 | git://github.com/briandfoy/mycpan-indexer.git | ||||||||||
| 110 | |||||||||||
| 111 | =head1 AUTHOR | ||||||||||
| 112 | |||||||||||
| 113 | brian d foy, C<< <bdfoy@cpan.org> >> | ||||||||||
| 114 | |||||||||||
| 115 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 116 | |||||||||||
| 117 | Copyright © 2008-2018, brian d foy <bdfoy@cpan.org>. All rights reserved. | ||||||||||
| 118 | |||||||||||
| 119 | You may redistribute this under the terms of the Artistic License 2.0. | ||||||||||
| 120 | |||||||||||
| 121 | =cut | ||||||||||