Name
WWW::PGXN::Extension - Extension metadata fetched from PGXN
Synopsis
my $pgxn = WWW::PGXN->new( url => 'https://api.pgxn.org/' );
my $ext = $pgxn->get_extension('pgTAP');
$ext->download_stable_to('.');
Description
This module represents PGXN extension metadata fetched from PGXN>. It is not intended to be constructed directly, but via the "get_extension" in WWW::PGXN method of WWW::PGXN.
Interface
Instance Accessors
name
my $name = $extension->name;
$extension->name($name);
The name of the extension.
latest
my $latest = $extension->latest;
$extension->latest($latest);
The status of the latest release. Should be one of:
- stable
- testing
- unstable
Instance Methods
stable_info
testing_info
unstable_info
my $stable_info = $extension->stable_info;
my $testing_info = $extension->testing_info;
my $unstable_info = $extension->unstable_info;
Returns a hash reference describing the latest version of the extension for the named release status. The supported keys are:
dist
-
The name of the distribution in which the extension may be found.
version
-
The version of the distribution in which the extension may be found.
abstract
-
A brief description of the extension. Available only from PGXN API servers, not mirrors.
sha1
-
The SHA1 hash for the distribution archive file.
docpath
-
A path to the documentation for the extension, if any.
If no release has been made with the given status, an empty hash reference will be returned. Here's an example of the structure for a distribution loaded from an API server:
{
dist => 'pair',
version => '0.1.1',
abstract => 'A key/value pair data type',
sha1 => 'c552c961400253e852250c5d2f3def183c81adb3',
docpath => 'doc/pair',
}
latest_info
my $latest_info = $extension->latest_info;
Returns a hash reference describing the latest version of the extension. Essentially a convenience method for:
my $meth = $extension->latest . '_info';
my $info = $extension->$meth;
info_for_version
my $version_info = $extension->info_for_version;
Returns a hash reference containing the distribution information for the named version of the extension, if it exists. The supported keys are:
dist
-
The name of the distribution in which the version of the extension may be found.
version
-
The version of the distribution in which the version of the extension may be found.
date
-
The release date the distribution containing the version of the extension. Available only from PGXN API servers, not mirrors.
Returns
undef
if no such version of the extension exists.
stable_distribution
testing_distribution
unstable_distribution
my $stable_distribution = $extension->stable_distribution;
my $testing_distribution = $extension->testing_distribution;
my $unstable_distribution = $extension->unstable_distribution;
Returns a WWW::PGXN::Distribution object describing the distribution containing the distribution with the named release status. Returns undef
if no distribution contains the extension with that status.
latest_distribution
Returns a WWW::PGXN::Distribution object describing the distribution in which the latest version of the extension is found. Essentially a convenience method for:
my $meth = $extension->latest . '_distribution';
my $dist = $extension->$meth;
distribution_for_version
my $version_distribution = $extension->distribution_for_version($version);
Returns a WWW::PGXN::Distribution object describing the distribution in which the named version of the extension is found. Returns undef
if no such version of the extension exists.
download_stable_to
download_testing_to
download_unstable_to
my $stable_file = $extension->download_stable_to('/usr/src');
my $testing_file = $extension->download_testing_to('.');
my $unstable_file = $extension->download_unstable_to('mfile.zip');
Downloads the distribution containing the latest version of the extension with the named release status. Pass the name of the file to save to, or the name of a directory. If a directory is specified, the file will be written with the same name as it has on PGXN, such as pgtap-0.24.0.zip
. Either way, the name of the file written will be returned. Regardless of the file's name, it will always be a zip archive.
download_latest_to
my $file = $extension->download_latest_to($file);
Download the distribution containing the latest version of the distribution, regardless of its release status. Essentially a convenience method for:
my $meth = 'download_' . $extension->latest . '_to';
my $file = $extension->$meth('.');
download_version_to
my $file = $extension->download_version_to($version, $file);
Download the distribution containing the specified version of the extension.
See Also
-
The main class to communicate with a PGXN mirror or API server.
Support
This module is stored in an open GitHub repository. Feel free to fork and contribute!
Please file bug reports via GitHub Issues or by sending mail to bug-WWW-PGXN@rt.cpan.org.
Author
David E. Wheeler <david@justatheory.com>
Copyright and License
Copyright (c) 2011-2024 David E. Wheeler. Some Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.