blib/lib/App/Ack/Filter/IsGroup.pm

filter: Statementstmt 77.2% 17 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 60.0% 3 / 5 totaltotal 74.2% 26 / 35 CC 1 SCAR 2.2
CC
1
Cov
77%
inspect
2.0
to_string
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/App/Ack/ConfigDefault.pm ↑ Summary blib/lib/App/Ack/Filter/IsPathGroup.pm »
1 package App::Ack::Filter::IsGroup;
2  
3 =head1 NAME
4  
5 App::Ack::Filter::IsGroup
6  
7 =head1 DESCRIPTION
8  
9 The App::Ack::Filter::IsGroup class optimizes multiple
10 App::Ack::Filter::Is calls into one container.
11  
12 Let's say you have 100 C<--type-add=is:...> filters.
13  
14 You could have
15  
16 my @filters = map { make_is_filter($_) } 1..100;
17  
18 and then do
19  
20 if ( any { $_->filter($rsrc) } @filters ) { ... }
21  
22 but that's slow, because of of method lookup overhead, function call
23 overhead, etc. So ::Is filters know how to organize themselves into an
24 ::IsGroup filter.
25  
26 =cut
27  
28 581 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 581 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 581 ▶use parent 'App::Ack::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 797 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
33 797 my ( $class ) = @_;
34  
35 797 return bless {
36 data => {},
37 }, $class;
38 }
39  
40 11683 ▶sub add {
Subroutine add: called CC=1 SCAR=0.0
Pod undocumented
41 11683 my ( $self, $filter ) = @_;
42  
43 11683 $self->{data}->{ $filter->{filename} } = 1;
44  
45 11683 return;
46 }
47  
48 13620 ▶sub filter {
Subroutine filter: called CC=1 SCAR=0.0
Pod documented
49 13620 my ( $self, $file ) = @_;
50  
51 13620 return exists $self->{data}->{ $file->basename };
52 }
53  
54 0 ▶sub inspect {
Subroutine inspect: not called CC=1 SCAR=6.9
Pod documented
55 0 my ( $self ) = @_;
56  
57 0 return ref($self) . " - $self";
58 }
59  
60 0 ▶sub to_string {
Subroutine to_string: not called CC=1 SCAR=6.9
Pod documented
61 0 my ( $self ) = @_;
62  
63 0 return join(' ', keys %{$self->{data}});
64 }
65  
66 581 1;
« blib/lib/App/Ack/ConfigDefault.pm ↑ Summary blib/lib/App/Ack/Filter/IsPathGroup.pm »