File Coverage

blib/lib/MyCPAN/Indexer/Queue/ErrorReports.pm
Criterion Covered Total %
statement 22 43 51.1
branch 0 2 0.0
condition n/a
subroutine 8 9 88.8
pod n/a
total 30 54 55.5


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