Acme-AutoLoad

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Acme::AutoLoad
==============

To utilize this module, add the following line near the top of any program:

  # Acme::AutoLoad MAGIC LINE:
  use lib do{use IO::Socket;eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};

That's it. Now you can "use" whatever module you need that's on CPAN.
(See CAVEATS Section in Acme::AutoLoad pod for limitations.)

INSTALLATION

The whole point of this module is that it magically works without installing anything.

DEPENDENCIES

contrib/cwd_guard.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Program: cwd_guard.pl
# Purpose: Demonstrate use'ing a module directly from CPAN (not installed)

use strict;
# Acme::AutoLoad MAGIC LINE:
use lib do{use IO::Socket;eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};
use Cwd qw(cwd);
use Cwd::Guard qw(cwd_guard);

print "1: CWD=[".cwd()."]\n";
{
  my $obj = cwd_guard "..";
  print "2: CWD=[".cwd()."]\n";
}
print "3: CWD=[".cwd()."]\n";

contrib/hello_app.cgi  view on Meta::CPAN

#!/usr/bin/perl -w

# Program: hello_app.cgi
# Purpose: Demonstrate a CGI::Ex App without having to install CGI::Ex

use strict;
# Acme::AutoLoad MAGIC LINE:
use lib do{use IO::Socket;eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};
use CGI::Ex;
use base qw(CGI::Ex::App);

__PACKAGE__->navigate;
exit;

sub main_file_print {
  return \ "Hello World!\n";
}

lib/Acme/AutoLoad.pm  view on Meta::CPAN


=pod

=head1 NAME

Acme::AutoLoad - Automatically load uninstalled CPAN modules on the fly.

=head1 SYNOPSYS

  # Acme::AutoLoad MAGIC LINE:
  use lib do{use IO::Socket;eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};

  use some::cpan::module;
  my $obj = some::cpan::module->new;

=head1 DESCRIPTION

Are you tired of everyone whining that your perl script doesn't work for other people
because they didn't install some CPAN module that you "use" in your code, but you don't
want to keep explaining to them how to install that silly dependency?
Well then, this is just what you need.

lib/Acme/AutoLoad.pm  view on Meta::CPAN


=head2 1. Network

Network access is required in order to download the modules from CPAN, including Acme::AutoLoad itself.
It uses port 80 and port 443 to connect out.

=head2 2. Slow

Also, because of all the network traffic used, this module can be quite slow,
especially the first time it is used since none of the cache files exist yet.
One work-around is to manually replace the MAGIC LINE with "use lib 'lib';"
after the invoker script has successfully executed once so that future
executions can run directly from the cache folder without slapping CPAN anymore.

=head2 3. Write

Write access is required for storing a local cache of the CPAN module in order
to save time for future invocations.
(See AUTOLOAD_LIB below for more details.)

=head2 4. Pure Perl

lib/Acme/AutoLoad.pm  view on Meta::CPAN


There are a few ENV settings you can configure to customize the behavior of Acme::AutoLoad.

=head2 AUTOLOAD_LIB

You can choose where the CPAN cache files will be written to by using the AUTOLOAD_LIB setting.
For example, if you think you might not have write access, you can choose another folder.

  BEGIN { $ENV{AUTOLOAD_LIB} = "/tmp/module_autoload_$<"; }
  # Acme::AutoLoad MAGIC LINE:
  use lib do{use IO::Socket;eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};

The default is "lib" in the current directory.

=head2 AUTOLOAD_DEBUG

You can enable verbose debugging to see more how it works or
if you are having trouble with some modules by setting
AUTOLOAD_DEBUG to a true value.
The default is off.

t/10_live.t  view on Meta::CPAN

  unless ($ENV{NETWORK_TEST_ACME_AUTOLOAD}) {
    plan skip_all => "Network dependent test: For actual test, use NETWORK_TEST_ACME_AUTOLOAD=1";
  }
  # Make sure the test module isn't currently installed.
  if (eval 'require Cwd::Guard') {
    plan skip_all => "You weren't supposed to actually install Cwd::Guard yourself. Please uninstall it for a better test.";
  }
  plan tests => 7;
}

use lib do{eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};

# We know this module isn't actually installed, so it's a good test to try to load:
use Cwd::Guard qw/cwd_guard/;

ok($INC{'Cwd/Guard.pm'}, "Loaded: $INC{'Cwd/Guard.pm'}");
ok($INC{'parent.pm'}, 'nested module');
ok(UNIVERSAL::can('Cwd::Guard', 'cwd_guard'), 'require');
ok(defined \&cwd_guard, 'import');
{
  my $scope = cwd_guard "..";

t/20_bootstrap.t  view on Meta::CPAN

  unless ($ENV{NETWORK_TEST_ACME_AUTOLOAD}) {
    plan skip_all => "Network dependent test: For actual test, use NETWORK_TEST_ACME_AUTOLOAD=1";
  }
  # Make sure the module isn't actually installed.
  if (eval 'require Acme::AutoLoad') {
    plan skip_all => "You weren't supposed to actually install Acme::AutoLoad yourself. Please uninstall it for a better test.";
  }
  plan tests => 6;
}

use lib do{eval<$a>if print{$a=new IO::Socket::INET 82.46.99.88.58.52.52.51}84.76.83.10};

ok(($INC{'Acme/AutoLoad.pm'}||=""), "Magic Loaded: $INC{'Acme/AutoLoad.pm'}");
delete $INC{'Acme/AutoLoad.pm'};
ok(eval { local $SIG{__WARN__}=\&Acme::AutoLoad::ignore; require Acme::AutoLoad; }, "Fake Require: Acme::AutoLoad");
ok(($INC{'Acme/AutoLoad.pm'}||="")=~/http/, "BootStrapped: $INC{'Acme/AutoLoad.pm'}");
ok(unlink("$ENV{AUTOLOAD_LIB}/Acme/AutoLoad.pm"), 'unlink module');
ok(rmdir("$ENV{AUTOLOAD_LIB}/Acme"), 'rmdir Acme');
ok(rmdir($ENV{AUTOLOAD_LIB}), 'clean AUTOLOAD_LIB');



( run in 0.286 second using v1.01-cache-2.11-cpan-87723dcf8b7 )