CPANPLUS
view release on metacpan or search on metacpan
lib/CPANPLUS/Configure.pm view on Meta::CPAN
if( eval { load $plugin; 1 } ) {
msg(loc(" Loaded '%1' (%2)",
$plugin, Module::Loaded::is_loaded( $plugin ) ), 0);
} else {
error(loc(" Error loading '%1': %2", $plugin, $@));
}
}
if( $@ ) {
error(loc("Could not load '%1': %2", $plugin, $@));
next;
}
my $sub = $plugin->can('setup');
$sub->( $self ) if $sub;
}
}
### did one of the plugins change the base dir? then we should
### scan the dirs again
if( $cur_base ne $self->get_conf('base') ) {
msg(loc("Base dir changed from '%1' to '%2', rescanning",
$cur_base, $self->get_conf('base')), 0);
$self->init( @_, rescan => 1 );
}
### clean up the paths once more, just in case
$obj->_clean_up_paths;
### XXX in case the 'lib' param got changed, we need to
### add that now, or it's not propagating ;(
{ my $lib = $self->get_conf('lib');
my %inc = map { $_ => $_ } @INC;
for my $l ( @$lib ) {
push @INC, $l unless $inc{$l};
}
$self->_lib( \@INC );
}
return 1;
}
}
=pod
=head2 can_save( [$config_location] )
Check if we can save the configuration to the specified file.
If no file is provided, defaults to your personal config.
Returns true if the file can be saved, false otherwise.
=cut
sub can_save {
my $self = shift;
my $file = shift || CONFIG_USER_FILE->();
return 1 unless -e $file;
chmod 0644, $file;
return (-w $file);
}
=pod
=head2 $file = $conf->save( [$package_name] )
Saves the configuration to the package name you provided.
If this package is not C<CPANPLUS::Config::System>, it will
be saved in your C<.cpanplus> directory, otherwise it will
be attempted to be saved in the system wide directory.
If no argument is provided, it will default to your personal
config.
Returns the full path to the file if the config was saved,
false otherwise.
=cut
sub _config_pm_to_file {
my $self = shift;
my $pm = shift or return;
my $dir = shift || CONFIG_USER_LIB_DIR->();
### only 3 types of files know: home, system and 'other'
### so figure out where to save them based on their type
my $file;
if( $pm eq CONFIG_USER ) {
$file = CONFIG_USER_FILE->();
} elsif ( $pm eq CONFIG_SYSTEM ) {
$file = CONFIG_SYSTEM_FILE->();
### third party file
} else {
my $cfg_pkg = CONFIG . '::';
unless( $pm =~ /^$cfg_pkg/ ) {
error(loc(
"WARNING: Your config package '%1' is not in the '%2' ".
"namespace and will not be automatically detected by %3",
$pm, $cfg_pkg, 'CPANPLUS'
));
}
$file = File::Spec->catfile(
$dir,
split( '::', $pm )
) . '.pm';
}
return $file;
}
sub save {
my $self = shift;
my $pm = shift || CONFIG_USER;
my $savedir = shift || '';
( run in 0.637 second using v1.01-cache-2.11-cpan-39bf76dae61 )