X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper.pm;h=d7b5d70a34fb7bd77b979669293b24e688f07d53;hb=608f6b92c3cc888724102f73290da3c0a493c899;hp=7891b0d246449afe85f65d63adb3c7e617fe2b0f;hpb=c3514751b89087a79ca9e49795bf95d8b8ee5227;p=catagits%2FCatalyst-Devel.git diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index 7891b0d..d7b5d70 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -5,6 +5,7 @@ use warnings; use base 'Class::Accessor::Fast'; use Config; use File::Spec; +use File::Spec::Unix; use File::Path; use FindBin; use IO::File; @@ -48,7 +49,7 @@ sub mk_app { # Needs to be here for PAR require Catalyst; - if ( $name =~ /[^\w\:]/ ) { + if ( $name =~ /[^\w:]/ || $name =~ /^\d/ || $name =~ /\b:\b|:{3,}/) { warn "Error: Invalid application name.\n"; return 0; } @@ -58,7 +59,9 @@ sub mk_app { $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->{startperl } = -r '/usr/bin/env' + ? '#!/usr/bin/env perl' + : "#!$Config{perlpath} -w"; $self->{scriptgen } = $Catalyst::Devel::CATALYST_SCRIPT_GEN || 4; $self->{catalyst_version} = $Catalyst::VERSION; $self->{author } = $self->{author} = $ENV{'AUTHOR'} @@ -89,6 +92,7 @@ sub mk_app { $self->_mk_server; $self->_mk_test; $self->_mk_create; + $self->_mk_information; } return $self->{dir}; } @@ -256,6 +260,11 @@ sub render_file { $self->mk_file( $path, $output ); } +sub _mk_information { + my $self = shift; + print qq/Change to application directory and Run "perl Makefile.PL" to make sure your install is complete\n/; +} + sub _mk_dirs { my $self = shift; $self->mk_dir( $self->{dir} ); @@ -311,7 +320,7 @@ sub _mk_rootclass { sub _mk_makefile { my $self = shift; - $self->{path} = File::Spec->catfile( 'lib', split( '::', $self->{name} ) ); + $self->{path} = File::Spec::Unix->catfile( 'lib', split( '::', $self->{name} ) ); $self->{path} .= '.pm'; my $dir = $self->{dir}; $self->render_file( 'makefile', "$dir\/Makefile.PL" ); @@ -499,8 +508,8 @@ So when you call C, create will try to execute Catalyst::Helper::View::TT->mk_compclass and Catalyst::Helper::View::TT->mk_comptest. -See L and L for -examples. +See L and +L for examples. All helper classes should be under one of the following namespaces. @@ -508,6 +517,34 @@ All helper classes should be under one of the following namespaces. Catalyst::Helper::View:: Catalyst::Helper::Controller:: +=head2 COMMON HELPERS + +=over + +=item * + +L - DBIx::Class models + +=item * + +L - Template Toolkit view + +=item * + +L + +=item * + +L - wrap any class into a Catalyst model + +=back + +=head3 NOTE + +The helpers will read author name from /etc/passwd by default. + To override, please export the AUTHOR variable. + +=head1 METHODS + =head2 mk_compclass This method in your Helper module is called with C<$helper> @@ -539,41 +576,46 @@ arguments the user typed. There is no fallback for this method. -=head1 METHODS +=head1 INTERNAL METHODS These are the methods that the Helper classes can call on the <$helper> object passed to them. -=head2 render_file +=head2 render_file ($file, $path, $vars) -Render and create a file from a template in DATA using -Template Toolkit. +Render and create a file from a template in DATA using Template +Toolkit. $file is the relevent chunk of the __DATA__ section, $path is +the path to the file and $vars is the hashref as expected by +L