Module-Starter-Plugin-CGIApp
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Module/Starter/Plugin/CGIApp.pm view on Meta::CPAN
);
Module::Starter->create_distro(%args);
=head1 ABSTRACT
This is a plugin for L<Module::Starter|Module::Starter> that builds you a skeleton
L<CGI::Application|CGI::Application> module with all the extra files needed to package it for
CPAN. You can customize the output using L<HTML::Template|HTML::Template>.
=cut
package Module::Starter::Plugin::CGIApp;
use base 'Module::Starter::Simple';
use warnings;
use strict;
use Carp qw( croak );
use English qw( -no_match_vars );
use File::Basename;
use File::Path qw( mkpath );
use File::Spec ();
use Module::Starter::BuilderSet;
use HTML::Template;
=head1 VERSION
This document describes version 0.44
=cut
our $VERSION = '0.44';
=head1 DESCRIPTION
This module subclasses L<Module::Starter::Simple|Module::Starter::Simple> and
includes functionality similar to L<Module::Starter::Plugin::Template|Module::Starter::Plugin::Template>.
This document only describes the methods which are overridden from those modules or are new.
Only developers looking to extend this module need to read this. If you just
want to use L<Module::Starter::Plugin::CGIApp|Module::Starter::Plugin::CGIApp>, read the docs for
L<cgiapp-starter|cgiapp-starter> or L<titanium-starter|titanium-starter> instead.
=head1 METHODS
=head2 new ( %args )
This method calls the C<new> supermethod from
L<Module::Starter::Plugin::Simple|Module::Starter::Plugin::Simple> and then
initializes the template store. (See C<templates>.)
=cut
sub new {
my ( $proto, %opts ) = @_;
my $class = ref $proto || $proto;
my $self = $class->SUPER::new(%opts);
$self->{templates} = { $self->templates };
return bless $self => $class;
}
=head2 create_distro ( %args )
This method works as advertised in L<Module::Starter|Module::Starter>.
=cut
sub create_distro {
my ( $either, %opts ) = @_;
( ref $either ) or $either = $either->new(%opts);
my $self = $either;
# Supposedly the *-starter scripts can handle multiple --builder options
# but this doesn't work (and IMO doesn't make sense anyway.) So in the
# case multiple builders were specified, we just pick the first one.
if ( ref $self->{builder} eq 'ARRAY' ) {
$self->{builder} = $self->{builder}->[0];
}
my @modules;
foreach my $arg ( @{ $self->{modules} } ) {
push @modules, ( split /[,]/msx, $arg );
}
if ( !@modules ) {
croak "No modules specified.\n";
}
for (@modules) {
if ( !/\A [[:alpha:]_] \w* (?: [:] [:] [\w]+ )* \Z /imsx ) {
croak "Invalid module name: $_";
}
}
$self->{modules} = \@modules;
if ( !$self->{author} ) {
croak "Must specify an author\n";
}
if ( !$self->{email} ) {
croak "Must specify an email address\n";
}
( $self->{email_obfuscated} = $self->{email} ) =~ s/@/ at /msx;
$self->{license} ||= 'perl';
$self->{main_module} = $self->{modules}->[0];
if ( !$self->{distro} ) {
$self->{distro} = $self->{main_module};
$self->{distro} =~ s/::/-/gmsx;
}
$self->{basedir} = $self->{dir} || $self->{distro};
$self->create_basedir;
my @files;
push @files, $self->create_modules( @{ $self->{modules} } );
push @files, $self->create_t( @{ $self->{modules} } );
push @files, $self->create_xt( @{ $self->{modules} } );
push @files, $self->create_tmpl();
my %build_results = $self->create_build();
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.847 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )