NAME
CPAN::Access::AdHoc::Util - Utility functions for CPAN::Access::AdHoc
SYNOPSIS
use CPAN::Access::AdHoc::Util;
say 'The CPAN default plugins are ',
join ', ', CPAN::Access::AdHoc::Util::plugins(
'CPAN::Access::AdHoc::Default::CPAN' );
DESCRIPTION
This module provides utility functions to CPAN::Access::AdHoc. It is private to the CPAN-Access-AdHoc
distribution. Documentation is for the benefit of the author only.
SUBROUTINES
This module provides the following public subroutines (which are nonetheless private to the CPAN-Access-AdHoc
distribution):
__attr
This subroutine/method returns the hash element of its argument which is named after the caller's name space. This element is initialized to an empty hash if necessary.
__expand_distribution_path
This subroutine takes as its argument a putative distribution path relative to the authors/id/ directory. If it does not begin with the two levels of directory that are derived from the author name, these are added. The expanded path is returned.
__guess_media_type
__guess_media_type( $resp, $path );
This subroutine guesses the media type and encoding.
The first argument is an HTTP::Response object such as would have been returned by a successful fetch of the data.
The second argument is optional, and is the URL or path used to fetch the data. If the second argument is defined, it sets the Content-Location
header in $resp
. If $path
is not defined, it defaults to $resp->header( 'Content-Location' )
, and an exception is thrown if there is none.
The method loads the Content-Type
and Content-Encoding
headers of the $resp
object with its best guess at what they are. Nothing is returned.
Note that the arguments are reversed from LWP::MediaTypes::guess_media_type()
.
__load
This subroutine takes as its arguments one or more module names, and loads them.
__whinge
This subroutine loads Carp, and then passes its arguments to carp()
.
__wail
This subroutine loads Carp, and then passes its arguments to croak()
.
__weep
This subroutine loads Carp, and then passes its arguments to confess()
, prefixed by the text 'Programming Error - '
.
SUPPORT
Support is by the author. Please file bug reports at http://rt.cpan.org, or in electronic mail to the author.
AUTHOR
Thomas R. Wyant, III wyant at cpan dot org
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.