13 May 2022 19:30:53 UTC
- Distribution: lib-relative-to
- Module version: 1.1000
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (247 / 0 / 0)
- KwaliteeBus factor: 1
- 100.00% Coverage
- License: unknown, artistic_1, gpl_2
- Activity24 month
- Download (16.28KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Find paths relative to something else
Both of these will look up through the parent directories of the file that contains this code until it finds the root of a git repository, then return the absolute paths of the 'lib' and 't/lib' directories in that repository.
use Directory::relative::to (relative_dir); my @dirs = relative_dir( GitRepository => qw(lib t/lib) );
use Directory::relative::to; my @dirs = Directory::relative::to->relative_dir( ParentContaining => '.git/config' => qw(lib t/lib) );
Yes, it's practically identical to how you'd invoke
lib::relative::to. This module is just a very thin wrapper around that.
Just like how I got fed up with Sam for the reasons explained in lib::relative::to I have a new colleague who wrote:
use FindBin qw($Bin); ... my $fixture_path = "$Bin/../../fixtures";
That string of repeated
../s is an abomination unto the Lord.
Can be invoked either as a class method or can optionally be exported and called as a normal function.
This takes the several arguments, the first of which is the name of a
lib::relative::toplugin, the remainder being arguments to that plugin. In general the argument list will take the form:
Note that under the bonnet this function uses lib::relative::to's undocumented private functions.
It normally returns a list of fully-qualified directory names, but if there is only one directory to be returned and you call it in scalar context you will get a scalar name.
If there aer multiple directory names but you use scalar context that is a fatal error.
I only have access to Unix machines for development and debugging. There may be bugs lurking that affect users of exotic platforms like Amiga, Windows, and VMS. I welcome patches, preferably in the form of a pull request. Ideally any patches will be accompanied by tests, and those tests will either skip or pass on Unix.
Copyright 2022 David Cantrell <email@example.com>.
This software is free-as-in-speech as well as free-as-in-beer, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.
This software is also free-as-in-mason.
Module Install Instructions
To install lib::relative::to, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install lib::relative::to
For more information on module installation, please visit the detailed CPAN module installation guide.