SYNOPSIS

    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;

DESCRIPTION

This module uses \s-1PPI\s0 to change the package name of code.

METHODS

new()

Constructor. Generally shouldn't be called with any arguments. Accepts either a \*(C`PPI::Document\*(C' to process or a string containing the code (which will be converted into a \*(C`PPI::Document\*(C') to process. Replaces the package name with that supplied in the \*(C`filename\*(C' parameter and returns a \*(C`PPIx::EditorTools::ReturnObject\*(C' with the new code available via the \*(C`ppi\*(C' or \*(C`code\*(C' accessors, as a \*(C`PPI::Document\*(C' or \*(C`string\*(C', respectively. An attempt will be made to derive the package name from the filename passed as a parameter. The filename's path will converted to an absolute path and it will be searched for a \*(C`lib\*(C' directory which will be assumed the start of the package name. If no \*(C`lib\*(C' directory can be found in the absolute path, the relative path will be used. Croaks with a \*(L"package name not found\*(R" exception if unable to find the package name.

RELATED TO PPIx::EditorTools::RenamePackageFromPath…

This class inherits from \*(C`PPIx::EditorTools\*(C'. Also see App::EditorTools, Padre, and \s-1PPI\s0.