# This file documents the revision history for Perl extension Catalyst.
+ 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.
+ - Bug fix to again correctly detect checkouts in dist zilla using
+ applications.
+
+5.90010 - 2012-02-18 00:01:00
+
+ Bug fixes:
+ - Fix the previous fix to Catalyst::ScriptRunner which was resulting
+ in the lib directory not being pushed onto @INC.
+ This meant perl ./script/myapp_server.pl failed, however
+ perl -Ilib ./script/myapp_server.pl would succeed.
+
+5.90009 - 2012-02-16 09:06:00
+
+ Bug fixes:
+ - Fix the debug page so that it works as expected with the latest
+ refactoring.
+
+ - The Catalyst::Utils::home function is used to find if the application
+ is a checkout in Catalyst::ScriptRunner. This means that a non-existant
+ lib directory that is relative to the script install location is not
+ included when not running from a checkout.
+
+ - Fix dead links to cpansearch.perl.org to point to metacpan.org.
+
+ - Require the latest version of B::Hooks::EndOfScope (0.10) to avoid an
+ issue with new versions of Module::Runtime (0.012) on perl 5.10
+ which stopped Catalyst::Controller from compiling.
+
+5.90008 - TRIAL 2012-02-06 20:49:00
+
New features and refactoring:
- Much of the Catalyst::Engine code has been moved into Catalyst::Request
and Catalyst::Response, to be able to better support asynchronous web
use Module::Install::CheckConflicts;
use Module::Install::AuthorTests;
-perl_version '5.008004';
+perl_version '5.008003';
name 'Catalyst-Runtime';
all_from 'lib/Catalyst/Runtime.pm';
requires 'List::MoreUtils';
requires 'namespace::autoclean' => '0.09';
requires 'namespace::clean' => '0.13';
-requires 'B::Hooks::EndOfScope' => '0.08';
+requires 'B::Hooks::EndOfScope' => '0.10';
requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00903';
requires 'Class::Load' => '0.12';
requires 'Class::MOP' => '0.95';
use Plack::Middleware::IIS6ScriptNameFix;
use Plack::Middleware::LighttpdScriptNameFix;
-BEGIN { require 5.008004; }
+BEGIN { require 5.008003; }
has stack => (is => 'ro', default => sub { [] });
has stash => (is => 'rw', default => sub { {} });
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90007';
+our $VERSION = '5.90010';
sub import {
my ( $class, @arguments ) = @_;
We do, however, provide you with a few starting points.</p>
<p>If you want to jump right into web development with Catalyst
you might want to start with a tutorial.</p>
-<pre>perldoc <a href="http://cpansearch.perl.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Tutorial.pod">Catalyst::Manual::Tutorial</a></code>
+<pre>perldoc <a href="https://metacpan.org/module/Catalyst::Manual::Tutorial">Catalyst::Manual::Tutorial</a></code>
</pre>
<p>Afterwards you can go on to check out a more complete look at our features.</p>
<pre>
-<code>perldoc <a href="http://cpansearch.perl.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Intro.pod">Catalyst::Manual::Intro</a>
+<code>perldoc <a href="https://metacpan.org/module/Catalyst::Manual::Intro">Catalyst::Manual::Intro</a>
<!-- Something else should go here, but the Catalyst::Manual link seems unhelpful -->
</code></pre>
<h2>What to do next?</h2>
<p>Next it's time to write an actual application. Use the
- helper scripts to generate <a href="http://cpansearch.perl.org/search?query=Catalyst%3A%3AController%3A%3A&mode=all">controllers</a>,
- <a href="http://cpansearch.perl.org/search?query=Catalyst%3A%3AModel%3A%3A&mode=all">models</a>, and
- <a href="http://cpansearch.perl.org/search?query=Catalyst%3A%3AView%3A%3A&mode=all">views</a>;
+ helper scripts to generate <a href="https://metacpan.org/search?q=Catalyst%3A%3AController">controllers</a>,
+ <a href="https://metacpan.org/search?q=Catalyst%3A%3AModel">models</a>, and
+ <a href="https://metacpan.org/search?q=Catalyst%3A%3AView">views</a>;
they can save you a lot of work.</p>
<pre><code>script/${prefix}_create.pl --help</code></pre>
<p>Also, be sure to check out the vast and growing
$title = $name = "$name on Catalyst $Catalyst::VERSION";
$name = "<h1>$name</h1>";
- # Don't show context in the dump
- $c->req->_clear_context;
- $c->res->_clear_context;
-
# Don't show body parser in the dump
$c->req->_clear_body;
use strict;
use warnings;
-BEGIN { require 5.008004; }
+BEGIN { require 5.008003; }
# Remember to update this in Catalyst as well!
-our $VERSION = '5.90007';
+our $VERSION = '5.90010';
=head1 NAME
use lib;
use File::Spec;
use Class::Load qw/ load_first_existing_class load_optional_class /;
+use Catalyst::Utils;
use namespace::autoclean -also => 'subclass_with_traits';
use Try::Tiny;
sub run {
my ($self, $appclass, $scriptclass) = @_;
- lib->import(File::Spec->catdir($FindBin::Bin, '..', 'lib'));
+ if (my $home = Catalyst::Utils::find_home_unloaded_in_checkout()) {
+ lib->import(File::Spec->catdir($home, 'lib'));
+ }
my $class = $self->find_script_class($appclass, $scriptclass);
COMPONENT method you would like to inherit is the first (left-hand most)
COMPONENT method in your @ISA.
+=head2 Development server relying on environment variables
+
+Previously, the development server would allow propagation of system
+environment variables into the request environment, this has changed with the
+adoption of Plack. You can use L<Plack::Middleware::ForceEnv> to achieve the
+same effect.
+
=head1 WARNINGS
=head2 Actions in your application class
use Path::Class;
use URI;
use Carp qw/croak/;
-use Cwd;
+use FindBin qw/ $Bin /;
use Class::MOP;
use String::RewritePrefix;
+use List::MoreUtils qw/ any /;
use namespace::clean;
return $tmpdir->stringify;
}
+=head2 dist_indicator_file_list
+
+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 /;
+}
+
=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 {
# find the @INC entry in which $file was found
(my $path = $inc_entry) =~ s/$file$//;
- $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 (-f $home->file("Makefile.PL") or -f $home->file("Build.PL")
- or -f $home->file("dist.ini")) {
-
- # 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;
- }
+ my $home = find_home_unloaded_in_checkout($path);
+ return $home if $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.
use strict;
use warnings;
use FindBin qw/$Bin/;
+
+# Package::Stash::XS has a weird =~ XS invocation during its compilation
+# This interferes with @INC hooks that do rematcuing on their own on
+# perls before 5.8.7. Just use the PP version to work around this.
+BEGIN { $ENV{PACKAGE_STASH_IMPLEMENTATION} = 'PP' if $] < '5.008007' }
+
use Test::More;
use Try::Tiny;
--- /dev/null
+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;
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+use File::Temp qw/ tempdir /;
+use Catalyst::Utils;
+use File::Spec;
+use Path::Class qw/ dir /;
+use Cwd qw/ cwd /;
+
+my @dists = Catalyst::Utils::dist_indicator_file_list();
+is(scalar(@dists), 3, 'Makefile.PL Build.PL dist.ini');
+
+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');
+ ok !Catalyst::Utils::home('MyApp'), "No files found inc $inc";
+ open(my $fh, '>', "Makefile.PL");
+ close($fh);
+ is Catalyst::Utils::home('MyApp'), dir($d)->absolute->cleanup, "Did find inc '$inc'";
+}
+
+{
+ my $d = tempdir(CLEANUP => 1);
+ local $INC{'MyApp.pm'} = File::Spec->catdir($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;
+