Skip to content

Commit

Permalink
Use filter collections for --ignore-file
Browse files Browse the repository at this point in the history
  • Loading branch information
hoelzro committed Oct 28, 2014
1 parent 60c2afc commit dc202f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 9 additions & 1 deletion ConfigLoader.pm
Expand Up @@ -296,7 +296,15 @@ EOT
},
'ignore-file=s' => sub {
my ( undef, $file ) = @_;
push @{ $opt->{ifiles} }, $file;

my ( $filter_type, $args ) = split /:/, $file, 2;

my $filter = App::Ack::Filter->create_filter($filter_type, split(/,/, $args));

if ( !$opt->{ifiles} ) {
$opt->{ifiles} = App::Ack::Filter::Collection->new();
}
$opt->{ifiles}->add($filter);
},
'lines=s' => sub { shift; my $val = shift; push @{$opt->{lines}}, $val },
'l|files-with-matches'
Expand Down
8 changes: 3 additions & 5 deletions ack
Expand Up @@ -178,7 +178,7 @@ sub _compile_descend_filter {
sub _compile_file_filter {
my ( $opt, $start ) = @_;

my $ifiles_filters = _compile_filters([ map { [ 1, $_ ] } @{$opt->{ifiles} || []} ], '--ignore-file', \@FILE_FILTERS) || [];
my $ifiles_filters = $opt->{ifiles};

my $filters = $opt->{'filters'} || [];
my $direct_filters = App::Ack::Filter::Collection->new();
Expand Down Expand Up @@ -270,10 +270,8 @@ sub _compile_file_filter {

my $resource = App::Ack::Resource::Basic->new($File::Next::name);

foreach my $filter ( @{$ifiles_filters} ) {
if ( $filter->filter($resource) ) {
return 0;
}
if ( $ifiles_filters && $ifiles_filters->filter($resource) ) {
return 0;
}

my $match_found = $direct_filters->filter($resource);
Expand Down

0 comments on commit dc202f0

Please sign in to comment.