MyCPAN-Indexer

 view release on metacpan or  search on metacpan

lib/MyCPAN/App/BackPAN/Indexer.pm  view on Meta::CPAN

			$config->set(
				"${subdir}_report_subdir",
				catfile( $config->get( 'report_dir' ), $subdir ),
				);
			}
		}

	# Adjust for some environment variables
	my $log4perl_file =
		$ENV{'MYCPAN_LOG4PERL_FILE'}
			||
		$coordinator->get_note( 'log4perl_file' )
			;

	# Adjust for some environment variables
	$ENV{'PREFER_BIN'} = 1 if $config->get( 'prefer_bin' );

	$config->set( 'log4perl_file', $log4perl_file ) if $log4perl_file;

	return 1;
	}

=item new

=cut

sub new {
	my( $class, @args ) = @_;

	bless { args => [ @args ] }, $class;
	}

=item get_coordinator

=item set_coordinator

Convenience methods to deal with the coordinator

=cut

sub get_coordinator { $_[0]->{coordinator}         }
sub set_coordinator { $_[0]->{coordinator} = $_[1] }

=item process_options

Handle the configuration directives from the command line and set default
values:

	-f  config_file     Default is $script.conf
	-l  log4perl_file   Default is $script.log4perl
	-c                  Print the config and exit

=cut

sub process_options {
	my( $application ) = @_;

	my $run_dir = dirname( $0 );
	( my $script  = basename( $0 ) ) =~ s/\.\w+$//;

	local @ARGV = @{ $application->{args} };
	getopts( 'cl:f:', \ my %Options );

	# other things might want to use things from @ARGV, and
	# we just removed the bits that we wanted.
	$application->{args} = [ @ARGV ]; # XXX: yuck

	$Options{f} ||= catfile( $run_dir, "$script.conf" );

	#$Options{l} ||= catfile( $run_dir, "$script.log4perl" );

	$application->{options} = \%Options;
	}

sub get_option { $_[0]->{options}{$_[1]} }

=item setup_coordinator

Set up the coordinator object and set its initial values.

=cut

sub setup_coordinator {
	my( $application ) = @_;

	require MyCPAN::Indexer::Coordinator;
	my $coordinator = MyCPAN::Indexer::Coordinator->new;

	$coordinator->set_application( $application );
	$application->set_coordinator( $coordinator );

	$coordinator->set_note( 'UUID',          $application->get_uuid() );
	$coordinator->set_note( 'tempdirs',      [] );
	$coordinator->set_note( 'log4perl_file', $application->get_option( 'l' ) );

	$coordinator;
	}

=item handle_config

Load and set the configuration file.

You can set the configuration filename with the C<-f> option on the command
line.

You can print the configuration and exit with the C<-c> option.

=cut

sub handle_config {
	my( $application ) = @_;

	# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
	# Adjust config based on run parameters
	my $config = $application->init_config( $application->get_option('f') );
	$application->get_coordinator->set_config( $config );

	$application->adjust_config;

	# If this is a dry run, just print the directives and exit
	if( $application->get_option( 'c' ) ) {



( run in 2.272 seconds using v1.01-cache-2.11-cpan-ad19def0cd9 )