line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Filter::Transform::Library::FileSystem; |
2
|
1
|
|
|
1
|
|
7
|
use base qw( Class::Base ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
106
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
List::Filter::Transform::Library::FileSystem - transforms for working with unix file listings |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# This is a plugin, not intended for direct use. |
12
|
|
|
|
|
|
|
# See: List::Filter::Storage::CODE |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
A library of standard List::Filter "transforms" for working with |
17
|
|
|
|
|
|
|
unix file listings. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
See L |
20
|
|
|
|
|
|
|
for information about the transforms defined by this module. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 filters |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The following is a (most likely partialy) listing of named |
25
|
|
|
|
|
|
|
filters are defined by this module. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Note that all follow the "leading colon" naming convention. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item :dwim_upcaret |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Returns a transform to be used on regexps that are intended |
34
|
|
|
|
|
|
|
to pick entries out of unix file system listings: |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
It converts a leading "^" in a regexp into a "\b", except when |
37
|
|
|
|
|
|
|
it looks like you really meant to match the beginning of the |
38
|
|
|
|
|
|
|
string, which in a file listing is typically relatively uninteresting, |
39
|
|
|
|
|
|
|
e.g. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
/usr/share/bin/this |
42
|
|
|
|
|
|
|
/usr/share/bin/that |
43
|
|
|
|
|
|
|
/usr/share/bin/theother |
44
|
|
|
|
|
|
|
... |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=back |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
14
|
use 5.8.0; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
55
|
|
51
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
52
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
53
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
54
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
55
|
1
|
|
|
1
|
|
5
|
use Hash::Util qw( lock_keys unlock_keys ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
58
|
|
|
|
|
|
|
my $DEBUG = 0; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item new |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Instantiates a new List::Filter::Profile object. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Takes an optional hashref as an argument, with named fields |
69
|
|
|
|
|
|
|
identical to the names of the object attributes. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
With no arguments, the newly created profile will be empty. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Note: "new" (inherited from Class::Base) |
76
|
|
|
|
|
|
|
# calls the following "init" routine automatically. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item init |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Initialize object attributes and then lock them down to prevent |
81
|
|
|
|
|
|
|
accidental creation of new ones. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Note: there is no leading underscore on name "init", though it's |
84
|
|
|
|
|
|
|
arguably an "internal" routine (i.e. not likely to be of use to |
85
|
|
|
|
|
|
|
client code). |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub init { |
90
|
2
|
|
|
2
|
1
|
52
|
my $self = shift; |
91
|
2
|
|
|
|
|
3
|
my $args = shift; |
92
|
2
|
|
|
|
|
3
|
unlock_keys( %{ $self } ); |
|
2
|
|
|
|
|
12
|
|
93
|
|
|
|
|
|
|
|
94
|
2
|
|
|
|
|
26
|
my $storage_handler = List::Filter::Storage->new( storage => |
95
|
|
|
|
|
|
|
{ format => 'MEM', } ); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# define new attributes |
98
|
2
|
|
33
|
|
|
20
|
my $attributes = { |
99
|
|
|
|
|
|
|
storage_handler => $args->{ storage_handler} || $storage_handler, |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# add attributes to object |
103
|
2
|
|
|
|
|
3
|
my @fields = (keys %{ $attributes }); |
|
2
|
|
|
|
|
7
|
|
104
|
2
|
|
|
|
|
3
|
@{ $self }{ @fields } = @{ $attributes }{ @fields }; # hash slice |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
5
|
|
105
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
4
|
lock_keys( %{ $self } ); |
|
2
|
|
|
|
|
6
|
|
107
|
2
|
|
|
|
|
20
|
return $self; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item define_filters_href |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub define_filters_href { |
115
|
2
|
|
|
2
|
1
|
2
|
my $self = shift; |
116
|
2
|
|
|
|
|
13
|
my $transforms = |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
':dwim_upcaret' => |
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
'description' => "leading '^' converted to \\b, unless it's '^/' or '^~'", |
121
|
|
|
|
|
|
|
'method' => 'sequential', |
122
|
|
|
|
|
|
|
'terms' => |
123
|
|
|
|
|
|
|
[ |
124
|
|
|
|
|
|
|
[ |
125
|
|
|
|
|
|
|
' ^ \^ (?![/~]) | (?<=\|) \^ (?![/~]) ', |
126
|
|
|
|
|
|
|
'xg', |
127
|
|
|
|
|
|
|
'\\b'], |
128
|
|
|
|
|
|
|
], |
129
|
|
|
|
|
|
|
'modifiers' => "x", |
130
|
|
|
|
|
|
|
}, |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
}; |
133
|
2
|
|
|
|
|
6
|
return $transforms; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 basic setters and getters |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item storage_handler |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Getter for object attribute storage_handler |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub storage_handler { |
151
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
152
|
0
|
|
|
|
|
|
my $storage_handler = $self->{ storage_handler }; |
153
|
0
|
|
|
|
|
|
return $storage_handler; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item set_storage_handler |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Setter for object attribute set_storage_handler |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub set_storage_handler { |
163
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
164
|
0
|
|
|
|
|
|
my $storage_handler = shift; |
165
|
0
|
|
|
|
|
|
$self->{ storage_handler } = $storage_handler; |
166
|
0
|
|
|
|
|
|
return $storage_handler; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 SEE ALSO |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L |
178
|
|
|
|
|
|
|
L |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 AUTHOR |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Joseph Brenner, Edoom@kzsu.stanford.eduE, |
185
|
|
|
|
|
|
|
24 May 2007 |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Copyright (C) 2007 by Joseph Brenner |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
192
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
193
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 BUGS |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
None reported... yet. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |