1PPIx::EditorTools::RenaUmseePracCkoangterFirboumtPPePadItxhP:(e:3rE)ldiDtoocruTmoeonltsa:t:iRoennamePackageFromPath(3)
2
3
4
6 PPIx::EditorTools::RenamePackageFromPath - Change the package name
7 based on the files path
8
10 version 0.21
11
13 my $munged = PPIx::EditorTools::RenamePackageFromPath->new->rename(
14 code => "package TestPackage;\nuse strict;\nBEGIN {
15 $^W = 1;
16 }\n1;\n",
17 filename => './lib/Test/Code/Path.pm',
18 );
19
20 my $new_code_as_string = $munged->code;
21 my $package_ppi_element = $munged->element;
22
24 This module uses PPI to change the package name of code.
25
27 new()
28 Constructor. Generally shouldn't be called with any arguments.
29
30 rename( ppi => PPI::Document $ppi, filename => Str )
31 rename( code => Str $code, filename => Str )
32 Accepts either a "PPI::Document" to process or a string containing
33 the code (which will be converted into a "PPI::Document") to
34 process. Replaces the package name with that supplied in the
35 "filename" parameter and returns a
36 "PPIx::EditorTools::ReturnObject" with the new code available via
37 the "ppi" or "code" accessors, as a "PPI::Document" or "string",
38 respectively.
39
40 An attempt will be made to derive the package name from the
41 filename passed as a parameter. The filename's path will converted
42 to an absolute path and it will be searched for a "lib" directory
43 which will be assumed the start of the package name. If no "lib"
44 directory can be found in the absolute path, the relative path will
45 be used.
46
47 Croaks with a "package name not found" exception if unable to find
48 the package name.
49
51 This class inherits from "PPIx::EditorTools". Also see
52 App::EditorTools, Padre, and PPI.
53
55 · Steffen Mueller "smueller@cpan.org"
56
57 · Mark Grimes "mgrimes@cpan.org"
58
59 · Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
60
61 · Gabor Szabo <gabor@szabgab.com>
62
63 · Yanick Champoux <yanick@cpan.org>
64
66 This software is copyright (c) 2017, 2014, 2012 by The Padre
67 development team as listed in Padre.pm..
68
69 This is free software; you can redistribute it and/or modify it under
70 the same terms as the Perl 5 programming language system itself.
71
72
73
74perl v5.30.1 20P2P0I-x0:1:-E3d0itorTools::RenamePackageFromPath(3)