Skip to content

kentnl/Module-Path-Simplify

Repository files navigation

NAME

Module::Path::Simplify - Simplify absolute paths for pretty-printing.

VERSION

version 0.001000

DESCRIPTION

This module aids in simplifying paths to modules you may already have had lying around, for instance, like in %INC, and aids in compressing them into a format more easily skimmed, for use in diagnostic reporting such as stack-traces, where legibility of the trace is more important to you than being able to use path URIs verbatim.

USAGE

use Module::Path::Simplify;

my $simplifier = Module::Path::Simplify->new();

print $simplifier->simplify( $INC{'Module/Path/Simplify.pm'} )
  # This may output something like $INC[0]/Module/Path/Simplify.pm
  # or even ${VP} or ${SP}, depending on where you installed it.

print $simplifier->pp_aliases;
  # This will emit a key => value table of all the aliases used so far
  # by this instance, expanding the display setting of the alias to the path matched.
  #
  # In cases where the aliases are different to their display values for better compressability
  # the raw internal alias names will be displayed in parentheses at the end of the line.

METHODS

new

Create a simplifier object.

Normally, new captures the state of @INC at its creation time.

This can be disabled to use a per-resolution dynamic @INC via

->new( inc_dynamic => 1 );

Additionally, @INC can be overridden with a custom list via

->new( inc => [ @INC ] );

inc_dynamic and inc don't work together, and setting inc_dynamic will cause inc to be ignored.

simplify

Return a simplified version of a path, or the path itself if there are no simplifications available

print $simpl->simplify( $INC{'Test/More.pm'} )

aliases

Returns the internal alias tracking object.

pp_aliases

Return a string detailing the used simplification aliases and where they map to. ( And possibly their internal identifier )

inc_dynamic

Returns whether or not this simplifier is using a dynamic @INC.

inc

Returns the snapshot @INC in use when not using inc_dynamic

AUTHOR

Kent Fredric kentnl@cpan.org

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Kent Fredric kentfredric@gmail.com.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

About

Simplify absolute paths for pretty-printing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages