Show
Ignore:
Timestamp:
05/09/08 17:45:17 (7 months ago)
Author:
charsbar
Message:

Acme-CPANAuthors: better cpan config loading (ripped and modified from CPAN::HandleConfig?)

Location:
lang/perl/Acme-CPANAuthors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Acme-CPANAuthors/trunk/Changes

    r11294 r11297  
    330.02 2008/05/** 
    44  - made Acme::CPANAuthors::(Specific)->authors context sensitive. 
     5  - better cpan config loading 
    56 
    670.01 2007/12/26 
  • lang/perl/Acme-CPANAuthors/trunk/lib/Acme/CPANAuthors/Utils.pm

    r3606 r11297  
    4242  my ($dir, $basename) = @_; 
    4343 
    44   _require_cpan_config(); 
     44  _require_myconfig_or_config(); 
     45  croak "You might want to configure CPAN first." 
     46    unless $CPAN::Config && ref $CPAN::Config eq 'HASH'; 
    4547 
    46   my $source_dir   = $CPAN::Config->{keep_source_where}; 
     48  my $source_dir = $CPAN::Config->{keep_source_where}; 
    4749  my $file = _catfile( $source_dir, '/', $dir, '/', $basename ); 
    4850  unless ( -f $file ) { 
     
    5456} 
    5557 
    56 sub _require_cpan_config () { 
    57   if ( $INC{'CPAN/MyConfig.pm'} ) { 
    58     eval { require CPAN::MyConfig }; 
    59     if ( $@ and $@ !~ m{Can't locate CPAN/MyConfig\.pm} ) { 
    60       croak "CPAN::MyConfig error: $@"; 
    61     } 
     58sub _require_myconfig_or_config () { # from CPAN::HandleConfig 
     59  return if $INC{'CPAN/MyConfig.pm'}; 
     60  local @INC = @INC; 
     61 
     62  eval { require File::HomeDir 0.52 }; 
     63  my $home = $@ ? $ENV{HOME} : File::HomeDir->my_data; 
     64 
     65  unshift @INC, File::Spec->catdir($home, '.cpan'); 
     66 
     67  eval { require CPAN::MyConfig }; 
     68  if ( $@ and $@ !~ m{Can't locate CPAN/MyConfig\.pm} ) { 
     69    croak "CPAN::MyConfig error: $@"; 
    6270  } 
    6371  unless ( $INC{'CPAN/MyConfig.pm'} ) {