NAME

CPAN::Access::AdHoc::Archive::Null - Archive-like wrapper for un-archived data.

SYNOPSIS

use CPAN::Access::AdHoc::Archive::Null;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new();
my $resp = $ua->get( ... );
my $tar = CPAN::Access::AdHoc::Archive::Null->new(
    content => \( $resp->content() ),
    encoding => $resp->header( 'Content-Encoding' ),
);

DESCRIPTION

This class wraps an un-archived file or text block, providing a CPAN::Access::AdHoc::Archive-compliant interface. It is private to the CPAN-Access-AdHoc package.

METHODS

This class supports the following public methods:

new

This static method instantiates the object, and possibly loads it. The supported arguments are:

content

This is the content to be loaded into the object. A scalar reference is assumed to be the literal content. A non-reference is assumed to be the file name. Any other value is unsupported.

If this argument is a scalar reference, the file name is set to 'unknown', and the contents are accessed under that name.

encoding

This is the MIME encoding of the content. It is ignored if the content is not present.

mtime

This is the modification time of the content. If the content is not a reference, it is taken as a file name, so this argument is ignored and the modification time of the file is used instead.

path

This is intended to be a path to the content. If not specified, and the content argument is a file name (i.e. not a reference), this defaults to the content argument.

base_directory

Because there is no real distribution inside this wrapper, we have no real place to get a base directory. So we have to invent one.

For files that appear to be single-file unpackaged distributions (that is, with paths like authors/id/T/TO/TOMC/scripts/whenon.dir/LastLog/File.pm.gz), the base directory is taken to be the directory portion of the path which is to the right of the author directory; that is, scripts/whenon.dir/LastLog/ in the above example.

For other files, the base directory is simply the directory portion of the file path relative to the base of the CPAN mirror.

extract

Because there is no real distribution inside this wrapper, we have to do our own extract functionality.

This simply creates the base directory tree and then extracts the file into it.

get_item_content

This method returns the content of the named item in the archive. Because there can only ever be one file in the pseudo-archive, if the argument is undef, the content of that file is returned.

list_contents

This method lists the contents of the archive. It always returns exactly one name.

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.