Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryan-willis/ful.pm
a useful "find upper lib" pragma that ascends dirs to include module directories in @INC.
https://github.com/ryan-willis/ful.pm
perl5-module
Last synced: 6 days ago
JSON representation
a useful "find upper lib" pragma that ascends dirs to include module directories in @INC.
- Host: GitHub
- URL: https://github.com/ryan-willis/ful.pm
- Owner: ryan-willis
- License: mit
- Created: 2020-05-20T22:48:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-24T21:23:07.000Z (over 4 years ago)
- Last Synced: 2024-05-02T05:20:00.269Z (7 months ago)
- Topics: perl5-module
- Language: Perl
- Homepage: https://metacpan.org/pod/ful
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
=encoding utf-8
=head1 NAME
ful - a useI "Bind Bpper Bib" pragma that ascends dirs to include
module directories in C<@INC>.=head1 SYNOPSIS
=begin HTML
=end HTML
One line to rule them all.
use ful;
Brings the first C directory found by directory ascencion and adds it to
C<@INC>.Instead of:
use lib::relative '../../lib';
# or
use FindBin;
use lib "$FindBin::Bin/../lib";
# or even
BEGIN {
use Path::Tiny;
my $base = path(__FILE__)->parent;
$base = $base->parent until -d "$base/lib" or $base->is_rootdir;
unshift @INC, "$base/lib";
}=head1 USAGE
When you're working within C when your project looks like this:
project-root/
├── bin/
│ └── utils/
│ └── a-script.pl
├── lib/
│ └── Some/
│ └── Module.pm
├── vendor/
│ └── SomeOrg/
│ └── Some/
│ └── Module.pmJust drop the line before your other C statements:
use ful;
use Some::Module;And that's all.
If you need more than just the C dir, you can do this:
use ful qw/vendor lib/;
use Some::Module;
use SomeOrg::Some::Module;=head1 METHODS
=over 4
=item * crum()
Returns the parent directory for the latest addition to C<@INC>.
=back
=head1 ADVANCED
use ful \%options;
=head2 OPTIONS
=over 4
=item * C \@dirs>
Equivalent to C but can be combined with all other
options.# multiple @INC dirs
use ful { libdirs => [qw/lib vendor/] };# combined with another option
use ful {
libdirs => [qw(lib vendor/lib)],
dir => 'vendor/lib',
};=item * C $file>, C $file>, C $file>
Finds an existing file to add a sibling directory to C<@INC>.
# adds 'lib'
use ful { file => '.file-in-project-root' };=item * C $dname>, C $dname>, C $dname>
Finds an existing directory to add a sibling directory to C<@INC>.
# adds 'lib'
use ful { dir => 'bin' };=item * C 1>
Finds a git repository to add a sibling directory to C<@INC>.
# adds 'lib'
use ful { git => 1 };=back
=head1 LICENSE
MIT License
Copyright (c) 2020 Ryan Willis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.=head1 VERSION
0.11
=head1 SUPPORT
Support is by the author. Please file bug reports or ask questions at
L.