| 1 | package List::Filter::Library::FileSystem; | ||||||||||||||||||||
| 2 | 1 | ▶ | use base qw( Class::Base ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | List::Filter::Library::FileSystem - filters for unix file listings | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # This is a plugin, not intended for direct use. | ||||||||||||||||||||
| 11 | # See: List::Filter::Storage::CODE | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | A library of L<List::Filter> filters for use on file listings. | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | See L<List::Filter::Library::Documentation> for a information | ||||||||||||||||||||
| 18 | about the filters defined here. | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 1 | ▶ | use 5.006; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 1 | my $DEBUG = 0; | |||||||||||||||||||
| 26 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | 1 | ▶ | use Hash::Util qw(lock_keys unlock_keys); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head2 METHODS | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =over | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =item new | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | Instantiates a new List::Filter::Transform::Library::FileSystem object. | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | # Note: | ||||||||||||||||||||
| 43 | # "new" is inherited from Class::Base. | ||||||||||||||||||||
| 44 | # It calls the following "init" routine automatically. | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =item init | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | Initialize object attributes and then lock them down to prevent | ||||||||||||||||||||
| 49 | accidental creation of new ones. | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | Note: there is no leading underscore on name "init", though it's | ||||||||||||||||||||
| 52 | arguably an "internal" routine (i.e. not likely to be of use to | ||||||||||||||||||||
| 53 | client code). | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | =cut | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 4 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 58 | 4 | my $self = shift; | |||||||||||||||||||
| 59 | 4 | my $args = shift; | |||||||||||||||||||
| 60 | 4 | unlock_keys( %{ $self } ); | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 4 | my $lfs = List::Filter::Storage->new( storage => | |||||||||||||||||||
| 63 | { format => 'MEM', } ); | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | # define new attributes | ||||||||||||||||||||
| 66 | my $attributes = { | ||||||||||||||||||||
| 67 | 4 | ▶ | storage_handler => $args->{ storage_handler } || $lfs, | ||||||||||||||||||
|
Condition33%1/3
$args->{'storage_handler'} || $lfs
MC/DC0%0/2
$args->{'storage_handler'} || $lfs
$args->{'storage_handler'}
$lfs
Truth table33%1/3
A || B
A= $args->{'storage_handler'}B= $lfs
| |||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | # add attributes to object | ||||||||||||||||||||
| 71 | 4 | my @fields = (keys %{ $attributes }); | |||||||||||||||||||
| 72 | 4 | @{ $self }{ @fields } = @{ $attributes }{ @fields }; # hash slice | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 4 | lock_keys( %{ $self } ); | |||||||||||||||||||
| 75 | 4 | return $self; | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =item define_filters_href | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | Returns a hash reference (keyed by filter name) of filter hash references. | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 4 | ▶ | sub define_filters_href { | ||||||||||||||||||
|
Subroutine
define_filters_href: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 85 | 4 | my $self = shift; | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 4 | my $filters = | |||||||||||||||||||
| 88 | { | ||||||||||||||||||||
| 89 | ':jpeg' => | ||||||||||||||||||||
| 90 | { | ||||||||||||||||||||
| 91 | 'description' => 'Find jpegs, for all common extensions.', | ||||||||||||||||||||
| 92 | 'method' => 'find_any', | ||||||||||||||||||||
| 93 | 'terms' => | ||||||||||||||||||||
| 94 | [ | ||||||||||||||||||||
| 95 | '\.jpeg$', | ||||||||||||||||||||
| 96 | '\.JPEG$', | ||||||||||||||||||||
| 97 | '\.jpg$', | ||||||||||||||||||||
| 98 | '\.JPG$', | ||||||||||||||||||||
| 99 | ], | ||||||||||||||||||||
| 100 | 'modifiers' => 'x', | ||||||||||||||||||||
| 101 | }, | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | ':web_img' => # | ||||||||||||||||||||
| 104 | { | ||||||||||||||||||||
| 105 | 'description' => 'Find files with common web image format extensions.', | ||||||||||||||||||||
| 106 | 'method' => 'find_any', | ||||||||||||||||||||
| 107 | 'terms' => | ||||||||||||||||||||
| 108 | [ | ||||||||||||||||||||
| 109 | '\.jpeg$', | ||||||||||||||||||||
| 110 | '\.JPEG$', | ||||||||||||||||||||
| 111 | '\.jpg$', | ||||||||||||||||||||
| 112 | '\.JPG$', | ||||||||||||||||||||
| 113 | '\.gif$', | ||||||||||||||||||||
| 114 | '\.GIF$', | ||||||||||||||||||||
| 115 | '\.png$', | ||||||||||||||||||||
| 116 | '\.PNG$', | ||||||||||||||||||||
| 117 | ], | ||||||||||||||||||||
| 118 | 'modifiers' => 'x', | ||||||||||||||||||||
| 119 | }, | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | ':dired-x-omit' => # | ||||||||||||||||||||
| 122 | { | ||||||||||||||||||||
| 123 | 'description' => 'Filters files like the emacs dired-x omit feature.', | ||||||||||||||||||||
| 124 | 'method' => 'skip_any', | ||||||||||||||||||||
| 125 | 'terms' => | ||||||||||||||||||||
| 126 | [ | ||||||||||||||||||||
| 127 | '^\.?\#', # need to escape '#' in a //x match | ||||||||||||||||||||
| 128 | '^\.$', | ||||||||||||||||||||
| 129 | '^\.\.$', | ||||||||||||||||||||
| 130 | 'CVS/$', | ||||||||||||||||||||
| 131 | '\.o$', | ||||||||||||||||||||
| 132 | '~$', | ||||||||||||||||||||
| 133 | '\.bin$', | ||||||||||||||||||||
| 134 | '\.lbin$', | ||||||||||||||||||||
| 135 | '\.fasl$', | ||||||||||||||||||||
| 136 | '\.ufsl$', | ||||||||||||||||||||
| 137 | '\.a$', | ||||||||||||||||||||
| 138 | '\.ln$', | ||||||||||||||||||||
| 139 | '\.blg$', | ||||||||||||||||||||
| 140 | '\.bbl$', | ||||||||||||||||||||
| 141 | '\.elc$', | ||||||||||||||||||||
| 142 | '\.lof$', | ||||||||||||||||||||
| 143 | '\.glo$', | ||||||||||||||||||||
| 144 | '\.idx$', | ||||||||||||||||||||
| 145 | '\.lot$', | ||||||||||||||||||||
| 146 | '\.dvi$', | ||||||||||||||||||||
| 147 | '\.fmt$', | ||||||||||||||||||||
| 148 | '\.tfm$', | ||||||||||||||||||||
| 149 | '\.pdf$', | ||||||||||||||||||||
| 150 | '\.class$', | ||||||||||||||||||||
| 151 | '\.fas$', | ||||||||||||||||||||
| 152 | '\.lib$', | ||||||||||||||||||||
| 153 | '\.x86f$', | ||||||||||||||||||||
| 154 | '\.sparcf$', | ||||||||||||||||||||
| 155 | '\.lo$', | ||||||||||||||||||||
| 156 | '\.la$', | ||||||||||||||||||||
| 157 | '\.toc$', | ||||||||||||||||||||
| 158 | '\.log$', | ||||||||||||||||||||
| 159 | '\.aux$', | ||||||||||||||||||||
| 160 | '\.cp$', | ||||||||||||||||||||
| 161 | '\.fn$', | ||||||||||||||||||||
| 162 | '\.ky$', | ||||||||||||||||||||
| 163 | '\.pg$', | ||||||||||||||||||||
| 164 | '\.tp$', | ||||||||||||||||||||
| 165 | '\.vr$', | ||||||||||||||||||||
| 166 | '\.cps$', | ||||||||||||||||||||
| 167 | '\.fns$', | ||||||||||||||||||||
| 168 | '\.kys$', | ||||||||||||||||||||
| 169 | '\.pgs$', | ||||||||||||||||||||
| 170 | '\.tps$', | ||||||||||||||||||||
| 171 | '\.vrs$', | ||||||||||||||||||||
| 172 | '\.pyc$', | ||||||||||||||||||||
| 173 | '\.pyo$', | ||||||||||||||||||||
| 174 | '\.idx$', | ||||||||||||||||||||
| 175 | '\.lof$', | ||||||||||||||||||||
| 176 | '\.lot$', | ||||||||||||||||||||
| 177 | '\.glo$', | ||||||||||||||||||||
| 178 | '\.blg$', | ||||||||||||||||||||
| 179 | '\.bbl$', | ||||||||||||||||||||
| 180 | '\.cp$', | ||||||||||||||||||||
| 181 | '\.cps$', | ||||||||||||||||||||
| 182 | '\.fn$', | ||||||||||||||||||||
| 183 | '\.fns$', | ||||||||||||||||||||
| 184 | '\.ky$', | ||||||||||||||||||||
| 185 | '\.kys$', | ||||||||||||||||||||
| 186 | '\.pg$', | ||||||||||||||||||||
| 187 | '\.pgs$', | ||||||||||||||||||||
| 188 | '\.tp$', | ||||||||||||||||||||
| 189 | '\.tps$', | ||||||||||||||||||||
| 190 | '\.vr$', | ||||||||||||||||||||
| 191 | '\.vrs$', | ||||||||||||||||||||
| 192 | ], | ||||||||||||||||||||
| 193 | 'modifiers' => 'x', | ||||||||||||||||||||
| 194 | }, | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | ':doom-omit' => # the way I like my emacs omit feature set-up | ||||||||||||||||||||
| 197 | { | ||||||||||||||||||||
| 198 | 'description' => q<emacs-like omit, without omitting too much>, | ||||||||||||||||||||
| 199 | 'method' => 'skip_any', | ||||||||||||||||||||
| 200 | 'terms' => | ||||||||||||||||||||
| 201 | [ | ||||||||||||||||||||
| 202 | '^\.?\#', | ||||||||||||||||||||
| 203 | '^\.$', | ||||||||||||||||||||
| 204 | '^\.\.$', | ||||||||||||||||||||
| 205 | 'CVS', | ||||||||||||||||||||
| 206 | 'RCS', | ||||||||||||||||||||
| 207 | '~$', | ||||||||||||||||||||
| 208 | '\.a$', | ||||||||||||||||||||
| 209 | '\.elc$', | ||||||||||||||||||||
| 210 | '\.idx$', | ||||||||||||||||||||
| 211 | '\.dvi$', | ||||||||||||||||||||
| 212 | ], | ||||||||||||||||||||
| 213 | 'modifiers' => 'x', | ||||||||||||||||||||
| 214 | }, | ||||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | ':skipdull' => | ||||||||||||||||||||
| 217 | { | ||||||||||||||||||||
| 218 | 'description' => 'Screen out some uninteresting files.', | ||||||||||||||||||||
| 219 | 'method' => 'skip_any', | ||||||||||||||||||||
| 220 | 'terms' => | ||||||||||||||||||||
| 221 | [ | ||||||||||||||||||||
| 222 | '~$', # emacs backups | ||||||||||||||||||||
| 223 | '/\#', # emacs autosaves | ||||||||||||||||||||
| 224 | '/\.\#', # emacs symlinks to autosaves | ||||||||||||||||||||
| 225 | ',v$', # cvs/rcs repository files | ||||||||||||||||||||
| 226 | '/CVS$', # CVS directories | ||||||||||||||||||||
| 227 | '/CVS/', # files in CVS directories | ||||||||||||||||||||
| 228 | '/RCS$', # RCS directories | ||||||||||||||||||||
| 229 | '\.elc$', # compiled elisp | ||||||||||||||||||||
| 230 | ], | ||||||||||||||||||||
| 231 | 'modifiers' => 'x', | ||||||||||||||||||||
| 232 | }, | ||||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | ':skipdull_not' => | ||||||||||||||||||||
| 235 | { | ||||||||||||||||||||
| 236 | 'description' => 'bogus filter for testing.', | ||||||||||||||||||||
| 237 | 'method' => 'skip_any', | ||||||||||||||||||||
| 238 | 'terms' => | ||||||||||||||||||||
| 239 | [ | ||||||||||||||||||||
| 240 | 'e', | ||||||||||||||||||||
| 241 | ], | ||||||||||||||||||||
| 242 | 'modifiers' => 'x', | ||||||||||||||||||||
| 243 | }, | ||||||||||||||||||||
| 244 | |||||||||||||||||||||
| 245 | ':c-omit' => # | ||||||||||||||||||||
| 246 | { | ||||||||||||||||||||
| 247 | 'description' => q<Omit dull files for working in compiled languages like C>, | ||||||||||||||||||||
| 248 | 'method' => 'skip_any', | ||||||||||||||||||||
| 249 | 'terms' => | ||||||||||||||||||||
| 250 | [ | ||||||||||||||||||||
| 251 | '\.o$', # compiled "object" files | ||||||||||||||||||||
| 252 | '~$', # emacs backups | ||||||||||||||||||||
| 253 | '/\#', # emacs autosaves | ||||||||||||||||||||
| 254 | '/\.\#', # emacs symlinks to autosaves | ||||||||||||||||||||
| 255 | ',v$', # cvs/rcs repository files | ||||||||||||||||||||
| 256 | '\.elc$', # compiled elisp | ||||||||||||||||||||
| 257 | ], | ||||||||||||||||||||
| 258 | 'modifiers' => 'x', | ||||||||||||||||||||
| 259 | }, | ||||||||||||||||||||
| 260 | |||||||||||||||||||||
| 261 | ':updatedb_prune' => # | ||||||||||||||||||||
| 262 | { | ||||||||||||||||||||
| 263 | 'description' => q<Prune directories in the same way as updatedb>, | ||||||||||||||||||||
| 264 | 'method' => 'skip_any', | ||||||||||||||||||||
| 265 | 'terms' => | ||||||||||||||||||||
| 266 | [ | ||||||||||||||||||||
| 267 | '^/tmp$', | ||||||||||||||||||||
| 268 | '^/usr/tmp$', | ||||||||||||||||||||
| 269 | '^/var/tmp$', | ||||||||||||||||||||
| 270 | '^/afs$', | ||||||||||||||||||||
| 271 | '^amd$', | ||||||||||||||||||||
| 272 | '^/alex$', | ||||||||||||||||||||
| 273 | '^/var/spool$', | ||||||||||||||||||||
| 274 | '^/sfs$', | ||||||||||||||||||||
| 275 | '^/media$', | ||||||||||||||||||||
| 276 | ], | ||||||||||||||||||||
| 277 | 'modifiers' => 'x', | ||||||||||||||||||||
| 278 | }, | ||||||||||||||||||||
| 279 | |||||||||||||||||||||
| 280 | ':hide_vc' => # | ||||||||||||||||||||
| 281 | { | ||||||||||||||||||||
| 282 | 'description' => q<ignore common version control files>, | ||||||||||||||||||||
| 283 | 'method' => 'skip_any', | ||||||||||||||||||||
| 284 | 'terms' => | ||||||||||||||||||||
| 285 | [ | ||||||||||||||||||||
| 286 | ',v$', # cvs/rcs repository files | ||||||||||||||||||||
| 287 | '/CVS$', # CVS directories | ||||||||||||||||||||
| 288 | '/CVS/', # files in CVS directories | ||||||||||||||||||||
| 289 | '/RCS$', # RCS directories | ||||||||||||||||||||
| 290 | '/RCS/', # files in RCS directories | ||||||||||||||||||||
| 291 | '/_MTN$', # monotone directories | ||||||||||||||||||||
| 292 | '/_MTN/', # files in monotone directories | ||||||||||||||||||||
| 293 | '/.svn$', # SVN directories | ||||||||||||||||||||
| 294 | '/.svn/', # files in SVN directories | ||||||||||||||||||||
| 295 | '/_darcs$', # darcs directories | ||||||||||||||||||||
| 296 | '/_darcs/', # files in darcs directories | ||||||||||||||||||||
| 297 | '/.git$', # GIT directories | ||||||||||||||||||||
| 298 | '/.git/', # files in GIT directories | ||||||||||||||||||||
| 299 | ], | ||||||||||||||||||||
| 300 | 'modifiers' => 'x', | ||||||||||||||||||||
| 301 | }, | ||||||||||||||||||||
| 302 | |||||||||||||||||||||
| 303 | }; | ||||||||||||||||||||
| 304 | 4 | return $filters; | |||||||||||||||||||
| 305 | } | ||||||||||||||||||||
| 306 | |||||||||||||||||||||
| 307 | |||||||||||||||||||||
| 308 | =back | ||||||||||||||||||||
| 309 | |||||||||||||||||||||
| 310 | =head2 setters and getters | ||||||||||||||||||||
| 311 | |||||||||||||||||||||
| 312 | =over | ||||||||||||||||||||
| 313 | |||||||||||||||||||||
| 314 | =item storage_handler | ||||||||||||||||||||
| 315 | |||||||||||||||||||||
| 316 | Getter for object attribute storage_handler | ||||||||||||||||||||
| 317 | |||||||||||||||||||||
| 318 | =cut | ||||||||||||||||||||
| 319 | |||||||||||||||||||||
| 320 | 0 | ▶ | sub storage_handler { | ||||||||||||||||||
|
Subroutine
storage_handler: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 321 | 0 | my $self = shift; | |||||||||||||||||||
| 322 | 0 | my $lfs = $self->{ storage_handler }; | |||||||||||||||||||
| 323 | 0 | return $lfs; | |||||||||||||||||||
| 324 | } | ||||||||||||||||||||
| 325 | |||||||||||||||||||||
| 326 | =item set_storage_handler | ||||||||||||||||||||
| 327 | |||||||||||||||||||||
| 328 | Setter for object attribute set_storage_handler | ||||||||||||||||||||
| 329 | |||||||||||||||||||||
| 330 | =cut | ||||||||||||||||||||
| 331 | |||||||||||||||||||||
| 332 | 0 | ▶ | sub set_storage_handler { | ||||||||||||||||||
|
Subroutine
set_storage_handler: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 333 | 0 | my $self = shift; | |||||||||||||||||||
| 334 | 0 | my $lfs = shift; | |||||||||||||||||||
| 335 | 0 | $self->{ storage_handler } = $lfs; | |||||||||||||||||||
| 336 | 0 | return $lfs; | |||||||||||||||||||
| 337 | } | ||||||||||||||||||||
| 338 | |||||||||||||||||||||
| 339 | 1 | 1; | |||||||||||||||||||
| 340 | |||||||||||||||||||||
| 341 | =back | ||||||||||||||||||||
| 342 | |||||||||||||||||||||
| 343 | =head1 SEE ALSO | ||||||||||||||||||||
| 344 | |||||||||||||||||||||
| 345 | L<List::Filter> | ||||||||||||||||||||
| 346 | L<List::Filter::Project> | ||||||||||||||||||||
| 347 | |||||||||||||||||||||
| 348 | =head1 AUTHOR | ||||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | Joseph Brenner, E<lt>doom@kzsu.stanford.eduE<gt> | ||||||||||||||||||||
| 351 | |||||||||||||||||||||
| 352 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 353 | |||||||||||||||||||||
| 354 | Copyright (C) 2007 by Joseph Brenner | ||||||||||||||||||||
| 355 | |||||||||||||||||||||
| 356 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 357 | it under the same terms as Perl itself, either Perl version 5.8.2 or, | ||||||||||||||||||||
| 358 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||
| 359 | |||||||||||||||||||||
| 360 | =head1 BUGS | ||||||||||||||||||||
| 361 | |||||||||||||||||||||
| 362 | None reported... yet. | ||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | =cut | ||||||||||||||||||||