| 1 | package App::Ack::Filter::MatchGroup; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | App::Ack::Filter::MatchGroup | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | The App::Ack::Filter::MatchGroup class optimizes multiple ::Match calls | ||
| 10 | into one container. See App::Ack::Filter::IsGroup for details. | ||
| 11 | |||
| 12 | =cut | ||
| 13 | |||
| 14 | 581 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 581 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 581 | ▶ | no re 'eval'; # Enforce default and block -Mre=eval to block RCE security problem. |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | 581 | ▶ | use parent 'App::Ack::Filter'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | 394 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 21 | 394 | my ( $class ) = @_; | |
| 22 | |||
| 23 | 394 | return bless { | |
| 24 | matches => [], | ||
| 25 | big_re => undef, | ||
| 26 | }, $class; | ||
| 27 | } | ||
| 28 | |||
| 29 | 3887 | ▶ | sub add { |
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 30 | 3887 | my ( $self, $filter ) = @_; | |
| 31 | |||
| 32 | 3887 | push @{ $self->{matches} }, $filter->{regex}; | |
| 33 | |||
| 34 | 3887 | my $re = join('|', map { "(?:$_)" } @{ $self->{matches} }); | |
| 35 | 3887 | $self->{big_re} = qr/$re/; | |
| 36 | |||
| 37 | 3887 | return; | |
| 38 | } | ||
| 39 | |||
| 40 | 10808 | ▶ | sub filter { |
|
Subroutine
filter: called CC=1 SCAR=0.0
Pod
documented
| |||
| 41 | 10808 | my ( $self, $file ) = @_; | |
| 42 | |||
| 43 | 10808 | return $file->basename =~ /$self->{big_re}/; | |
| 44 | } | ||
| 45 | |||
| 46 | # This class has no inspect() or to_string() method. | ||
| 47 | # It will just use the default one unless someone writes something useful. | ||
| 48 | |||
| 49 | 581 | 1; | |