Indexer/Interface/Text.pm

filter: Statementstmt 32.1% 18 / 56 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 6 / 12 Podpod 100% 5 / 5 totaltotal 30.8% 29 / 94 CC 10 SCAR 39.7
CC
10
Cov
24%
do_interface
110.0
component_type
2.0
__ANON__
2.0
CRAP 53.1
↑ Summary Indexer/Interface/ShowDist.pm »
1 package MyCPAN::Indexer::Interface::Text;
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::Text - Present the run info as plain text
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::Text
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 =item do_interface( $Notes )
33  
34  
35 =cut
36  
37 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 $logger = Log::Log4perl->get_logger( 'Interface' );
39 }
40  
41 =item component_type
42  
43 This is an interface type
44  
45 =cut
46  
47 0 ▶sub component_type { $_[0]->interface_type }
Subroutine component_type: not called CC=1 SCAR=6.9
Pod documented
48  
49 =item do_interface
50  
51 =cut
52  
53 sub do_interface
54 0 ▶ {
Subroutine do_interface: not called CC=10 SCAR=47.0
Pod documented
55 0 my( $self ) = @_;
56 0 $logger->debug( "Calling do_interface" );
57  
58 0 my $config = $self->get_config;
59  
60 0 my $i = $config->indexer_class;
61 0 eval "require $i; 1";
62  
63 0 print join( " ",
64 $config->indexer_class,
65 $config->indexer_class->VERSION
66 ),
67 "\n";
68  
69 0 my $total = @{ $self->get_note('queue') };
70 0 print "Processing $total distributions\n";
71 0 print "One + = 1 distribution\n";
72  
73 0 my $count = 0;
74 0 my $timer = time;
75  
76 0 while( 1 )
77 {
78 0 ▶ last if $self->get_note('Finished');
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_note("Finished") 0 0 0
79  
80 0 ▶ unless( $count++ % 70 )
Branch: 1 branch
BranchTrueFalseTotal
unless ($count++ % 70) 0 0 0
81 {
82 0 my $elapsed = time - $timer;
83 0 $timer = time;
84  
85 0 ▶ print " $elapsed" unless $count < 70;
Branch: 1 branch
BranchTrueFalseTotal
unless $count < 70 0 0 0
86 0 printf "\n[%6d/%6d]", $count, $total;
87 }
88  
89 0 local $| = 1;
90  
91 0 my $info = $self->get_note('interface_callback')->();
92  
93 0 my $method = do {
94 0 ▶ if( not defined $info or ref $info ne ref {} ) { 'error_tick' }
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $info or ref $info ne ref {}) { } 0 0 0
elsif ($info->{'completed'}) { } 0 0 0
elsif ($info->{'skipped'}) { } 0 0 0
elsif (grep {exists $info->{$_};} 'error', 'fatal_error') { } 0 0 0
Condition0%0/3
not defined $info or ref $info ne ref {}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $info or ref $info ne ref {}
not defined $info ref $info ne ref {}
Truth table0%0/3
not(A) or B
A= not defined $infoB= ref $info ne ref {}
ABresult
1X1
011
000
95 0 elsif( $info->{'completed'} ) { 'success_tick' }
96 0 elsif( $info->{'skipped'} ) { 'skip_tick' }
97 0 elsif( grep { exists $info->{$_} } qw( error fatal_error ) ) { 'error_tick' }
98 0 else { 'error_tick' }
99 };
100  
101 # if we fork, how does the interface class know what happened?
102 0 $method = 'success_tick';
103  
104 0 print $self->$method();
105  
106 }
107 0 print "\n";
108  
109 0 my $collator = $self->get_coordinator->get_note( 'collator' );
110 0 ▶ $collator->() if ref $collator eq ref sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if ref $collator eq ref sub { } 0 0 0
111 }
112  
113 =item skip_tick
114  
115 =item success_tick
116  
117 =item error_tick
118  
119 Return a grapheme to represent what just happened.
120  
121 =cut
122  
123 0 ▶sub skip_tick { '.' }
Subroutine skip_tick: not called CC=1 SCAR=6.9
Pod documented
124  
125 0 ▶sub success_tick { '+' }
Subroutine success_tick: not called CC=1 SCAR=6.9
Pod documented
126  
127 0 ▶sub error_tick { '!' }
Subroutine error_tick: not called CC=1 SCAR=6.9
Pod documented
128  
129  
130 =back
131  
132 =head1 SEE ALSO
133  
134 MyCPAN::Indexer
135  
136 =head1 SOURCE AVAILABILITY
137  
138 This code is in Github:
139  
140 git://github.com/briandfoy/mycpan-indexer.git
141  
142 =head1 AUTHOR
143  
144 brian d foy, C<< <bdfoy@cpan.org> >>
145  
146 =head1 COPYRIGHT AND LICENSE
147  
148 Copyright © 2008-2018, brian d foy <bdfoy@cpan.org>. All rights reserved.
149  
150 You may redistribute this under the terms of the Artistic License 2.0.
151  
152 =cut
153  
154 1 1;
↑ Summary Indexer/Interface/ShowDist.pm »