line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Filter::Storage::MEM; |
2
|
|
|
|
|
|
|
# use base qw( Class::Base ); |
3
|
1
|
|
|
1
|
|
6
|
use base qw( List::Filter::StorageBase ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
127
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
List::Filter::Storage::MEM - filter storage in memory |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use List::Filter::Storage::MEM; |
12
|
|
|
|
|
|
|
my $ffpsm = List::Filter::Storage::MEM->new(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# This is a plugin, not intended for direct use. |
15
|
|
|
|
|
|
|
# See: List:Filter:Storage |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
List::Filter::Storage::MEM, is a Plug-in to use for |
20
|
|
|
|
|
|
|
"storing" List::Filter filters in memory, so that they can be |
21
|
|
|
|
|
|
|
recalled using the List::Filter::Storage interface that |
22
|
|
|
|
|
|
|
scans through multiple storage locations. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The filter_data structure may be passed in as the "connect_to" |
25
|
|
|
|
|
|
|
parameter, or one will be created internally if one has not been |
26
|
|
|
|
|
|
|
passed in. This may be added to with the "save" method. |
27
|
|
|
|
|
|
|
The entire structure can be extracted with the "filter_data" |
28
|
|
|
|
|
|
|
accessor, or (more typically) filter's may be looked up by name, |
29
|
|
|
|
|
|
|
using the "lookup" method. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
17
|
use 5.8.0; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
43
|
|
36
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
37
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
38
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
39
|
1
|
|
|
1
|
|
7
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
40
|
1
|
|
|
1
|
|
6
|
use Hash::Util qw( lock_keys unlock_keys ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 initialization code |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item new |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Instantiates a new List::Filter::Profile object. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Takes an optional hashref as an argument, with named fields |
53
|
|
|
|
|
|
|
identical to the names of the object attributes. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
With no arguments, the newly created filter will be empty. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Note: "new" (inherited from Class::Base) |
60
|
|
|
|
|
|
|
# calls the following "init" routine automatically. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item init |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Initialize object attributes and then lock them down to prevent |
65
|
|
|
|
|
|
|
accidental creation of new ones. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Note: there is no leading underscore on name "init", though it's |
68
|
|
|
|
|
|
|
arguably an "internal" routine (i.e. not likely to be of use to |
69
|
|
|
|
|
|
|
client code). |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub init { |
74
|
34
|
|
|
34
|
1
|
599
|
my $self = shift; |
75
|
34
|
|
|
|
|
42
|
my $args = shift; |
76
|
34
|
|
|
|
|
41
|
unlock_keys( %{ $self } ); |
|
34
|
|
|
|
|
169
|
|
77
|
|
|
|
|
|
|
|
78
|
34
|
|
|
|
|
292
|
$self->SUPER::init( $args ); # uncomment if this is a child class |
79
|
|
|
|
|
|
|
|
80
|
34
|
|
100
|
|
|
169
|
my $filter_data = $args->{connect_to} || {}; |
81
|
34
|
|
|
|
|
96
|
$self->set_filter_data( $filter_data ); |
82
|
|
|
|
|
|
|
|
83
|
34
|
|
|
|
|
44
|
lock_keys( %{ $self } ); |
|
34
|
|
|
|
|
97
|
|
84
|
34
|
|
|
|
|
290
|
return $self; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item save |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Given a filter "saves" it in memory. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the ref to the filter object. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub save { |
96
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
97
|
3
|
|
|
|
|
5
|
my $filter = shift; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# convert $filter object into a data structure, |
100
|
|
|
|
|
|
|
|
101
|
3
|
|
|
|
|
12
|
my $filter_name = $filter->name; |
102
|
|
|
|
|
|
|
|
103
|
3
|
|
|
|
|
12
|
my $method = $filter->method; |
104
|
3
|
|
|
|
|
11
|
my $description = $filter->description; |
105
|
3
|
|
|
|
|
12
|
my $terms = $filter->terms; |
106
|
3
|
|
|
|
|
12
|
my $modifiers = $filter->modifiers; |
107
|
|
|
|
|
|
|
|
108
|
3
|
|
|
|
|
16
|
my $filter_href = { method => $method, |
109
|
|
|
|
|
|
|
description => $description, |
110
|
|
|
|
|
|
|
terms => $terms, |
111
|
|
|
|
|
|
|
modifiers => $modifiers, |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# add it to the internal stash (replaces any existing one of same name) |
115
|
3
|
|
|
|
|
9
|
my $filter_data = $self->filter_data; |
116
|
3
|
|
|
|
|
10
|
$filter_data->{ $filter_name } = $filter_href; |
117
|
|
|
|
|
|
|
|
118
|
3
|
|
|
|
|
10
|
return $filter; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item lookup |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Note: this is *identical* to the code in (the original) YAML.pm |
127
|
|
|
|
|
|
|
sub lookup { |
128
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
129
|
3
|
|
|
|
|
5
|
my $name = shift; |
130
|
|
|
|
|
|
|
|
131
|
3
|
|
|
|
|
13
|
my $filter_data = $self->filter_data; |
132
|
|
|
|
|
|
|
|
133
|
3
|
|
|
|
|
6
|
my $filter; |
134
|
3
|
50
|
|
|
|
14
|
if ( my $filter_href = $filter_data->{ $name } ) { |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# convert this data into a filter object. |
137
|
3
|
|
|
|
|
8
|
my $terms = $filter_href->{terms}; |
138
|
3
|
|
|
|
|
7
|
my $method = $filter_href->{method}; |
139
|
3
|
|
|
|
|
7
|
my $description = $filter_href->{description}; |
140
|
3
|
|
|
|
|
6
|
my $modifiers = $filter_href->{modifiers}; |
141
|
|
|
|
|
|
|
|
142
|
3
|
|
|
|
|
27
|
my $filter_class = $self->define_filter_class; |
143
|
3
|
|
|
|
|
29
|
$filter = $filter_class->new( |
144
|
|
|
|
|
|
|
{ name => $name, |
145
|
|
|
|
|
|
|
terms => $terms, |
146
|
|
|
|
|
|
|
method => $method, |
147
|
|
|
|
|
|
|
description => $description, |
148
|
|
|
|
|
|
|
modifiers => $modifiers, |
149
|
|
|
|
|
|
|
} ); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
152
|
3
|
|
|
|
|
30
|
return $filter; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item list_filters |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns a list of all avaliable named filters. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub list_filters { |
164
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
165
|
2
|
|
|
|
|
7
|
my $filter_data = $self->filter_data; |
166
|
2
|
|
|
|
|
3
|
my @names = keys (%{ $filter_data }); |
|
2
|
|
|
|
|
17
|
|
167
|
2
|
|
|
|
|
10
|
return \@names; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 special accessors (access the "extra" namespace) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item filter_data |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Getter for object attribute filter_data |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub filter_data { |
184
|
8
|
|
|
8
|
1
|
12
|
my $self = shift; |
185
|
8
|
|
|
|
|
25
|
my $filter_data = $self->extra->{ filter_data }; |
186
|
|
|
|
|
|
|
|
187
|
8
|
|
|
|
|
21
|
return $filter_data; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item set_filter_data |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Setter for object attribute set_filter_data |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub set_filter_data { |
197
|
42
|
|
|
42
|
1
|
60
|
my $self = shift; |
198
|
42
|
|
|
|
|
62
|
my $filter_data = shift; |
199
|
42
|
|
|
|
|
133
|
$self->extra->{ filter_data } = $filter_data; |
200
|
42
|
|
|
|
|
73
|
return $filter_data; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=back |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 basic accessors (defined in L); |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=over |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item connect_to |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Getter for object attribute connect_to |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item set_connect_to |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Setter for object attribute set_connect_to |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item owner |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Getter for object attribute owner |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item set_owner |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Setter for object attribute set_owner |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item password |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Getter for object attribute password |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=cut |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item set_password |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Setter for object attribute set_password |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item attributes |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Getter for object attribute attributes |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=item set_attributes |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Setter for object attribute set_attributes |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item extra |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Getter for object attribute extra |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item set_extra |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Setter for object attribute set_extra |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=back |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 SEE ALSO |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
L |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head1 AUTHOR |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Joseph Brenner, Edoom@kzsu.stanford.eduE, |
269
|
|
|
|
|
|
|
18 May 2007 |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Copyright (C) 2007 by Joseph Brenner |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
276
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
277
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 BUGS |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
None reported... yet. |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=cut |