line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Ack::Filter; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
138879
|
use strict; |
|
18
|
|
|
|
|
63
|
|
|
18
|
|
|
|
|
499
|
|
4
|
18
|
|
|
18
|
|
144
|
use warnings; |
|
18
|
|
|
|
|
31
|
|
|
18
|
|
|
|
|
430
|
|
5
|
|
|
|
|
|
|
|
6
|
18
|
|
|
18
|
|
1911
|
use App::Ack (); |
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
334
|
|
7
|
18
|
|
|
18
|
|
7235
|
use App::Ack::Filter::Inverse (); |
|
18
|
|
|
|
|
56
|
|
|
18
|
|
|
|
|
4873
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %filter_types; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
App::Ack::Filter - Filter objects to filter files |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
An abstract superclass that represents objects that can filter |
18
|
|
|
|
|
|
|
C objects. App::Ack::Filter implementations are |
19
|
|
|
|
|
|
|
responsible for filtering filenames to be searched. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# filter implementation |
24
|
|
|
|
|
|
|
package MyFilter; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use strict; |
27
|
|
|
|
|
|
|
use warnings; |
28
|
|
|
|
|
|
|
use parent 'App::Ack::Filter'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub filter { |
31
|
|
|
|
|
|
|
my ( $self, $file ) = @_; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
BEGIN { |
35
|
|
|
|
|
|
|
App::Ack::Filter->register_filter('mine' => __PACKAGE__); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# users |
41
|
|
|
|
|
|
|
App::Ack::Filter->create_filter('mine', @args); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 App::Ack::Filter->create_filter($type, @args) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Creates a filter implementation, registered as C<$type>. C<@args> |
49
|
|
|
|
|
|
|
are provided as additional arguments to the implementation's constructor. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub create_filter { |
54
|
14
|
|
|
14
|
1
|
13750
|
my ( undef, $type, @args ) = @_; |
55
|
|
|
|
|
|
|
|
56
|
14
|
100
|
|
|
|
68
|
if ( my $package = $filter_types{$type} ) { |
57
|
12
|
|
|
|
|
88
|
return $package->new(@args); |
58
|
|
|
|
|
|
|
} |
59
|
2
|
|
|
|
|
9
|
my $allowed_types = join( ', ', sort keys %filter_types ); |
60
|
2
|
|
|
|
|
19
|
App::Ack::die( "Unknown filter type '$type'. Type must be one of: $allowed_types." ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 App::Ack::Filter->register_filter($type, $package) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Registers a filter implementation package C<$package> under |
66
|
|
|
|
|
|
|
the name C<$type>. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub register_filter { |
71
|
20
|
|
|
20
|
1
|
3004
|
my ( undef, $type, $package ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
20
|
|
|
|
|
64
|
$filter_types{$type} = $package; |
74
|
|
|
|
|
|
|
|
75
|
20
|
|
|
|
|
481
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 $filter->filter( $file ) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Must be implemented by filter implementations. Returns |
81
|
|
|
|
|
|
|
true if the filter passes, false otherwise. This method |
82
|
|
|
|
|
|
|
must B alter the passed-in C<$file> object. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 $filter->invert() |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns a filter whose L method returns the opposite of this filter. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub invert { |
91
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return App::Ack::Filter::Inverse->new( $self ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 $filter->is_inverted() |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns true if this filter is an inverted filter; false otherwise. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub is_inverted { |
103
|
0
|
|
|
0
|
1
|
|
return 0; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 $filter->to_string |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Converts the filter to a string. This method is also |
109
|
|
|
|
|
|
|
called implicitly by stringification. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub to_string { |
114
|
0
|
|
|
0
|
1
|
|
return '(unimplemented to_string)'; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 $filter->inspect |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Prints a human-readable debugging string for this filter. Useful for, |
120
|
|
|
|
|
|
|
you guessed it, debugging. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub inspect { |
125
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return ref($self); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |