CPANPLUS::Module(3pm)

πŸ“¦
version 0.9916 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ CPANPLUS::Module ✨

ok so this is the CPANPLUS::Module page, bestie πŸ’– β€” from the User Contributed Perl Documentation, CPANPLUS::Module(3pm), and it's giving "let me introduce you to the actual module objects". buckle up πŸŽ€

🌸 NAME 🌸

CPANPLUS::Module β€” CPAN module objects for CPANPLUS. that's it, that's the name, slay πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

ok so first you gotta get a module object from the CPANPLUS::Backend object, like so:

### get a module object from the CPANPLUS::Backend object
my $mod = $cb->module_tree('Some::Module');

### accessors
$mod->version;
$mod->package;

### methods
$mod->fetch;
$mod->extract;
$mod->install;

see how it's accessors first and then methods? the vibes are immaculate ✨


πŸ’œ DESCRIPTION πŸ’œ

CPANPLUS::Module creates objects from the information in the source files. and once you have those objects?? you can query them and do stuff to them, like fetching or installing. main character energy, honestly πŸ‘‘

now, important part, no cap: these objects should only be created internally πŸ™ˆ. if you want "fake" objects there's a whole separate class for that, it's CPANPLUS::Module::Fake. and if you actually need to obtain a module object the right way, go read the CPANPLUS::Backend documentation. don't just make one yourself bestie, that's not the move πŸ’€


⭐ CLASS METHODS ⭐

πŸŽ€ accessors () πŸŽ€

Returns a list of all accessor methods to the object. like a little inventory of every accessor this thing has. so helpful, we love her 🌸


πŸ‘‘ ACCESSORS πŸ‘‘

so an object of this class has the following accessors β€” here's the whole roster, no skips:

  • name β€” Name of the module.
  • module β€” Name of the module. (yes, same thing, she said what she said πŸ’…)
  • version β€” Version of the module. Defaults to '0.0' if none was provided.
  • path β€” Extended path on the mirror.
  • comment β€” Any comment about the module β€” largely unused. (she's just sitting there, chilling 😭)
  • package β€” The name of the package.
  • description β€” Description of the module β€” only registered modules have this.
  • dslip β€” The five character dslip string, that represents meta-data of the module β€” again, only registered modules have this.
  • status β€” The CPANPLUS::Module::Status object associated with this object. (see below πŸ‘‡)
  • author β€” The CPANPLUS::Module::Author object associated with this object.
  • parent β€” The CPANPLUS::Internals object that spawned this module object. (her origin story πŸ₯Ή)

🌈 STATUS ACCESSORS 🌈

ok so CPANPLUS caches a LOT of results from method calls and saves data it collected along the road for later reuse. very organized of her, we stan a hoarder of knowledge 🫢

CPANPLUS uses this internally, but it's also available for the end user. you can get a status object by calling:

$modobj->status

and then you can query that object like this:

  • installer_type β€” The installer type used for this distribution. Will be one of 'makemaker' or 'build'. This determines whether CPANPLUS::Dist::MM or CPANPLUS::Dist::Build will be used to build this distribution.
  • dist_cpan β€” The dist object used to do the CPAN-side of the installation. Either a CPANPLUS::Dist::MM or a CPANPLUS::Dist::Build object.
  • dist β€” The custom dist object used to do the operating specific side of the installation, if you've chosen to use this. For example, if you've chosen to install using the "ports" format, this may be a CPANPLUS::Dist::Ports object. Undefined if you didn't specify a separate format to install through.
  • prereqs | requires β€” A hashref of prereqs this distribution was found to have. Will look something like this:
{ Carp  => 0.01, strict => 0 }

Might be undefined if the distribution didn't have any prerequisites. (if it's undefined, she simply had no needs, icon behaviour πŸ’…)

  • configure_requires β€” Like prereqs, but these are necessary to be installed before the build process can even begin. like, before the build even gets out of bed, these gotta be there 🌸
  • signature β€” Flag indicating, if a signature check was done, whether it was OK or not.
  • extract β€” The directory this distribution was extracted to.
  • fetch β€” The location this distribution was fetched to.
  • readme β€” The text of this distributions README file.
  • uninstall β€” Flag indicating if an uninstall call was done successfully.
  • created β€” Flag indicating if the "create" call to your dist object was done successfully.
  • installed β€” Flag indicating if the "install" call to your dist object was done successfully.
  • checksums β€” The location of this distributions CHECKSUMS file.
  • checksum_ok β€” Flag indicating if the checksums check was done successfully.
  • checksum_value β€” The checksum value this distribution is expected to have.
bestie this is only part 1 of the page 😭 more is coming, don't go anywhere πŸ¦‹

πŸ’– METHODS πŸ’–

$self = CPANPLUS::Module->new( OPTIONS )

okay so this one hands you back a CPANPLUS::Module object. but bestie, listen β€” normal users should never call this method directly, you're supposed to use the CPANPLUS::Backend to get your module objects. that's the vibe, respect the vibe 🫢

here's what a new() call looks like with all the required arguments in place:

CPANPLUS::Module->new(
    module  => 'Foo',
    path    => 'authors/id/A/AA/AAA',
    package => 'Foo-1.0.tgz',
    author  => $author_object,
    _id     => INTERNALS_OBJECT_ID,
);

and the part that's so satisfying β€” every accessor is also a valid option to pass to new. like, all of them. iconic.

Returns a module object on success and false on failure. πŸ’…


$mod->package_name( [$package_string] )

gives you the name of the package a module lives in. for Acme::Bleach that might be Acme-Bleach. cute, right?

$mod->package_version( [$package_string] )

gives you the version of the package a module is in. so for a module chillin in the package Acme-Bleach-1.1.tar.gz, this would be 1.1. πŸ“

$mod->package_extension( [$package_string] )

gives you the suffix that got added by the compression method of the package a certain module is in. for a module in Acme-Bleach-1.1.tar.gz, this would be tar.gz.

$mod->package_is_perl_core

returns a boolean telling you whether the package this particular module is in is actually a core perl distribution. πŸ‘‘

$mod->module_is_supplied_with_perl_core( [version => $]] )

returns a boolean telling you whether ANY VERSION of this module was supplied with the core package of the perl you're currently running.

$mod->is_bundle

returns a boolean telling you if the module you're staring at is actually a bundle. bundles get identified as modules whose name starts with Bundle::.

$mod->is_autobundle;

returns a boolean telling you if the module you're looking at is actually an autobundle as generated by $cb->autobundle. ✨

$mod->is_third_party

returns a boolean telling you whether the package is a known third-party module β€” meaning it's not provided by the standard Perl distribution and it's not available on the CPAN, but instead comes from a third party software provider. see Module::ThirdParty for more deets.

$mod->third_party_information

returns a reference to a hash with more info about a third-party module. check the docs about module_information() in Module::ThirdParty for the details.

$clone = $self->clone

clones the current module object so you can tinker with it without messing up the original. it'll come with a clean CPANPLUS::Module::Status object, plus a fake CPANPLUS::Module::Author object. fresh start energy 🌸

$where = $self->fetch

fetches the module from a CPAN mirror. peek at CPANPLUS::Internals::Fetch::_fetch() for the details on which options you can pass.

$path = $self->extract

extracts the fetched module. peek at CPANPLUS::Internals::Extract::_extract() for the details on which options you can pass.

$type = $self->get_installer_type([prefer_makefile => BOOL])

grabs the installer type for this module. it's either gonna be build or makemaker. if Module::Build isn't available, or if there's no installer type available at all, it falls back to makemaker. if both are available, it picks whichever one your config says β€” or whichever the prefer_makefile option you passed to this function says.

returns the installer type on success, and false on error.

$dist = $self->dist([target => 'prepare|create', format => DISTRIBUTION_TYPE, args => {key => val}]);

creates a distribution object, all ready to be installed. the distribution type defaults to your config settings. πŸ“¦

the optional args hashref gets passed on to the specific distribution type's create method β€” after being dereferenced, obviously.

returns a distribution object on success, false on failure.

see CPANPLUS::Dist for details.

$bool = $mod->prepare( )

a convenience method wrapped around install() that prepares a module without actually building it. this is equivalent to invoking install with target set to prepare.

returns true on success, false on failure.

$bool = $mod->create( )

a convenience method wrapped around install() that creates a module. this is equivalent to invoking install with target set to create.

returns true on success, false on failure.

$bool = $mod->test( )

a convenience wrapper around install() that tests a module without installing it. it's the equivalent of invoking install() with target set to create and skiptest set to 0.

returns true on success, false on failure. 🧚

$bool = $self->install([ target => 'init|prepare|create|install', format => FORMAT_TYPE, extractdir => DIRECTORY, fetchdir => DIRECTORY, prefer_bin => BOOL, force => BOOL, verbose => BOOL, ..... ]);

