Module-Starter

 view release on metacpan or  search on metacpan

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

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 {
            $_ !~ /
                      \A
                      (?>
                          (?:           # Author
                              [^\s<>]+
                              \s+
                          )+
                      )
                      <[^<>]+>          # Email
                      \s*
                      \z
                  /x;
        } @{$self->{author}};
    
    $self->{license}      ||= 'artistic2';
    $self->{minperl}      ||= '5.008003';
    $self->{ignores_type} ||= ['generic'];
    $self->{manifest_skip} = !! grep { /manifest/ } @{ $self->{ignores_type} };
    
    $self->{license_record} = $self->_license_record();

    $self->{main_module} = $modules[0];
    if ( not defined $self->{distro} or not length $self->{distro} ) {
        $self->{distro} = $self->{main_module};
        $self->{distro} =~ s/::/-/g;
    }

    $self->{basedir} = $self->{dir} || $self->{distro};
    $self->create_basedir;

    my @files;
    push @files, $self->create_modules( @modules );

    push @files, $self->create_t( @modules );
    push @files, $self->create_ignores;
    my %build_results = $self->create_build();
    push(@files, @{ $build_results{files} } );

    push @files, $self->create_Changes;
    push @files, $self->create_README( $build_results{instructions} );
    push @files, $self->create_LICENSE if $self->{genlicense};

    $self->create_MANIFEST( $build_results{'manifest_method'} ) unless ( $self->{manifest_skip} );
    # TODO: put files to ignore in a more standard form?

    return @files;



( run in 3.274 seconds using v1.01-cache-2.11-cpan-524268b4103 )