-
Notifications
You must be signed in to change notification settings - Fork 140
/
Is.pm
62 lines (41 loc) · 944 Bytes
/
Is.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package App::Ack::Filter::Is;
=head1 NAME
App::Ack::Filter::Is
=head1 DESCRIPTION
Filters based on exact filename match.
=cut
use strict;
use warnings;
use base 'App::Ack::Filter';
use File::Spec 3.00 ();
use App::Ack::Filter::IsGroup;
sub new {
my ( $class, $filename ) = @_;
return bless {
filename => $filename,
groupname => 'IsGroup',
}, $class;
}
sub create_group {
return App::Ack::Filter::IsGroup->new();
}
sub filter {
my ( $self, $resource ) = @_;
my $filename = $self->{'filename'};
my $base = (File::Spec->splitpath($resource->name))[2];
return $base eq $filename;
}
sub inspect {
my ( $self ) = @_;
my $filename = $self->{'filename'};
return ref($self) . " - $filename";
}
sub to_string {
my ( $self ) = @_;
my $filename = $self->{'filename'};
return $filename;
}
BEGIN {
App::Ack::Filter->register_filter(is => __PACKAGE__);
}
1;