Strip trailing whitespace
[catagits/Catalyst-Devel.git] / lib / Catalyst / Helper.pm
index 799d4f3..31fdfef 100644 (file)
@@ -36,8 +36,9 @@ Catalyst::Helper - Bootstrap a Catalyst application
 sub get_sharedir_file {
     my ($self, @filename) = @_;
     my $dist_dir;
-    if (-d "inc/.author") { # Can't use sharedir if we're in a checkout
-                            # this feels horrible, better ideas?
+    if (-d "inc/.author" && -f "lib/Catalyst/Helper.pm"
+            ) { # Can't use sharedir if we're in a checkout
+                # this feels horrible, better ideas?
         $dist_dir = 'share';
     }
     else {
@@ -274,7 +275,7 @@ sub next_test {
 
 # Do not touch this method, *EVER*, it is needed for back compat.
 ## addendum: we had to split this method so we could have backwards
-## compatability.  otherwise, we'd have no way to pass stuff from __DATA__ 
+## compatability.  otherwise, we'd have no way to pass stuff from __DATA__
 
 sub render_file {
     my ( $self, $file, $path, $vars ) = @_;
@@ -349,12 +350,12 @@ sub _mk_dirs {
 sub _mk_appclass {
     my $self = shift;
     my $mod  = $self->{mod};
-    $self->render_sharedir_file( 'lib/MyApp.pm.tt', "$mod.pm" );
+    $self->render_sharedir_file( File::Spec->catfile('lib', 'MyApp.pm.tt'), "$mod.pm" );
 }
 
 sub _mk_rootclass {
     my $self = shift;
-    $self->render_sharedir_file( 'lib/MyApp/Controller/Root.pm.tt',
+    $self->render_sharedir_file( File::Spec->catfile('lib', 'MyApp', 'Controller', 'Root.pm.tt'),
         File::Spec->catfile( $self->{c}, "Root.pm" ) );
 }
 
@@ -397,16 +398,16 @@ sub _mk_changes {
 sub _mk_apptest {
     my $self = shift;
     my $t    = $self->{t};
-    $self->render_sharedir_file( 't/01app.t.tt',         "$t\/01app.t" );
-    $self->render_sharedir_file( 't/02pod.t.tt',         "$t\/02pod.t" );
-    $self->render_sharedir_file( 't/03podcoverage.tt', "$t\/03podcoverage.t" );
+    $self->render_sharedir_file( File::Spec->catfile('t', '01app.t.tt'),         "$t\/01app.t" );
+    $self->render_sharedir_file( File::Spec->catfile('t', '02pod.t.tt'),         "$t\/02pod.t" );
+    $self->render_sharedir_file( File::Spec->catfile('t', '03podcoverage.t.tt'), "$t\/03podcoverage.t" );
 }
 
 sub _mk_cgi {
     my $self      = shift;
     my $script    = $self->{script};
     my $appprefix = $self->{appprefix};
-    $self->render_sharedir_file( 'script/myapp_cgi.pl.tt', "$script\/$appprefix\_cgi.pl" );
+    $self->render_sharedir_file( File::Spec->catfile('script', 'myapp_cgi.pl.tt'), "$script\/$appprefix\_cgi.pl" );
     chmod 0700, "$script/$appprefix\_cgi.pl";
 }
 
@@ -414,7 +415,7 @@ sub _mk_fastcgi {
     my $self      = shift;
     my $script    = $self->{script};
     my $appprefix = $self->{appprefix};
-    $self->render_sharedir_file( 'script/myapp_fastcgi.pl.tt', "$script\/$appprefix\_fastcgi.pl" );
+    $self->render_sharedir_file( File::Spec->catfile('script', 'myapp_fastcgi.pl.tt'), "$script\/$appprefix\_fastcgi.pl" );
     chmod 0700, "$script/$appprefix\_fastcgi.pl";
 }
 
@@ -422,7 +423,7 @@ sub _mk_server {
     my $self      = shift;
     my $script    = $self->{script};
     my $appprefix = $self->{appprefix};
-    $self->render_sharedir_file( 'script/myapp_server.pl.tt', "$script\/$appprefix\_server.pl" );
+    $self->render_sharedir_file( File::Spec->catfile('script', 'myapp_server.pl.tt'), "$script\/$appprefix\_server.pl" );
     chmod 0700, "$script/$appprefix\_server.pl";
 }
 
@@ -430,7 +431,7 @@ sub _mk_test {
     my $self      = shift;
     my $script    = $self->{script};
     my $appprefix = $self->{appprefix};
-    $self->render_sharedir_file( 'script/myapp_test.pl.tt', "$script/$appprefix\_test.pl" );
+    $self->render_sharedir_file( File::Spec->catfile('script', 'myapp_test.pl.tt'), "$script/$appprefix\_test.pl" );
     chmod 0700, "$script/$appprefix\_test.pl";
 }
 
@@ -438,20 +439,20 @@ sub _mk_create {
     my $self      = shift;
     my $script    = $self->{script};
     my $appprefix = $self->{appprefix};
-    $self->render_sharedir_file( 'script/myapp_create.pl.tt', "$script\/$appprefix\_create.pl" );
+    $self->render_sharedir_file( File::Spec->catfile('script', 'myapp_create.pl.tt'), "$script\/$appprefix\_create.pl" );
     chmod 0700, "$script/$appprefix\_create.pl";
 }
 
 sub _mk_compclass {
     my $self = shift;
     my $file = $self->{file};
-    return $self->render_sharedir_file( 'myapp_compclass.pl.tt', "$file" );
+    return $self->render_sharedir_file( 'lib', 'Helper', 'compclass.pl.tt', "$file" );
 }
 
 sub _mk_comptest {
     my $self = shift;
     my $test = $self->{test};
-    $self->render_sharedir_file( 'comptest.tt', "$test" );  ## wtf do i rename this to?
+    $self->render_sharedir_file( 't', 'comptest.tt', "$test" );  ## wtf do i rename this to?
 }
 
 sub _mk_images {
@@ -522,7 +523,7 @@ sub _find_share_dir {
         }
         confess "could not find sharebase by recursion. ended up at $dir, from $file"
           unless $share_base;
-        $args->{share_base_dir} = $share_base; 
+        $args->{share_base_dir} = $share_base;
     }
   }
   my $base = $args->{share_base_dir}->subdir($share_name);