File Coverage

blib/lib/MyCPAN/Indexer/Worker/JustShowDist.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package MyCPAN::Indexer::Worker::JustShowDist;
2 1     1   1734 use strict;
  1         3  
  1         44  
3 1     1   6 use warnings;
  1         2  
  1         35  
4              
5 1     1   7 use parent qw(MyCPAN::Indexer::Worker);
  1         1  
  1         9  
6             use vars qw($VERSION $logger);
7             $VERSION = '1.28_12';
8              
9             use File::Basename qw(basename);
10             use Log::Log4perl;
11              
12             =head1 NAME
13              
14             MyCPAN::Indexer::Worker::JustShowDist - Do nothing except show what the task is
15              
16             =head1 SYNOPSIS
17              
18             Use this in backpan_indexer.pl by specifying it as the queue class:
19              
20             # in backpan_indexer.config
21             worker_class MyCPAN::Indexer::Worker::JustShowDist
22              
23             =head1 DESCRIPTION
24              
25             This class takes a distribution and analyses it. This is what the dispatcher
26             hands a disribution to for the actual indexing.
27              
28             =head2 Methods
29              
30             =over 4
31              
32             =item get_task
33              
34             C sets the C key in the notes. The
35             value is a code reference that takes a distribution path as its only
36             argument and indexes that distribution.
37              
38             See L for details about what C expects
39             and should do.
40              
41             =cut
42              
43             BEGIN {
44             $logger = Log::Log4perl->get_logger( 'Worker' );
45             }
46              
47             sub get_task
48             {
49             my( $self ) = @_;
50              
51             my $config = $self->get_config;
52              
53             my $indexer = $self->get_coordinator->get_component( 'indexer' );
54             my $coordinator = $self->get_coordinator;
55              
56             $logger->debug( "Worker class is " . __PACKAGE__ );
57             $logger->debug( "Indexer class is " . $indexer->class );
58              
59             my $child_task = sub {
60             my $dist = shift;
61              
62             my $dist_basename = basename( $dist );
63              
64             my $basename = $coordinator->get_reporter->check_for_previous_successful_result( $dist );
65              
66             my $previous_error_basename = $coordinator->get_reporter->check_for_previous_error_result( $dist ) || '';
67             $logger->debug( "Found error report for $dist_basename" ) if $previous_error_basename;
68              
69             if( $previous_error_basename and ! $config->retry_errors )
70             {
71             $logger->debug( "By config, will NOT retry $dist_basename" ) if $previous_error_basename;
72             }
73             elsif( $previous_error_basename and $config->retry_errors )
74             {
75             $logger->debug( "By config, will retry $dist_basename" ) if $previous_error_basename;
76             }
77              
78             my $info = bless {
79             dist_info => {
80             dist_path => $dist,
81             dist_basename => $dist_basename
82             },
83             skipped => 1,
84             }, $indexer->class unless $basename;
85              
86             $info;
87             };
88              
89             $coordinator->set_note( 'child_task', $child_task );
90              
91             1;
92             }
93              
94             =back
95              
96             =head1 SEE ALSO
97              
98             MyCPAN::Indexer::Worker, MyCPAN::Indexer::Tutorial
99              
100             =head1 SOURCE AVAILABILITY
101              
102             This code is in Github:
103              
104             git://github.com/briandfoy/mycpan-indexer.git
105              
106             =head1 AUTHOR
107              
108             brian d foy, C<< >>
109              
110             =head1 COPYRIGHT AND LICENSE
111              
112             Copyright (c) 2010-2013, brian d foy, All Rights Reserved.
113              
114             You may redistribute this under the same terms as Perl itself.
115              
116             =cut
117              
118             1;