Module-Starter

 view release on metacpan or  search on metacpan

lib/Module/Starter/Simple.pm  view on Meta::CPAN

package Module::Starter::Simple;

use 5.008003;
use strict;
use warnings;

use Cwd 'cwd';
use File::Path qw( make_path );
use File::Spec ();
use Carp qw( carp confess croak );
use Module::Runtime qw( require_module );

use Module::Starter::BuilderSet;

=head1 NAME

Module::Starter::Simple - a simple, comprehensive Module::Starter plugin

=head1 VERSION

version 1.82

=cut

our $VERSION = '1.82';

=head1 SYNOPSIS

    use Module::Starter qw(Module::Starter::Simple);

    Module::Starter->create_distro(%args);

=head1 DESCRIPTION

Module::Starter::Simple is a plugin for Module::Starter that will perform all
the work needed to create a distribution.  Given the parameters detailed in
L<Module::Starter>, it will create content, create directories, and populate
the directories with the required files.

=head1 CLASS METHODS

=head2 C<< new(%args) >>

This method is called to construct and initialize a new Module::Starter object.
It is never called by the end user, only internally by C<create_distro>, which
creates ephemeral Module::Starter objects.  It's documented only to call it to
the attention of subclass authors.

=cut

sub new {
    my $class = shift;
    return bless { @_ } => $class;
}

=head1 OBJECT METHODS

All the methods documented below are object methods, meant to be called
internally by the ephemeral objects created during the execution of the class
method C<create_distro> above.

=head2 postprocess_config

A hook to do any work after the configuration is initially processed.

=cut

sub postprocess_config { 1 };

=head2 pre_create_distro

A hook to do any work right before the distro is created.

=cut

sub pre_create_distro { 1 };

=head2 C<< create_distro(%args) >>

This method works as advertised in L<Module::Starter>.

=cut

sub create_distro {
    my $either = shift;

    ( ref $either ) or $either = $either->new( @_ );

    my $self    = $either;
    my $modules = $self->{modules} || [];
    my @modules = map { split /,/ } @{$modules};
    croak "No modules specified.\n" unless @modules;
    for (@modules) {
        croak "Invalid module name: $_" unless /\A[a-z_]\w*(?:::[\w]+)*\Z/i;
    }

    if ( ( not @{ $self->{author} } ) && ( $^O ne 'MSWin32' ) ) {
        ( $self->{author} ) = split /,/, ( getpwuid $> )[6];
        $self->{author} = [ 
            exists $ENV{EMAIL} 
                ? "$self->{author} <$ENV{EMAIL}>" 
                : $self->{author} 
        ] if defined $self->{author};
    }

    croak "Must specify one or more authors\n" 
        unless defined $self->{author}
        && ref($self->{author}) eq 'ARRAY'
        && @{$self->{author}} > 0;

    croak "author strings must be in the format: 'Author Name <author-email\@domain.tld>'"
        if grep {
            $_ !~ /



( run in 0.670 second using v1.01-cache-2.11-cpan-39bf76dae61 )