File Coverage

blib/lib/App/GitGrepPerlStatement.pm
Criterion Covered Total %
statement 15 37 40.5
branch 0 4 0.0
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 20 48 41.6


line stmt bran cond sub pod time code
1             package App::GitGrepPerlStatement;
2 1     1   1407 use 5.014000;
  1         3  
  1         32  
3 1     1   5 use strict;
  1         3  
  1         31  
4 1     1   14 use warnings;
  1         2  
  1         31  
5 1     1   527 use App::GitGrepPerlStatement::StatementFinder;
  1         4  
  1         38  
6 1     1   11 use Term::ANSIColor qw(colored);
  1         2  
  1         298  
7              
8             our $VERSION = "0.04";
9              
10             sub run {
11 0     0 0   my ($class, @argv) = @_;
12              
13 0           my $word = (@argv)[0];
14              
15 0 0         unless (defined $word) {
16 0           say "USAGE: git grep-per-statement ";
17 0           exit 1;
18             }
19              
20 0           my @files = split "\n", `git grep --name-only --cached --word-regexp @{[ join ' ', map { quotemeta($_) } @argv ]}`;
  0            
  0            
21              
22 0           my $finder = App::GitGrepPerlStatement::StatementFinder->new($word);
23              
24 0           for my $file (@files) {
25 0           my @found = $finder->search($file);
26              
27 0           for (@found) {
28 0 0         if (-t STDOUT) {
29 0           say colored(
30             ['bold'],
31 0           "@{[ $file ]}:@{[ $_->line_number ]}"
  0            
32             );
33 0           say $finder->highlight($_);
34             } else {
35 0           say "@{[ $file ]}:@{[ $_->line_number ]}";
  0            
  0            
36 0           say $_;
37             }
38             }
39 0           $finder->flush;
40             }
41              
42             }
43              
44             __END__