Plugins/Sqitch.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 39 CC 1 SCAR 6.9
CC
1
Cov
0%
complete
2.0
prefix_match
2.0
should_activate
2.0
CRAP 2.0
1 package Bash::Completion::Plugins::Sqitch;
2  
3 use strict;
4 use warnings;
5 use parent 'Bash::Completion::Plugin';
6 use Bash::Completion::Utils qw{command_in_path};
7 use Bash::Completion::RequestX::Sqitch;
8  
9 our $VERSION = '0.01';
10  
11 sub complete {
12 my ($self, $r) = @_;
13  
14 # this is the word bash is trying to complete
15 my $word = $r->word;
16  
17 # extended request for the sqitch command
18 my $rx = Bash::Completion::RequestX::Sqitch->new(request => $r);
19  
20 $r->candidates(prefix_match($word, @{$rx->candidates}));
21 }
22  
23 # Bash::Completion::Utils version of prefix_match is broken in that it doesn't
24 # quote the meta characters in variables used in regular expressions.
25 sub prefix_match {
26 my $prefix = shift;
27  
28 return grep { /^\Q$prefix\E/ } @_;
29 }
30  
31 sub should_activate {
32 return [grep { command_in_path($_) } ('sqitch')];
33 }
34  
35 1;
36  
37 __END__