Updated -short auto-detection
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Helper.pm
index 2949581..9bbf398 100644 (file)
@@ -134,13 +134,15 @@ sub mk_component {
         $type              = 'M' if $type =~ /model/i;
         $type              = 'V' if $type =~ /view/i;
         $type              = 'C' if $type =~ /controller/i;
-        $type              = $self->{long_type} unless $self->{short};
-        $self->{type}      = $type;
-        $self->{name}      = $name;
-        $self->{class}     = "$app\::$type\::$name";
+        my $appdir = File::Spec->catdir( split /\:\:/, $app );
+        my $test_path =
+          File::Spec->catdir( $FindBin::Bin, '..', 'lib', $appdir, 'C' );
+        $type = $self->{long_type} unless -d $test_path;
+        $self->{type}  = $type;
+        $self->{name}  = $name;
+        $self->{class} = "$app\::$type\::$name";
 
         # Class
-        my $appdir = File::Spec->catdir( split /\:\:/, $app );
         my $path =
           File::Spec->catdir( $FindBin::Bin, '..', 'lib', $appdir, $type );
         my $file = $name;
@@ -256,10 +258,9 @@ sub next_test {
         $self->{uri} = $prefix;
     }
     my $dir  = $self->{test_dir};
-    my $type = $self->{type};
-    $dir = File::Spec->catdir( $dir, $type );
+    my $type = lc $self->{type};
     $self->mk_dir($dir);
-    return File::Spec->catfile( $dir, $tname );
+    return File::Spec->catfile( $dir, "$type\_$tname" );
 }
 
 =head3 render_file
@@ -297,17 +298,6 @@ sub _mk_dirs {
     $self->{t} = File::Spec->catdir( $self->{dir}, 't' );
     $self->mk_dir( $self->{t} );
 
-    if ( $self->{short} ) {
-        $self->mk_dir( File::Spec->catdir( $self->{t}, 'M' ) );
-        $self->mk_dir( File::Spec->catdir( $self->{t}, 'V' ) );
-        $self->mk_dir( File::Spec->catdir( $self->{t}, 'C' ) );
-    }
-    else {
-        $self->mk_dir( File::Spec->catdir( $self->{t}, 'Model' ) );
-        $self->mk_dir( File::Spec->catdir( $self->{t}, 'View' ) );
-        $self->mk_dir( File::Spec->catdir( $self->{t}, 'Controller' ) );
-    }
-
     $self->{class} = File::Spec->catdir( split( /\:\:/, $self->{name} ) );
     $self->{mod} = File::Spec->catdir( $self->{lib}, $self->{class} );
     $self->mk_dir( $self->{mod} );
@@ -550,7 +540,7 @@ sub default : Private {
 #    my ( $self, $c ) = @_;
 #
 #    # Forward to View unless response body is already defined
-#    $c->forward('View::') unless $c->response->body;
+#    $c->forward( $c->view('') ) unless $c->response->body;
 #}
 
 =head1 AUTHOR
@@ -574,10 +564,9 @@ author('[% author %]');
 version_from('[% path %]');
 license('perl');
 
-requires( Catalyst => '5.57');
+requires( Catalyst => '5.57' );
 
-install_script;
-tests( glob('t/*.t'), glob('t/*/*.t') );
+install_script( glob('script/*.pl') );
 
 catalyst_files();
 
@@ -893,18 +882,15 @@ use Catalyst::Helper;
 
 my $force = 0;
 my $help  = 0;
-my $short = 0;
 
 GetOptions(
     'nonew|force' => \$force,
-    'help|?'      => \$help,
-    'short'       => \$short
+    'help|?'      => \$help
  );
 
 pod2usage(1) if ( $help || !$ARGV[0] );
 
-my $helper =
-    Catalyst::Helper->new( { '.newfiles' => !$force, short => $short } );
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force } );
 
 pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
 
@@ -921,7 +907,6 @@ pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
  Options:
    -force    don't create a .new file where a file to be created exists
    -help     display this help and exits
-   -short    use short types, like C instead of Controller...
 
  Examples:
    [% appprefix %]_create.pl controller My::Controller