From: Florian Ragwitz Date: Sun, 15 May 2011 16:32:54 +0000 (+0200) Subject: Merge branch 'master' into psgi X-Git-Tag: 1.34~4^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=28323be6f68317a18b4253b762e5dc653cf954a8;hp=ed763c0fa4b58576fbc2149b1d33ca74de1ad4dc;p=catagits%2FCatalyst-Devel.git Merge branch 'master' into psgi * master: Fix failing test - render_file_contents is expected to return the filename Changelog set permissions of script/*.pl to 0755 allow changing permissions to 0000 Fix RT#67303: -scripts changes permissions of original files Fix duplicate 'use Test::More' statement in generated components --- diff --git a/Changes b/Changes index 4779612..2930433 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ This file documents the revision history for Perl extension Catalyst-Devel. + - Fix scripts being generated mode 0700, rather than 0755 + - Fix duplicate 'use Test::More' statement in generated components. + 1.33 2011-03-24 15:10:00 - Fix a regression introduced in 1.32 that caused Catalyst::Restarter to not work at all. diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index a1d150f..e5574c8 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -271,7 +271,7 @@ sub mk_file { binmode $f; print $f $content; print qq/created "$file"\n/; - return 1; + return $file; } Catalyst::Exception->throw( message => qq/Couldn't create "$file", "$!"/ ); @@ -302,20 +302,20 @@ sub next_test { ## compatability. otherwise, we'd have no way to pass stuff from __DATA__ sub render_file { - my ( $self, $file, $path, $vars ) = @_; + my ( $self, $file, $path, $vars, $perms ) = @_; my $template = $self->get_file( ( caller(0) )[0], $file ); - $self->render_file_contents($template, $path, $vars); + $self->render_file_contents($template, $path, $vars, $perms); } sub render_sharedir_file { - my ( $self, $file, $path, $vars ) = @_; + my ( $self, $file, $path, $vars, $perms ) = @_; my $template = $self->get_sharedir_file( $file ); die("Cannot get template from $file for $self\n") unless $template; - $self->render_file_contents($template, $path, $vars); + $self->render_file_contents($template, $path, $vars, $perms); } sub render_file_contents { - my ( $self, $template, $path, $vars ) = @_; + my ( $self, $template, $path, $vars, $perms ) = @_; $vars ||= {}; my $t = Template->new; return 0 unless $template; @@ -323,7 +323,9 @@ sub render_file_contents { $t->process( \$template, { %{$self}, %$vars }, \$output ) || Catalyst::Exception->throw( message => qq/Couldn't process "$template", / . $t->error() ); - $self->mk_file( $path, $output ); + my $file = $self->mk_file( $path, $output ); + chmod $perms, file($file) if defined $perms; + return $file; } sub _mk_information { @@ -450,40 +452,40 @@ sub _mk_cgi { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_sharedir_file( file('script', 'myapp_cgi.pl.tt'), file($script,"$appprefix\_cgi.pl") ); - chmod 0700, file($script,"$appprefix\_cgi.pl"); + $self->render_sharedir_file( file('script', 'myapp_cgi.pl.tt'), + file($script,"$appprefix\_cgi.pl"), undef, 0755 ); } sub _mk_fastcgi { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_sharedir_file( file('script', 'myapp_fastcgi.pl.tt'), file($script, "$appprefix\_fastcgi.pl") ); - chmod 0700, file($script, "$appprefix\_fastcgi.pl"); + $self->render_sharedir_file( file('script', 'myapp_fastcgi.pl.tt'), + file($script, "$appprefix\_fastcgi.pl"), undef, 0755 ); } sub _mk_server { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_sharedir_file( file('script', 'myapp_server.pl.tt'), file($script, "$appprefix\_server.pl") ); - chmod 0700, file($script, "$appprefix\_server.pl"); + $self->render_sharedir_file( file('script', 'myapp_server.pl.tt'), + file($script, "$appprefix\_server.pl"), undef, 0755 ); } sub _mk_test { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_sharedir_file( file('script', 'myapp_test.pl.tt'), file($script, "$appprefix\_test.pl") ); - chmod 0700, file($script, "$appprefix\_test.pl"); + $self->render_sharedir_file( file('script', 'myapp_test.pl.tt'), + file($script, "$appprefix\_test.pl"), undef, 0755 ); } sub _mk_create { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_sharedir_file( file('script', 'myapp_create.pl.tt'), file($script, "$appprefix\_create.pl") ); - chmod 0700, file($script, "$appprefix\_create.pl"); + $self->render_sharedir_file( file('script', 'myapp_create.pl.tt'), + file($script, "$appprefix\_create.pl"), undef, 0755 ); } sub _mk_compclass { @@ -665,12 +667,13 @@ There is no fallback for this method. These are the methods that the Helper classes can call on the <$helper> object passed to them. -=head2 render_file ($file, $path, $vars) +=head2 render_file ($file, $path, $vars, $perms) 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