Indexer/Worker/JustShowDist.pm

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