File Coverage

blib/lib/App/perlfind.pm
Criterion Covered Total %
statement 19 37 51.3
branch 0 10 0.0
condition n/a
subroutine 6 8 75.0
pod 1 3 33.3
total 26 58 44.8


line stmt bran cond sub pod time code
1             package App::perlfind;
2 10     10   662484 use strict;
  10         31  
  10         423  
3 10     10   61 use warnings;
  10         21  
  10         320  
4 10     10   6428 use Class::Trigger;
  10         15374  
  10         136  
5 10     10   6383 use Module::Pluggable require => 1;
  10         105241  
  10         74  
6             __PACKAGE__->plugins; # 'require' them
7 10     10   7518 use parent qw(Pod::Cpandoc);
  10         3033  
  10         72  
8             our $VERSION = '2.07';
9              
10             # separate function so it's testable
11             sub find_matches {
12 24     24 1 34396 my $word = shift;
13 24         36 my @matches;
14 24         112 __PACKAGE__->call_trigger('matches.add', \$word, \@matches);
15 24         313 return ($word, @matches);
16             }
17              
18             sub grand_search_init {
19 0     0 0   my ($self, $pages, @found) = @_;
20 0           my (@new_pages, $done_opt_f, $done_opt_v);
21 0           for my $page (@$pages) {
22              
23             # $page is a search term, see Pod::Perldoc
24 0           my @matches;
25 0           ($page, @matches) = find_matches($page);
26              
27             # If perlfunc or perlvar are indicated, set options as though
28             # -f or -v were given, respectively, so Pod::Perldoc will only
29             # show the relevant part of that document.
30 0 0         if (grep { $_ eq 'perlfunc' } @matches) {
  0            
31 0 0         $self->opt_f_with($page) unless $done_opt_v++;
32             }
33 0 0         if (grep { $_ eq 'perlvar' } @matches) {
  0            
34 0 0         $self->opt_v_with($page) unless $done_opt_f++;
35             }
36 0 0         if (@matches) {
37 0           push @new_pages, @matches;
38             } else {
39              
40             # pass through; maybe someone higher up knows what to do
41             # with it
42 0           push @new_pages, $page;
43             }
44             }
45 0           $self->SUPER::grand_search_init(\@new_pages, @found);
46             }
47              
48             sub opt_V {
49 0     0 0   my $self = shift;
50 0           print "perlfind v$VERSION, ";
51 0           $self->SUPER::opt_V(@_);
52             }
53              
54             1;
55             __END__