Bash/Completion/Request.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 7 / 7 totaltotal 100% 47 / 47 CC 2 SCAR 1.5
CC
2
Cov
100%
candidates
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Bash/Completion.pm ↑ Summary Bash/Completion/Plugin.pm »
1 package Bash::Completion::Request;
2 {
3 4 $Bash::Completion::Request::VERSION = '0.008';
4 }
5  
6 # ABSTRACT: Abstract a completion request
7  
8 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 1 ▶sub line { return $_[0]{line} }
Subroutine line: called CC=1 SCAR=0.0
Pod documented
13  
14  
15  
16 4 ▶sub word { return $_[0]{word} }
Subroutine word: called CC=1 SCAR=0.0
Pod documented
17  
18  
19  
20 4 ▶sub args { return @{$_[0]{args}} }
Subroutine args: called CC=1 SCAR=0.0
Pod documented
21  
22  
23  
24 4 ▶sub count { return $_[0]{count} }
Subroutine count: called CC=1 SCAR=0.0
Pod documented
25  
26  
27  
28 1 ▶sub point { return $_[0]{point} }
Subroutine point: called CC=1 SCAR=0.0
Pod documented
29  
30  
31  
32 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
33 4 my ($class) = @_;
34  
35 return bless {
36 candidates => [],
37  
38 line => $ENV{COMP_LINE},
39 point => $ENV{COMP_POINT},
40 4 _get_completion_word(),
41 _get_arguments(),
42 }, $class;
43 }
44  
45  
46  
47 8 ▶sub candidates {
Subroutine candidates: called CC=2 SCAR=6.9
Pod documented
48 8 my $self = shift;
49 8 my $c = $self->{candidates};
50  
51 8 ▶ return @$c unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 4 4 8
52  
53 4 push @$c, @_;
54 }
55  
56  
57 #######
58 # Utils
59  
60 ## Stolen from http://github.com/yanick/dist-zilla/blob/master/contrib/dzil-complete
61 4 ▶sub _get_completion_word {
Subroutine _get_completion_word: called CC=1 SCAR=0.0
62 4 my $comp = substr $ENV{'COMP_LINE'}, 0, $ENV{'COMP_POINT'};
63 4 $comp =~ s/.*\s//;
64 4 return word => $comp;
65 }
66  
67 4 ▶sub _get_arguments {
Subroutine _get_arguments: called CC=1 SCAR=0.0
68 4 my $comp = substr $ENV{'COMP_LINE'}, 0, $ENV{'COMP_POINT'};
69 4 my @args = split(/\s+/, $comp);
70  
71 4 return args => \@args, count => scalar(@args);
72 }
73  
74  
75 4 1;
76  
77 __END__
« Bash/Completion.pm ↑ Summary Bash/Completion/Plugin.pm »