| 1 | package MyCPAN::Indexer::Interface::ShowDist; | ||||||||||||||||||||||
| 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 Log::Log4perl; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 1 | ▶ | use parent qw(MyCPAN::Indexer::Component); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 1 | ▶ | use vars qw($VERSION $logger); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 1 | $VERSION = '1.282'; | |||||||||||||||||||||
| 10 | |||||||||||||||||||||||
| 11 | =encoding utf8 | ||||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||
| 14 | |||||||||||||||||||||||
| 15 | MyCPAN::Indexer::Interface::ShowDist - Show dists as MyCPAN processes them | ||||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | Use this in backpan_indexer.pl by specifying it as the interface class: | ||||||||||||||||||||||
| 20 | |||||||||||||||||||||||
| 21 | # in backpan_indexer.config | ||||||||||||||||||||||
| 22 | interface_class MyCPAN::Indexer::Interface::ShowDist | ||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||
| 25 | |||||||||||||||||||||||
| 26 | This class presents the information as the indexer runs, using plain text. | ||||||||||||||||||||||
| 27 | |||||||||||||||||||||||
| 28 | =head2 Methods | ||||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | =over 4 | ||||||||||||||||||||||
| 31 | |||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | 1 | ▶ | BEGIN { | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 35 | 1 | $logger = Log::Log4perl->get_logger( 'Interface' ); | |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||
| 37 | |||||||||||||||||||||||
| 38 | =item component_type | ||||||||||||||||||||||
| 39 | |||||||||||||||||||||||
| 40 | This is an interface type | ||||||||||||||||||||||
| 41 | |||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 0 | ▶ | sub component_type { $_[0]->interface_type } | ||||||||||||||||||||
|
Subroutine
component_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | =item do_interface() | ||||||||||||||||||||||
| 47 | |||||||||||||||||||||||
| 48 | |||||||||||||||||||||||
| 49 | =cut | ||||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | sub do_interface | ||||||||||||||||||||||
| 52 | 0 | ▶ | { | ||||||||||||||||||||
|
Subroutine
do_interface: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||
| 53 | 0 | my( $self ) = @_; | |||||||||||||||||||||
| 54 | 0 | $logger->debug( "Calling do_interface" ); | |||||||||||||||||||||
| 55 | |||||||||||||||||||||||
| 56 | 0 | my $config = $self->get_config; | |||||||||||||||||||||
| 57 | |||||||||||||||||||||||
| 58 | 0 | my $indexer = $self->get_coordinator->get_component( 'indexer' ); | |||||||||||||||||||||
| 59 | |||||||||||||||||||||||
| 60 | 0 | print join( " ", | |||||||||||||||||||||
| 61 | $config->indexer_class, | ||||||||||||||||||||||
| 62 | $indexer->VERSION | ||||||||||||||||||||||
| 63 | ), | ||||||||||||||||||||||
| 64 | "\n"; | ||||||||||||||||||||||
| 65 | |||||||||||||||||||||||
| 66 | 0 | my $total = @{ $self->get_note('queue') }; | |||||||||||||||||||||
| 67 | 0 | ▶ | my $width = eval { int( log($total)/log(10) + 1 ) } || 5; | ||||||||||||||||||||
|
Condition0%0/2
eval {
do {
int log($total) / 2.3025850929940459011 + 1
}
} || 5
MC/DC0%0/1
eval {
do {
int log($total) / 2.3025850929940459011 + 1
}
} || 5
eval {
do {
int log($total) / 2.3025850929940459011 + 1
}
}
Truth table0%0/2
A
A= eval {
do {
int log($total) / 2.3025850929940459011 + 1
}
}
| |||||||||||||||||||||||
| 68 | 0 | print "Processing $total distributions\n"; | |||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 0 | my $count = 0; | |||||||||||||||||||||
| 71 | 0 | while( 1 ) | |||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||
| 73 | 0 | ▶ | last if $self->get_note('Finished'); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 74 | |||||||||||||||||||||||
| 75 | 0 | local $| = 1; | |||||||||||||||||||||
| 76 | |||||||||||||||||||||||
| 77 | 0 | my $info = $self->get_note('interface_callback')->(); | |||||||||||||||||||||
| 78 | 0 | my $status = do { | |||||||||||||||||||||
| 79 | 0 | ▶ | if( exists $info->{skipped} ) { 'skipped' } | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 80 | 0 | elsif( exists $info->{skip_error} ) { 'previous error (skipped)' } | |||||||||||||||||||||
| 81 | 0 | elsif( exists $info->{run_info}{error} ) { $self->get_error($info) } | |||||||||||||||||||||
| 82 | 0 | elsif( exists $info->{run_info}{completed} ) { 'completed' } | |||||||||||||||||||||
| 83 | 0 | else { 'unknown' } | |||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||
| 85 | |||||||||||||||||||||||
| 86 | printf "[%*d/%d] %s ---> %s\n", $width, ++$count, $total, | ||||||||||||||||||||||
| 87 | 0 | ▶ | $info->{dist_info}{dist_basename} || '(unknown dist???)', | ||||||||||||||||||||
|
Condition0%0/2
$info->{'dist_info'}{'dist_basename'} || '(unknown dist???)'
MC/DC0%0/1
$info->{'dist_info'}{'dist_basename'} || '(unknown dist???)'
$info->{'dist_info'}{'dist_basename'}
Truth table0%0/2
A
A= $info->{'dist_info'}{'dist_basename'}
| |||||||||||||||||||||||
| 88 | $status; | ||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||
| 90 | |||||||||||||||||||||||
| 91 | 0 | my $collator = $self->get_coordinator->get_note( 'collator' ); | |||||||||||||||||||||
| 92 | 0 | $collator->(); | |||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | 1 | ▶ | BEGIN { | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 96 | 1 | my @patterns = ( | |||||||||||||||||||||
| 97 | qr/Malformed UTF-8/p, | ||||||||||||||||||||||
| 98 | qr/No child process/p, | ||||||||||||||||||||||
| 99 | qr/Alarm rang/p, | ||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||
| 101 | |||||||||||||||||||||||
| 102 | =item get_error | ||||||||||||||||||||||
| 103 | |||||||||||||||||||||||
| 104 | Returns the error message that most likely was the big problem. | ||||||||||||||||||||||
| 105 | |||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||
| 107 | |||||||||||||||||||||||
| 108 | sub get_error | ||||||||||||||||||||||
| 109 | 0 | ▶ | { | ||||||||||||||||||||
|
Subroutine
get_error: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||
| 110 | 0 | my( $self, $info ) = @_; | |||||||||||||||||||||
| 111 | |||||||||||||||||||||||
| 112 | 0 | my $r = $info->{run_info}; | |||||||||||||||||||||
| 113 | |||||||||||||||||||||||
| 114 | 0 | ▶ | my @errors = map { $r->{$_} || () } qw(error fatal_error); | ||||||||||||||||||||
|
Condition0%0/3
$r->{$_} || ()
MC/DC0%0/2
$r->{$_} || ()
$r->{$_}
()
Truth table0%0/3
A || B
A= $r->{$_}B= ()
| |||||||||||||||||||||||
| 115 | |||||||||||||||||||||||
| 116 | 0 | foreach my $pattern ( @patterns ) | |||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||
| 118 | 0 | ▶ | return ${^MATCH} if $errors[0] =~ m/$pattern/p; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||
| 120 | |||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||
| 123 | |||||||||||||||||||||||
| 124 | =back | ||||||||||||||||||||||
| 125 | |||||||||||||||||||||||
| 126 | =head1 SEE ALSO | ||||||||||||||||||||||
| 127 | |||||||||||||||||||||||
| 128 | MyCPAN::Indexer | ||||||||||||||||||||||
| 129 | |||||||||||||||||||||||
| 130 | =head1 SOURCE AVAILABILITY | ||||||||||||||||||||||
| 131 | |||||||||||||||||||||||
| 132 | This code is in Github: | ||||||||||||||||||||||
| 133 | |||||||||||||||||||||||
| 134 | git://github.com/briandfoy/mycpan-indexer.git | ||||||||||||||||||||||
| 135 | |||||||||||||||||||||||
| 136 | =head1 AUTHOR | ||||||||||||||||||||||
| 137 | |||||||||||||||||||||||
| 138 | brian d foy, C<< <bdfoy@cpan.org> >> | ||||||||||||||||||||||
| 139 | |||||||||||||||||||||||
| 140 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||
| 141 | |||||||||||||||||||||||
| 142 | Copyright © 2010-2018, brian d foy <bdfoy@cpan.org>. All rights reserved. | ||||||||||||||||||||||
| 143 | |||||||||||||||||||||||
| 144 | You may redistribute this under the terms of the Artistic License 2.0. | ||||||||||||||||||||||
| 145 | |||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||
| 147 | |||||||||||||||||||||||
| 148 | 1 | 1; | |||||||||||||||||||||