CGI-Application-Structured-Tools

 view release on metacpan or  search on metacpan

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

    my @files = map { 
	$self->_create_t( $_, 
			  $t_files{$_} 
	    ) 
    } keys %t_files;

    # This next part is for the static files dir t/www
    my @dirparts = ( $self->{basedir}, 't', 'www' );
    my $twdir = File::Spec->catdir(@dirparts);
    if ( not -d $twdir ) {
        local @ARGV = $twdir;
        mkpath();
        $self->progress("Created $twdir");
    }
    my $placeholder =
      File::Spec->catfile( @dirparts, 'PUT.STATIC.CONTENT.HERE' );
    $self->create_file( $placeholder, q{ } );
    $self->progress("Created $placeholder");
    push @files, 't/www/PUT.STATIC.CONTENT.HERE';

    return @files;

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

that the behavior of C<perl-critic.t> can be modified.

=cut

sub create_perlcriticrc {
    my $self = shift;

    my @dirparts = ( $self->{basedir}, 't' );
    my $tdir = File::Spec->catdir(@dirparts);
    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }

    my $fname = File::Spec->catfile( @dirparts, 'perlcriticrc' );
    $self->create_file( $fname, $self->perlcriticrc_guts() );
    $self->progress("Created $fname");

    return 't/perlcriticrc';
}

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


sub create_config_pl {
    my $self = shift;

    #my $reldir = join q{/}, File::Spec->splitdir( $self->{templatedir} );

    my @dirparts = ( $self->{basedir}, "config" );
    my $tdir = File::Spec->catdir(@dirparts);

    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }

    my $fname = File::Spec->catfile( $tdir, 'config.pl' );
    $self->create_file( $fname, $self->config_pl_guts() );
    $self->progress("Created $fname");

    return 'config.pl';
}

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


=cut

sub create_create_pl {
    my $self = shift;

    my @dirparts = ( $self->{basedir}, "script" );
    my $tdir = File::Spec->catdir(@dirparts);

    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }

    # template needs template_path not just template dir
    $self->{template_path} = File::Spec->rel2abs( $self->{templatedir} );

    # Store template directory
    my $fname = File::Spec->catfile( $tdir, 'create_controller.pl' );
    $self->create_file( $fname, $self->create_pl_guts() );

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


=cut
sub create_submodule {
    my $self = shift;

    my @distroparts = @{ $self->{distroparts} };

    my @dirparts = ( $self->{basedir}, 'lib', @distroparts, "C" );
    my $tdir = File::Spec->catdir(@dirparts);
    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }
    my $fname =
      File::Spec->catfile( $self->{basedir}, 'lib', @distroparts, "C",
        "Home.pm" );
    $self->create_file( $fname, $self->submodule_guts() );
    $self->progress("Created $fname");

    return $fname;

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

    # For multi level main packages, separate out the path parts
    # from the main module file name part.
    #
    my $last_inx = $#distroparts - 1;
    my @distro_dirparts = @distroparts > 1? @distroparts[0..$last_inx]: ();
    my $distro_namepart = $distroparts[-1] . '.pm';

    my @dirparts = ( $self->{basedir}, 'lib', @distro_dirparts);
    my $tdir = File::Spec->catdir(@dirparts);
    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }
  
    
   
    my $fname =
      File::Spec->catfile( $self->{basedir}, 'lib',  @distro_dirparts, $distro_namepart );

    # need to delete the module starter default file for this customization

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


    # template needs path ucd nder lib to main module
    $self->{distrodir} = File::Spec->catdir( @{ $self->{distroparts} } );

    # Create the script directory if it is not there already

    my @dirparts = ( $self->{basedir}, "script" );
    my $tdir = File::Spec->catdir(@dirparts);

    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }

    # create the user script
    my $fname = File::Spec->catfile( $tdir, 'create_dbic_schema.pl' );
    $self->create_file( $fname, $self->create_create_dbic_guts() );
    chmod 0755, ($fname);
    $self->progress("Created $fname");

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

=cut

sub create_dispatch {
    my $self = shift;

    my @distroparts = split /::/, $self->{main_module};
    my @dirparts = ( $self->{basedir}, 'lib', @distroparts );
    my $tdir = File::Spec->catdir(@dirparts);

    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }
    my $fname =
      File::Spec->catfile( $self->{basedir}, 'lib', @distroparts,
        "Dispatch.pm" );
    $self->create_file( $fname, $self->dispatch_guts() );
    $self->progress("Created $fname");

    return $fname;

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


    # Create the default submodule template folder ("Home")
    # (could use reldir
    my @dirparts = (
        $self->{basedir}, $self->{templatedir}, @{ $self->{distroparts} },
        "C", "Home"
    );
    my $tdir = File::Spec->catdir(@dirparts);

    if ( not -d $tdir ) {
        local @ARGV = $tdir;
        mkpath();
        $self->progress("Created $tdir");
    }

    #TODO We only need one file so remove loop
    my @t_files;
    foreach my $filename ( grep { /\.tmpl$/mx } keys %{ $self->{templates} } ) {
        my $template = $self->{templates}{$filename};
        my $fname = File::Spec->catfile( @dirparts, $filename );
        $self->create_file( $fname, $template );

lib/CGI/Application/Structured/Tools/templates/create_controller.pl  view on Meta::CPAN

	my $last_inx   = $#submodparts - 1;
	my @submoddirs = @submodparts > 1 ? @submodparts[ 0 .. $last_inx ] : ();
	my $submodname = $submodparts[-1];

	my @dirparts = ( 'lib', @distroparts, "C", @submoddirs );
	my $tdir = File::Spec->catdir(@dirparts);

	print "will try to create $tdir\n";
	if ( not -d $tdir )
	{
		local @ARGV = $tdir;
		mkpath();
		print "Created $tdir\n";
	}

	my $out_fname = File::Spec->catfile( @dirparts, "${submodname}.pm" );
	my $tmpl_path = get_template_path("submodule.pm");

	my $htmlt = HTML::Template->new( filename => $tmpl_path );
	$htmlt->param( main_module => DISTRO );
	$htmlt->param( sub_module  => "C::$new_module" );

lib/CGI/Application/Structured/Tools/templates/create_controller.pl  view on Meta::CPAN

	my $last_inx   = $#submodparts - 1;
	my @submoddirs = @submodparts > 1 ? @submodparts[ 0 .. $last_inx ] : ();
	my $submodname = $submodparts[-1];

	my @dirparts = ( 'templates', @distroparts, "C", @submodparts );
	my $tdir = File::Spec->catdir(@dirparts);

	if ( not -d $tdir )
	{
		print "will try to create template directory $tdir\n";
		local @ARGV = $tdir;
		mkpath();
		print "Created $tdir\n";
	}

	my $tmpl_path = get_template_path("index.tmpl");
	my $htmlt     = HTML::Template->new( filename => $tmpl_path );
	my $out_fname = File::Spec->catfile( @dirparts, "index.tmpl" );

	create_file( $out_fname, $htmlt->output );



( run in 1.333 second using v1.01-cache-2.11-cpan-49f99fa48dc )