installs the current module. this includes fetching it and extracting it (if that hasn't been done yet), plus creating a distribution object for it. the full package, no skips. πŸ”₯

which means you can pass it more arguments than the ones described above, and those extra args get passed on to the relevant methods as they get called.

see CPANPLUS::Internals::Fetch, CPANPLUS::Internals::Extract and CPANPLUS::Dist for details.

returns true on success, false on failure.

@list = $self->bundle_modules()

returns a list of module objects that the Bundle specifies.

this one requires you to have extracted the bundle already, using the extract() method. no extract, no list, sorry bestie.

returns false on error.

$text = $self->readme

fetches the readme that belongs to this module and stores it under $obj->status->readme. returns the readme as a string on success, and returns false on failure.

$version = $self->installed_version()

returns the version of this module that's currently installed, if there is one.

$where = $self->installed_file()

returns the location of the currently installed file of this module, if there is one.

$dir = $self->installed_dir()

returns the directory β€” or more accurately, the @INC handle β€” from which this module got loaded, if any.

$bool = $self->is_uptodate([version => VERSION_NUMBER])

returns a boolean telling you if this module is uptodate or not. ⭐

$href = $self->details()

returns a hashref with key/value pairs giving you more info about a particular module. for Time::HiRes it might look like this:

Author                  Jarkko Hietaniemi (jhi@iki.fi)
Description             High resolution time, sleep, and alarm
Development Stage       Released
Installed File          /usr/local/perl/lib/Time/Hires.pm
Interface Style         plain Functions, no references used
Language Used           C and perl, a C compiler will be needed
Package                 Time-HiRes-1.65.tar.gz
Public License          Unknown
Support Level           Developer
Version Installed       1.52
Version on CPAN         1.65

@list = $self->contains()

returns a list of module objects that represent the modules also present in the package of this module.

for example, for Archive::Tar this might return:

Archive::Tar
Archive::Tar::Constant
Archive::Tar::File

@list_of_hrefs = $self->fetch_report()

this function queries the CPAN testers database over at http://testers.cpan.org/ for test results of the specified module objects, module names or distributions.

check CPANPLUS::Internals::Report::_query_report() for details on the options you can pass and the return value to expect.

$bool = $self->uninstall([type => [all|man|prog])

this function uninstalls the specified module object. 🫑

you can install 2 types of files β€” either man pages or program files. or you can just say all and uninstall both (which is the default, btw).

returns true on success and false on failure.

do note that this does an uninstall via the so-called .packlist, so if you used a module installer like, say, ports or apt, you should not use this β€” use your package manager instead. fr fr, don't fight your package manager.

@modobj = $self->distributions()

returns a list of module objects representing all the releases for this module on success, false on failure.

@list = $self->files ()

returns a list of files used by this module, if it's installed.

@list = $self->directory_tree ()

returns a list of directories used by this module.

@list = $self->packlist ()

returns the ExtUtils::Packlist object for this module.

@list = $self->validate ()

returns a list of files that are missing for this module but are present in the .packlist file. (the little discrepancy check, we love her πŸ’…)

$bool = $self->add_to_includepath;

adds the current module's path to @INC and $PERL5LIB. this lets you add the module from its build dir into your path. πŸ¦‹

it also adds the current module's bin and/or script paths to the PATH.

and you can reset $PATH, @INC and $PERL5LIB back to their original state β€” the state they were in when you started the program β€” by calling:

$self->parent->flush('lib');

$path = $self->best_path_to_module_build();

OBSOLETE

if a newer version of Module::Build is found in your path, it'll return this special path. if the newest version of Module::Build is found in your regular @INC, the method returns false β€” which is the signal that you do not need to add a special directory to your @INC.

note that this is only relevant if you're building your own CPANPLUS::Dist::* plugin β€” the built-in dist types already have this taken care of. so like, you probably don't need it. πŸ™ˆ

πŸ› BUG REPORTS πŸ›

please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>. do it, we love a good bug report. πŸ’œ

πŸ‘‘ AUTHOR πŸ‘‘

this module by Jos Boumans <kane@cpan.org>.

the CPAN++ interface (of which this module is a part of) is copyright (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. all rights reserved.

this library is free software; you may redistribute and/or modify it under the same terms as Perl itself.


and that's a wrap bestie πŸŽ€ this whole page came from perl v5.40.1, dated 2025-03-01, in the CPANPLUS::Module(3pm) era β€” go forth and install your modules, you absolute main character ✨

πŸ“¦ where this page comes from