CPAN::Access::AdHoc::Archive::Null - Archive-like wrapper for un-archived data.
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' ), );
This class wraps an un-archived file or text block, providing a
CPAN::Access::AdHoc::Archive-compliant interface. It is private to the
This class supports the following public methods:
This static method instantiates the object, and possibly loads it. The supported arguments are:
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.
This is the MIME encoding of the content. It is ignored if the content is not present.
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.
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.
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.
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.
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.
This method lists the contents of the archive. It always returns exactly one name.
Support is by the author. Please file bug reports at http://rt.cpan.org, or in electronic mail to the author.
Thomas R. Wyant, III wyant at cpan dot org
Copyright (C) 2012-2014 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.