Browse files

Enable PERL5_CPANPLUS_HOME environment variable for changing .cpanplu…

…s location
  • Loading branch information...
1 parent ec523d4 commit ad3bb542946f68abe386b2dc7841d982582cf8e3 @bingos bingos committed May 9, 2012
Showing with 65 additions and 0 deletions.
  1. +1 −0 MANIFEST
  2. +62 −0 lib/CPANPLUS/Config/HomeEnv.pm
  3. +2 −0 t/inc/conf.pl
View
1 MANIFEST
@@ -61,6 +61,7 @@ lib/CPANPLUS.pm
lib/CPANPLUS/Backend.pm
lib/CPANPLUS/Backend/RV.pm
lib/CPANPLUS/Config.pm
+lib/CPANPLUS/Config/HomeEnv.pm
lib/CPANPLUS/Configure.pm
lib/CPANPLUS/Configure/Setup.pm
lib/CPANPLUS/Dist.pm
View
62 lib/CPANPLUS/Config/HomeEnv.pm
@@ -0,0 +1,62 @@
+package CPANPLUS::Config::HomeEnv;
+
+use strict;
+use File::Spec;
+use vars qw($VERSION);
+
+$VERSION = '0.04';
+
+sub setup {
+ my $conf = shift;
+ $conf->set_conf( base => File::Spec->catdir( $ENV{PERL5_CPANPLUS_HOME}, '.cpanplus' ) )
+ if $ENV{PERL5_CPANPLUS_HOME};
+ return 1;
+}
+
+qq'Wherever I hang my hat is home';
+
+__END__
+
+=head1 NAME
+
+CPANPLUS::Config::HomeEnv - Set the environment for the CPANPLUS base dir
+
+=head1 SYNOPSIS
+
+ export PERL5_CPANPLUS_HOME=/home/moo/perls/conf/perl-5.8.9/
+
+=head1 DESCRIPTION
+
+CPANPLUS::Config::HomeEnv is a L<CPANPLUS::Config> file that allows the CPANPLUS user to
+specify where L<CPANPLUS> gets its configuration from.
+
+Setting the environment variable C<PERL5_CPANPLUS_HOME> to a path location, determines
+where the C<.cpanplus> directory will be located.
+
+=head1 METHODS
+
+=over
+
+=item C<setup>
+
+Called by L<CPANPLUS::Configure>.
+
+=back
+
+=head1 AUTHOR
+
+Chris C<BinGOs> Williams <chris@bingosnet.co.uk>
+
+Contributions and patience from Jos Boumans the L<CPANPLUS> guy!
+
+=head1 LICENSE
+
+Copyright E<copy> Chris Williams and Jos Boumans.
+
+This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.
+
+=head1 SEE ALSO
+
+L<CPANPLUS>
+
+=cut
View
2 t/inc/conf.pl
@@ -131,6 +131,8 @@ sub gimme_conf {
### don't load any other configs than the heuristic one
### during tests. They might hold broken/incorrect data
### for our test suite. Bug [perl #43629] showed this.
+ local $ENV{PERL5_CPANPLUS_HOME} = '';
+
my $conf = CPANPLUS::Configure->new( load_configs => 0 );
my $dummy_cpan = dummy_cpan_dir();

0 comments on commit ad3bb54

Please sign in to comment.