Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: andrewalker/catalyst-runtime
...
head fork: andrewalker/catalyst-runtime
  • 14 commits
  • 15 files changed
  • 0 commit comments
  • 5 contributors
Commits on Feb 28, 2012
@bobtfish bobtfish Fix all the tests to get it right, use Cwd rather than FindBin 202d7d9
@bobtfish bobtfish Cleanup changelog 7a091cb
@bobtfish bobtfish And bug fix c47c751
Commits on Feb 29, 2012
@bobtfish bobtfish Fix for tests b9b257c
@bobtfish bobtfish Add fake Makefile.PL to make test apps think they're root 7f0a549
Commits on Mar 01, 2012
@bobtfish bobtfish Simplify loading madness back to what I was originally trying to do a8946dc
Commits on Mar 02, 2012
@bobtfish bobtfish Fix for closing fds with --background
As web load the app (and therefore setup file loggers) before
we use MX::Daemonize, it's closing stuff clobbers everything.
Therefore we just close STDIN/STDOUT/STDERR, leaving anything
the user has setup.
df89434
@nigelm nigelm Fixed up uses of catdir being used to return a file path
catdir and catfile are different - using them interchangeably may
work on most platforms, but one day you will encounter VMS
and get horribly confused!
94d7a76
@bobtfish bobtfish Changelog for File::Spec fix f1944b3
Commits on Mar 04, 2012
@jessesheidlower jessesheidlower Fixed typo in Engine::HTTP warning message 5bf2932
Commits on Mar 06, 2012
@bobtfish bobtfish Unpossible, but people keep seeing it f2b8342
Commits on Mar 08, 2012
@jjn1056 jjn1056 set change file date and updated versions in preparation for release 2114ee9
Commits on Mar 09, 2012
@bobtfish bobtfish Doc fixes / additions in Catalyst::Component d8ccdd9
Commits on Mar 10, 2012
@andrewalker Merge branch 'master' into gsoc_breadboard 345358e
View
26 Changes
@@ -1,12 +1,30 @@
# This file documents the revision history for Perl extension Catalyst.
+ Documentation:
+ - Fix documentation in Catalyst::Component to show attributes and
+ calling readers, rather than accessing elements in the $self->{} hash
+ directly.
+ - Add note in Catalyst::Component to strongly disrecommend $self->config
+
+5.90011 - 2012-03-08 16:43:00
+
Bug fixes:
- - Yet another fix to the previous fix to Catalyst::ScriptRunner which
- was resulting in the lib directory not being pushed onto @INC.
- When you were in a directory in your checkout below the root
- of the application.
+ - Simplification of the previous changes to Catalyst::ScriptRunner
+ We now just push $FindBin::Bin/../lib to the @INC path again, but
+ only if one of the dist indicator files (Makefile.PL Build.PL or
+ dist.ini) can be found in $FindBin::Bin/../$_
+ This avoids heuristics when the app is unloaded and therefore
+ works better for extensions which have entire applications in
+ their test suites.
- Bug fix to again correctly detect checkouts in dist zilla using
applications.
+ - --background option for the server script now only closes
+ STDIN, STDOUT and STDERR. This fixes issues with Log::Dispatch
+ and other loggers which open a file handle when
+ - Change incorrect use of File::Spec->catdir to File::Spec->catfile
+ so that we work on platforms which care about this (VMS?)
+ - Make it more obvious if our PSGI server doesn't pass in a response
+ callback.
5.90010 - 2012-02-18 00:01:00
View
2  lib/Catalyst.pm
@@ -99,7 +99,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90010';
+our $VERSION = '5.90011';
sub import {
my ( $class, @arguments ) = @_;
View
19 lib/Catalyst/Component.pm
@@ -28,14 +28,18 @@ Catalyst::Component - Catalyst Component Base Class
__PACKAGE__->config( foo => 'bar' );
+ has foo => (
+ is => 'ro',
+ );
+
sub test {
my $self = shift;
- return $self->{foo};
+ return $self->foo;
}
sub forward_to_me {
my ( $self, $c ) = @_;
- $c->response->output( $self->{foo} );
+ $c->response->output( $self->foo );
}
1;
@@ -46,7 +50,7 @@ Catalyst::Component - Catalyst Component Base Class
# Or just methods
print $c->comp('MyApp::Model::Something')->test;
- print $c->comp('MyApp::Model::Something')->{foo};
+ print $c->comp('MyApp::Model::Something')->foo;
=head1 DESCRIPTION
@@ -56,6 +60,13 @@ This is the universal base class for Catalyst components
It provides you with a generic new() for component construction through Catalyst's
component loader with config() support and a process() method placeholder.
+B<Note> that calling C<< $self->config >> inside a component is strongly
+disrecommended - the correctly merged config should have already been
+passed to the constructor and stored in attributes - accessing
+the config accessor directly from an instance is likely to get the
+wrong values (as it only holds the class wide config, not things loaded
+from the config file!)
+
=cut
__PACKAGE__->mk_classdata('_plugins');
@@ -200,7 +211,7 @@ a Catalyst application has its own config hash.
The component's config hash is merged with any config entry on the
application for this component and passed to C<new()> (as mentioned
-above at L</COMPONENT>). The common practice to access the merged
+above at L</COMPONENT>). The recommended practice to access the merged
config is to use a Moose attribute for each config entry on the
receiving component.
View
1  lib/Catalyst/Engine.pm
@@ -678,6 +678,7 @@ sub build_psgi_app {
return sub {
my ($respond) = @_;
+ confess("Did not get a response callback for writer, cannot continiue") unless $respond;
$app->handle_request(env => $env, response_cb => $respond);
};
};
View
2  lib/Catalyst/Engine/HTTP.pm
@@ -7,7 +7,7 @@ use base 'Catalyst::Engine';
warn("You are loading Catalyst::Engine::HTTP explicitly.
-This is almost certainally a bad idea, as Catalyst::Engine::HTTP
+This is almost certainly a bad idea, as Catalyst::Engine::HTTP
has been removed in this version of Catalyst.
Please update your application's scripts with:
View
2  lib/Catalyst/Runtime.pm
@@ -7,7 +7,7 @@ BEGIN { require 5.008003; }
# Remember to update this in Catalyst as well!
-our $VERSION = '5.90010';
+our $VERSION = '5.90011';
=head1 NAME
View
5 lib/Catalyst/Script/Server.pm
@@ -71,17 +71,20 @@ has pidfile => (
predicate => '_has_pidfile',
);
+# Override MooseX::Daemonize
+sub dont_close_all_files { 1 }
sub BUILD {
my $self = shift;
if ($self->background) {
# FIXME - This is evil. Should we just add MX::Daemonize to the deps?
- try { Class::MOP::load_class('MooseX::Daemonize::Core') }
+ try { Class::MOP::load_class('MooseX::Daemonize::Core'); Class::MOP::load_class('POSIX') }
catch {
warn("MooseX::Daemonize is needed for the --background option\n");
exit 1;
};
MooseX::Daemonize::Core->meta->apply($self);
+ POSIX::close($_) foreach (0..2);
}
}
View
4 lib/Catalyst/ScriptRunner.pm
@@ -35,8 +35,8 @@ sub subclass_with_traits {
sub run {
my ($self, $appclass, $scriptclass) = @_;
- if (my $home = Catalyst::Utils::find_home_unloaded_in_checkout()) {
- lib->import(File::Spec->catdir($home, 'lib'));
+ if (grep { -f File::Spec->catfile($FindBin::Bin, '..', $_) } Catalyst::Utils::dist_indicator_file_list()) {
+ lib->import(File::Spec->catdir($FindBin::Bin, '..', 'lib'));
}
my $class = $self->find_script_class($appclass, $scriptclass);
View
79 lib/Catalyst/Utils.pm
@@ -6,10 +6,9 @@ use HTTP::Request;
use Path::Class;
use URI;
use Carp qw/croak/;
-use FindBin qw/ $Bin /;
+use Cwd;
use Class::MOP;
use String::RewritePrefix;
-use List::MoreUtils qw/ any /;
use namespace::clean;
@@ -169,24 +168,21 @@ sub class2tempdir {
return $tmpdir->stringify;
}
+=head2 home($class)
+
+Returns home directory for given class.
+
=head2 dist_indicator_file_list
-Returns a list of files which can be tested to check if you're inside a checkout
+Returns a list of files which can be tested to check if you're inside
+a checkout
=cut
sub dist_indicator_file_list {
- qw/ Makefile.PL Build.PL dist.ini /;
+ qw{Makefile.PL Build.PL dist.ini};
}
-=head2 home($class)
-
-Returns home directory for given class.
-
-Note that the class must be loaded for the home directory to be found using this function.
-
-=cut
-
sub home {
my $class = shift;
@@ -199,8 +195,25 @@ sub home {
# find the @INC entry in which $file was found
(my $path = $inc_entry) =~ s/$file$//;
- my $home = find_home_unloaded_in_checkout($path);
- return $home if $home;
+ $path ||= cwd() if !defined $path || !length $path;
+ my $home = dir($path)->absolute->cleanup;
+
+ # pop off /lib and /blib if they're there
+ $home = $home->parent while $home =~ /b?lib$/;
+
+ # only return the dir if it has a Makefile.PL or Build.PL or dist.ini
+ if (grep { -f $home->file($_) } dist_indicator_file_list()) {
+ # clean up relative path:
+ # MyApp/script/.. -> MyApp
+
+ my $dir;
+ my @dir_list = $home->dir_list();
+ while (($dir = pop(@dir_list)) && $dir eq '..') {
+ $home = dir($home)->parent->parent;
+ }
+
+ return $home->stringify;
+ }
}
{
@@ -219,44 +232,6 @@ sub home {
return 0;
}
-=head2 find_home_unloaded_in_checkout ($path)
-
-Tries to determine if C<$path> (or $FindBin::Bin if not supplied)
-looks like a checkout. Any leading lib, script or blib components
-will be removed, then the directory produced will be checked
-for the existence of a C<< dist_indicator_file_list() >>.
-
-If one is found, the directory will be returned, otherwise false.
-
-=cut
-
-sub find_home_unloaded_in_checkout {
- my ($path) = @_;
- $path ||= $Bin if !defined $path || !length $path;
- my $home = dir($path)->absolute->cleanup;
-
- # pop off /lib and /blib if they're there
- $home = $home->parent while $home =~ /b?lib$/;
- # pop off /script if it's there.
- $home = $home->parent while $home =~ /b?script$/;
-
- # only return the dir if it has a Makefile.PL or Build.PL or dist.ini
- if (any { $_ } map { -f $home->file($_) } dist_indicator_file_list()) {
-
- # clean up relative path:
- # MyApp/script/.. -> MyApp
-
- my $dir;
- my @dir_list = $home->dir_list();
- while (($dir = pop(@dir_list)) && $dir eq '..') {
- $home = dir($home)->parent->parent;
- }
-
- return $home->stringify;
- }
-
-}
-
=head2 prefix($class, $name);
Returns a prefixed action.
View
42 t/aggregate/unit_core_scriptrunner_home.t
@@ -1,42 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-use FindBin qw/$Bin/;
-use Test::Exception;
-use lib "$Bin/../lib";
-use File::Temp qw/ tempdir /;
-use Cwd;
-
-use_ok('Catalyst::ScriptRunner');
-
-my $cwd = cwd();
-
-my $d = tempdir(); #CLEANUP => 1);
-chdir($d) or die;
-mkdir("lib") or die;
-mkdir(File::Spec->catdir("lib", "MyApp")) or die;
-mkdir(File::Spec->catdir("lib", "MyApp", "Script")) or die;
-
-open(my $fh, '>', 'Makefile.PL') or die;
-close($fh) or die;
-
-open($fh, '>', File::Spec->catdir("lib", "MyApp", "Script", "Foo.pm")) or die;
-print $fh q{package MyApp::Script::Foo;
-use Moose;
-use namespace::autoclean;
-
-with 'Catalyst::ScriptRole';
-
-sub run { __PACKAGE__ }
-
-1;
-};
-close($fh) or die;
-
-use_ok 'Catalyst::ScriptRunner';
-
-is Catalyst::ScriptRunner->run('MyApp', 'Foo'), 'MyApp::Script::Foo';
-
-chdir($cwd) or die;
-
-done_testing;
View
13 t/aggregate/unit_utils_home.t
@@ -15,7 +15,7 @@ my $cwd = cwd();
foreach my $inc ('', 'lib', 'blib'){
my $d = tempdir(CLEANUP => 1);
chdir($d);
- local $INC{'MyApp.pm'} = File::Spec->catdir($d, $inc, 'MyApp.pm');
+ local $INC{'MyApp.pm'} = File::Spec->catfile($d, $inc, 'MyApp.pm');
ok !Catalyst::Utils::home('MyApp'), "No files found inc $inc";
open(my $fh, '>', "Makefile.PL");
close($fh);
@@ -24,21 +24,12 @@ foreach my $inc ('', 'lib', 'blib'){
{
my $d = tempdir(CLEANUP => 1);
- local $INC{'MyApp.pm'} = File::Spec->catdir($d, 'MyApp.pm');
+ local $INC{'MyApp.pm'} = File::Spec->catfile($d, 'MyApp.pm');
ok !Catalyst::Utils::home('MyApp'), 'No files found';
mkdir File::Spec->catdir($d, 'MyApp');
is Catalyst::Utils::home('MyApp'), dir($d, 'MyApp')->absolute->cleanup;
}
-{
- my $d = tempdir(CLEANUP => 1);
- chdir($d);
- ok !Catalyst::Utils::find_home_unloaded_in_checkout();
- open(my $fh, '>', "Makefile.PL");
- close($fh);
- is Catalyst::Utils::find_home_unloaded_in_checkout(), cwd(), "Did find home_unloaded_in_checkout"
-}
-
chdir($cwd);
done_testing;
View
2  t/author/podcoverage.t
@@ -8,7 +8,7 @@ use Test::Pod::Coverage 1.04;
my @modules = all_modules;
our @private = ( 'BUILD' );
foreach my $module (@modules) {
- local @private = (@private, 'run') if $module =~ /^Catalyst::Script::/;
+ local @private = (@private, 'run', 'dont_close_all_files') if $module =~ /^Catalyst::Script::/;
local @private = (@private, 'plugin') if $module =~ /^Catalyst$/;
local @private = (@private, 'snippets') if $module =~ /^Catalyst::Request$/;
local @private = (@private, 'prepare_connection') if $module =~ /^Catalyst::Engine$/;
View
2  t/lib/TestAppEncoding/Controller/Root.pm
@@ -8,7 +8,7 @@ __PACKAGE__->config->{namespace} = '';
sub binary : Local {
my ($self, $c) = @_;
- $c->res->body(do {
+ $c->res->body(do {
open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!;
binmode($fh);
local $/ = undef; <$fh>;
View
2  t/psgi_file_testapp.t
@@ -14,7 +14,7 @@ BEGIN {
$temp = tempdir( CLEANUP => 1 );
$ENV{CATALYST_HOME} = $temp;
- open(my $psgi, '>', File::Spec->catdir($temp, 'testapp.psgi')) or die;
+ open(my $psgi, '>', File::Spec->catfile($temp, 'testapp.psgi')) or die;
print $psgi q{
use strict;
use TestApp;
View
2  t/psgi_file_testapp_engine_psgi_compat.t
@@ -14,7 +14,7 @@ BEGIN {
$temp = tempdir( CLEANUP => 1 );
$ENV{CATALYST_HOME} = $temp;
- open(my $psgi, '>', File::Spec->catdir($temp, 'testapp.psgi')) or die;
+ open(my $psgi, '>', File::Spec->catfile($temp, 'testapp.psgi')) or die;
print $psgi q{
use strict;
use TestApp;

No commit comments for this range

Something went wrong with that request. Please try again.