missing changes
[catagits/Catalyst-Devel.git] / lib / Catalyst / Helper.pm
index 3c617cf..835c061 100644 (file)
@@ -1,19 +1,21 @@
 package Catalyst::Helper;
 
 use strict;
+use warnings;
 use base 'Class::Accessor::Fast';
 use Config;
 use File::Spec;
 use File::Path;
-use IO::File;
 use FindBin;
+use IO::File;
+use POSIX 'strftime';
 use Template;
+use Catalyst::Devel;
 use Catalyst::Utils;
 use Catalyst::Exception;
 
 my %cache;
 
-our $VERSION = '1.00';
 
 =head1 NAME
 
@@ -25,7 +27,7 @@ See L<Catalyst::Manual::Intro>
 
 =head1 DESCRIPTION
 
-Bootstrap a Catalyst application. Autogenerates scripts
+Bootstrap a Catalyst application. Autogenerates scripts.
 
 =head2 METHODS
 
@@ -72,8 +74,9 @@ sub mk_app {
     $self->{dir             } =~ s/\:\:/-/g;
     $self->{script          } = File::Spec->catdir( $self->{dir}, 'script' );
     $self->{appprefix       } = Catalyst::Utils::appprefix($name);
+    $self->{appenv          } = Catalyst::Utils::class2env($name);
     $self->{startperl       } = "#!$Config{perlpath} -w";
-    $self->{scriptgen       } = $Catalyst::CATALYST_SCRIPT_GEN || 4;
+    $self->{scriptgen       } = $Catalyst::Devel::CATALYST_SCRIPT_GEN || 4;
     $self->{catalyst_version} = $Catalyst::VERSION;
     $self->{author          } = $self->{author} = $ENV{'AUTHOR'}
       || eval { @{ [ getpwuid($<) ] }[6] }
@@ -385,7 +388,7 @@ sub _mk_readme {
 sub _mk_changes {
     my $self = shift;
     my $dir  = $self->{dir};
-    my $time = localtime time;
+    my $time = strftime('%Y-%m-%d %H:%M:%S', localtime time);
     $self->render_file( 'changes', "$dir\/Changes", { time => $time } );
 }
 
@@ -532,6 +535,8 @@ Sebastian Riedel, C<sri@oook.de>
 This library is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
+=begin pod_to_ignore
+
 =cut
 
 1;
@@ -543,7 +548,8 @@ package [% name %];
 use strict;
 use warnings;
 
-#
+use Catalyst::Runtime '5.70';
+
 # Set flags and add plugins for the application
 #
 #         -Debug: activates the debug mode for very useful log messages
@@ -551,24 +557,25 @@ use warnings;
 #                 application's home directory
 # Static::Simple: will serve static files from the application's root 
 #                 directory
-#
+
 use Catalyst qw/-Debug ConfigLoader Static::Simple/;
 
 our $VERSION = '0.01';
 
+# Configure the application. 
 #
-# Configure the application 
-#
+# Note that settings in [% appprefix %].yml (or other external
+# configuration file that you set up manually) take precedence
+# over this when using ConfigLoader. Thus configuration
+# details given here can function as a default configuration,
+# with a external configuration file acting as an override for
+# local deployment.
+
 __PACKAGE__->config( name => '[% name %]' );
 
-#
 # Start the application
-#
 __PACKAGE__->setup;
 
-#
-# IMPORTANT: Please look into [% rootname %] for more
-#
 
 =head1 NAME
 
@@ -580,7 +587,7 @@ __PACKAGE__->setup;
 
 =head1 DESCRIPTION
 
-Catalyst based application.
+[enter your description here]
 
 =head1 SEE ALSO
 
@@ -613,15 +620,11 @@ __PACKAGE__->config->{namespace} = '';
 
 =head1 NAME
 
-[% rootname %] - Root Controller for this Catalyst based application
-
-=head1 SYNOPSIS
-
-See L<[% name %]>.
+[% rootname %] - Root Controller for [% name %]
 
 =head1 DESCRIPTION
 
-Root Controller for this Catalyst based application.
+[enter your description here]
 
 =head1 METHODS
 
@@ -631,9 +634,6 @@ Root Controller for this Catalyst based application.
 
 =cut
 
-#
-# Output a friendly welcome message
-#
 sub default : Private {
     my ( $self, $c ) = @_;
 
@@ -641,19 +641,13 @@ sub default : Private {
     $c->response->body( $c->welcome_message );
 }
 
-#
-# Uncomment and modify this end action after adding a View component
-#
-#=head2 end
-#
-#=cut
-#
-#sub end : Private {
-#    my ( $self, $c ) = @_;
-#
-#    # Forward to View unless response body is already defined
-#    $c->forward( $c->view('') ) unless $c->response->body;
-#}
+=head2 end
+
+Attempt to render a view, if needed.
+
+=cut 
+
+sub end : ActionClass('RenderView') {}
 
 =head1 AUTHOR
 
@@ -673,9 +667,12 @@ use inc::Module::Install;
 name '[% dir %]';
 all_from '[% path %]';
 
-requires Catalyst => '[% catalyst_version %]';
-requires YAML; # This should reflect the config file format you've chosen
-               # See Catalyst::Plugin::ConfigLoader for supported formats
+requires 'Catalyst::Runtime' => '[% catalyst_version %]';
+requires 'Catalyst::Plugin::ConfigLoader';
+requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Action::RenderView';
+requires 'YAML'; # This should reflect the config file format you've chosen
+                 # See Catalyst::Plugin::ConfigLoader for supported formats
 catalyst;
 
 install_script glob('script/*.pl');
@@ -725,6 +722,7 @@ __cgi__
 BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
 
 use strict;
+use warnings;
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 use [% name %];
@@ -743,7 +741,7 @@ See L<Catalyst::Manual>
 
 =head1 DESCRIPTION
 
-Run a Catalyst application as cgi.
+Run a Catalyst application as a cgi script.
 
 =head1 AUTHOR
 
@@ -751,7 +749,6 @@ Sebastian Riedel, C<sri@oook.de>
 
 =head1 COPYRIGHT
 
-Copyright 2004 Sebastian Riedel. All rights reserved.
 
 This library is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
@@ -763,6 +760,7 @@ __fastcgi__
 BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
 
 use strict;
+use warnings;
 use Getopt::Long;
 use Pod::Usage;
 use FindBin;
@@ -770,7 +768,7 @@ use lib "$FindBin::Bin/../lib";
 use [% name %];
 
 my $help = 0;
-my ( $listen, $nproc, $pidfile, $manager, $detach );
+my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );
  
 GetOptions(
     'help|?'      => \$help,
@@ -779,6 +777,7 @@ GetOptions(
     'pidfile|p=s' => \$pidfile,
     'manager|M=s' => \$manager,
     'daemon|d'    => \$detach,
+    'keeperr|e'   => \$keep_stderr,
 );
 
 pod2usage(1) if $help;
@@ -789,6 +788,7 @@ pod2usage(1) if $help;
         pidfile => $pidfile, 
         manager => $manager,
         detach  => $detach,
+       keep_stderr => $keep_stderr,
     }
 );
 
@@ -817,6 +817,8 @@ pod2usage(1) if $help;
    -M -manager   specify alternate process manager
                  (FCGI::ProcManager sub-class)
                  or empty string to disable
+   -e -keeperr   send error messages to STDOUT, not
+                 to the webserver
 
 =head1 DESCRIPTION
 
@@ -825,11 +827,10 @@ Run a Catalyst application as fastcgi.
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
 
 =head1 COPYRIGHT
 
-Copyright 2004 Sebastian Riedel. All rights reserved.
-
 This library is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
@@ -840,9 +841,11 @@ __server__
 BEGIN { 
     $ENV{CATALYST_ENGINE} ||= 'HTTP';
     $ENV{CATALYST_SCRIPT_GEN} = [% scriptgen %];
+    require Catalyst::Engine::HTTP;
 }  
 
 use strict;
+use warnings;
 use Getopt::Long;
 use Pod::Usage;
 use FindBin;
@@ -852,11 +855,11 @@ my $debug             = 0;
 my $fork              = 0;
 my $help              = 0;
 my $host              = undef;
-my $port              = 3000;
+my $port              = $ENV{[% appenv %]_PORT} || $ENV{CATALYST_PORT} || 3000;
 my $keepalive         = 0;
-my $restart           = 0;
+my $restart           = $ENV{[% appenv %]_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
 my $restart_delay     = 1;
-my $restart_regex     = '\.yml$|\.yaml$|\.pm$';
+my $restart_regex     = '(?:/|^)(?!\.#).+(?:\.yml$|\.yaml$|\.pm)$';
 my $restart_directory = undef;
 
 my @argv = @ARGV;
@@ -876,7 +879,7 @@ GetOptions(
 
 pod2usage(1) if $help;
 
-if ( $restart ) {
+if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
     $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
 }
 if ( $debug ) {
@@ -915,7 +918,7 @@ require [% name %];
       -host           host (defaults to all)
    -p -port           port (defaults to 3000)
    -k -keepalive      enable keep-alive connections
-   -r -restart        restart when files got modified
+   -r -restart        restart when files get modified
                       (defaults to false)
    -rd -restartdelay  delay between file checks
    -rr -restartregex  regex match files that trigger
@@ -936,11 +939,10 @@ Run a Catalyst Testserver for this application.
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
 
 =head1 COPYRIGHT
 
-Copyright 2004 Sebastian Riedel. All rights reserved.
-
 This library is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
@@ -949,6 +951,7 @@ __test__
 [% startperl %]
 
 use strict;
+use warnings;
 use Getopt::Long;
 use Pod::Usage;
 use FindBin;
@@ -991,11 +994,10 @@ Run a Catalyst action from the command line.
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
 
 =head1 COPYRIGHT
 
-Copyright 2004 Sebastian Riedel. All rights reserved.
-
 This library is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
@@ -1004,6 +1006,7 @@ __create__
 [% startperl %]
 
 use strict;
+use warnings;
 use Getopt::Long;
 use Pod::Usage;
 use Catalyst::Helper;
@@ -1041,13 +1044,16 @@ pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
 
  Examples:
    [% appprefix %]_create.pl controller My::Controller
+   [% appprefix %]_create.pl controller My::Controller BindLex
    [% appprefix %]_create.pl -mechanize controller My::Controller
    [% appprefix %]_create.pl view My::View
    [% appprefix %]_create.pl view MyView TT
    [% appprefix %]_create.pl view TT TT
    [% appprefix %]_create.pl model My::Model
-   [% appprefix %]_create.pl model SomeDB DBIC::SchemaLoader dbi:SQLite:/tmp/my.db
-   [% appprefix %]_create.pl model AnotherDB DBIC::SchemaLoader dbi:Pg:dbname=foo root 4321
+   [% appprefix %]_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
+   dbi:SQLite:/tmp/my.db
+   [% appprefix %]_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
+   dbi:Pg:dbname=foo root 4321
 
  See also:
    perldoc Catalyst::Manual
@@ -1064,11 +1070,10 @@ This behavior can be suppressed with the C<-force> option.
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
 
 =head1 COPYRIGHT
 
-Copyright 2004 Sebastian Riedel. All rights reserved.
-
 This library is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
@@ -1084,10 +1089,6 @@ use base 'Catalyst::[% long_type %]';
 
 [% class %] - Catalyst [% long_type %]
 
-=head1 SYNOPSIS
-
-See L<[% app %]>
-
 =head1 DESCRIPTION
 
 Catalyst [% long_type %].
@@ -1096,19 +1097,16 @@ Catalyst [% long_type %].
 
 =cut
 
-#
-# Uncomment and modify this or add new actions to fit your needs
-#
-#=head2 default
-#
-#=cut
-#
-#sub default : Private {
-#    my ( $self, $c ) = @_;
-#
-#    # Hello World
-#    $c->response->body('[% class %] is on Catalyst!');
-#}
+
+=head2 index 
+
+=cut
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+
+    $c->response->body('Matched [% class %] in [%name%].');
+}
 
 [% END %]
 =head1 AUTHOR