NAME
Path::List::Rule - Path::Iterator::Rule on an list of paths
VERSION
version 0.02
SYNOPSIS
use Path::List::Rule;
my $rule = Path::List::Rule->new([
qw(
Monkey/Plugin/Bonobo.pm
Monkey/Plugin/Mandrill.pm
Monkey/Plugin/Bonobo/Utilities.pm
Monkey/See/Monkey/Do/
);
]);
$rule->clone->perl_module->all( 'Monkey' );
# returns
# Monkey/Plugin/Bonobo.pm
# Monkey/Plugin/Mandrill.pm
# Monkey/Plugin/Bonobo/Utilities.pm
$rule->clone->dirs->all( 'Monkey' );
# returns
# Monkey
# Monkey/See
# Monkey/See/Monkey
# Monkey/See/Monkey/Do
# Monkey/Plugin
# Monkey/Plugin/Bonobo
DESCRIPTION
Path::List::Rule
is a subclass of Path::Iterator::Rule which uses a list of paths (passed to the constructor) as a proxy for a filesystem.
The list of paths doesn't contain any metadata to allow Path::List::Rule
to distinguish between directories and files, so it does its best:
If a path is used as a component in another path, it's a directory.
If it ends with
/
, it's a directory.Otherwise it's a file.
Path:List::Rule
objects behave just like Path::Iterator::Rule objects, except that methods which would ordinarily return paths as strings return them as "Path::List::Rule::Entry" objects instead.
Path::List::Rule::Entry
These objects overload the stringification operator to provide the initial path. (A stringify
method is also available).
They also respond to the standard Perl file test operators (e.g. -f
, -d
). The following operators are supported; all others will result in a thrown exception.
-e
-
True if the object represents an entry found in the paths passed to the
Path::List::Rule
constructor. -l
-
Always returns false.
-r
-
Always returns true.
-d
-
Returns true if the object represents a directory found in the paths passed to the
Path::List::Rule
constructor. -f
-
Returns true if the object represents a file found in the paths passed to the
Path::List::Rule
constructor.
Note! This minimal set of file operations significantly limits the Path::Iterator::Rule tests which may be used.
Methods
is_dir
-
Returns true if the object represents a directory found in the paths passed to the
Path::List::Rule
constructor. is_file
-
Returns true if the object represents a file found in the paths passed to the
Path::List::Rule
constructor. exists
-
Returns true if the object represents a entry found in the paths passed to the
Path::List::Rule
constructor. stringify
-
Return the path as a string.
SUPPORT
Bugs
Please report any bugs or feature requests to bug-path-list-rule@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=Path-List-Rule
Source
Source is available at
https://gitlab.com/djerius/path-list-rule
and may be cloned from
https://gitlab.com/djerius/path-list-rule.git
SEE ALSO
Please see those modules/websites for more information related to this module.
AUTHOR
Diab Jerius <djerius@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2022 by Smithsonian Astrophysical Observatory.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.