PPIx::...omPath(3pm)

πŸ“¦
version 0.21 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ’– NAME πŸ’–

PPIx::EditorTools::RenamePackageFromPath β€” the module that looks at where your file lives and goes "bestie, your package name is wrong, let me fix it." It changes the package name based on the file's path. No cap. πŸ¦‹

This is the page for PPIx::...omPath(3pm), from the User Contributed Perl Documentation crew.


✨ VERSION ✨

version 0.21 β€” that's the one, periodt. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

okay so this is literally how you'd use it:

my $munged = PPIx::EditorTools::RenamePackageFromPath->new->rename(
    code        => "package TestPackage;\nuse strict;\nBEGIN {
    $^W = 1;
}\n1;\n",
    filename => './lib/Test/Code/Path.pm',
);

my $new_code_as_string = $munged->code;
my $package_ppi_element = $munged->element;

look at her go πŸ’…


🌸 DESCRIPTION 🌸

This module uses PPI to change the package name of code. That's it, that's the whole vibe. it's giving "renamed and unbothered." ✨


πŸ’œ METHODS πŸ’œ

🫢 new()

Constructor. Generally shouldn't be called with any arguments. Like, she works best when you just let her cook with nothing in her hands, fr fr.


πŸ¦‹ rename( ppi => PPI::Document $ppi, filename => Str )

πŸ¦‹ rename( code => Str $code, filename => Str )

okay so she's flexible, and we love that for her. She accepts either a PPI::Document to process, or a plain string containing the code (which she'll convert into a PPI::Document for you, no stress).

Then she replaces the package name with the one supplied in the filename parameter, and hands you back a PPIx::EditorTools::ReturnObject with the fresh new code available through the ppi or code accessors β€” as a PPI::Document or a string, respectively. Pick your fighter. πŸ₯Š

An attempt will be made to derive the package name from the filename you passed in as a parameter. Here's the tea 🍡: the filename's path gets converted to an absolute path, and then she searches it for a lib directory, which gets assumed to be the start of the package name. If no lib directory can be found in the absolute path, then the relative path will be used instead. She's resourceful like that.

😭 Heads up bestie: she croaks with a package name not found exception if she's unable to find the package name. So if you hear croaking, that's what happened, not a frog.

⭐ SEE ALSO ⭐

This class inherits from PPIx::EditorTools. Also go peek at App::EditorTools, Padre, and PPI β€” the whole friend group, honestly. 🌈


πŸ‘‘ AUTHORS πŸ‘‘

The absolute icons who made this happen:

  • Steffen Mueller smueller@cpan.org
  • Mark Grimes mgrimes@cpan.org
  • Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
  • Gabor Szabo <gabor@szabgab.com>
  • Yanick Champoux <yanick@cpan.org>

This software is copyright (c) 2017, 2014, 2012 by The Padre development team as listed in Padre.pm.. (yes, with the double period, we're keeping it exactly as written, no notes πŸ’…)

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


perl v5.34.0 Β· 2022-06-17 Β· PPIx::...omPath(3pm)

that's the whole page bestie, mwah πŸ’‹ go rename something iconic 🫢✨

πŸ“¦ where this page comes from