CGI-Application-Structured-Tools

 view release on metacpan or  search on metacpan

lib/CGI/Application/Structured/Tools/Starter.pm  view on Meta::CPAN


    
=head1 ABSTRACT

The prefered method for using this module is via the L<scripts/cas-starter.pl> script.

=cut

package CGI::Application::Structured::Tools::Starter;
use base 'Module::Starter::Simple';
use warnings;
use strict;
use Carp qw( croak );
use English qw( -no_match_vars );
use ExtUtils::Command qw( mkpath );
use File::Basename;
use File::Spec ();

use HTML::Template;

=head1 VERSION

Version 0.015

=cut

our $VERSION = '0.015';

=head1 DESCRIPTION

This is a plugin for L<Module::Starter> that builds a skeleton 
L<CGI::Application::Structured> module with all the extra files needed to package it for 
CPAN. It also generates 
  - an CGI::Application::Structured controller base class for your modules
  - a customized CGI::Application::Dispatch subclass
  - a preconfigured development config file 
  - a server.pl that runs out of the box
  - helper scripts to generate Controller modules subclasses
  - a helper script to generate DBIx::Class schema and result classes.

This module is inspired L<Module::Starter::Plugin::CGIApp> by Jaldhar H. Vyas .


=head1 METHODS

=head2 new ( %args )

This method calls the C<new> supermethod from 
L<Module::Starter::Plugin::Template> and then initializes the template store 
and renderer. (See C<templates> and C<renderer> below.)

=cut

sub new {
     my ( $class, @opts ) = @_;
    
     my $self = $class->SUPER::new(@opts);

     $self->{templates} = { $self->templates };
     $self->{renderer}  = $self->renderer;
     return bless $self => $class;
 }

=head2 create_distro ( %args ) 

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

=cut

sub create_distro {
    my ( $either, @opts ) = @_;

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



    # This plugin only works to create one module.  This is
    # hangover from borrowed code and should be fixed to remove
    # the impression that multiple modules can be created at once.
    my @modules = map { split /,/mx } @{ $self->{modules} };
    
    croak "No modules specified.\n" if ( !@modules );

    croak "No modules specified.\n" unless ( @modules );

    die "Only one module can be created.\n"
      unless( @modules == 1 );

    croak "Invalid module name: ". $modules[0]
	if ( $modules[0] !~ /\A[a-z_]\w*(?:::[\w]+)*\Z/imx );

    
    croak "Must specify an author\n"
	unless ( $self->{author} );

    croak "Must specify an email address\n"
	unless ( $self->{email} );

    ( $self->{email_obfuscated} = $self->{email} ) =~ s/@/ at /mx;

    $self->{license} ||= 'perl';

    $self->{main_module} = $self->{modules}->[0];

    unless ( $self->{distro} ) {
        $self->{distro} = $self->{main_module};
        $self->{distro} =~ s/::/-/gmx;
    }

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

    # split out module package parts for ease of creating
    # directory structure.
    my @distroparts = split /-/mx, $self->{distro};
    $self->{distroparts} = \@distroparts;

    # templatedir is used in config_pl_guts
    $self->{templatedir} = File::Spec->catdir('templates');

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.475 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )