[Catalyst-commits] r10141 - in
Catalyst-Plugin-SmartURI/1.000/trunk: . lib/Catalyst/Plugin t
t/lib t/lib/TestApp t/lib/TestApp/Controller
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Thu May 14 01:07:51 GMT 2009
Author: caelum
Date: 2009-05-14 01:07:51 +0000 (Thu, 14 May 2009)
New Revision: 10141
Added:
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/MyURI.pm
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp.pm
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/MyURI.pm
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/REST.pm
Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/Root.pm
Removed:
Catalyst-Plugin-SmartURI/1.000/trunk/META.yml
Modified:
Catalyst-Plugin-SmartURI/1.000/trunk/Changes
Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL
Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm
Catalyst-Plugin-SmartURI/1.000/trunk/t/00-load.t
Catalyst-Plugin-SmartURI/1.000/trunk/t/01-basic.t
Catalyst-Plugin-SmartURI/1.000/trunk/t/02-c-a-rest-compat.t
Catalyst-Plugin-SmartURI/1.000/trunk/t/03-uri-class.t
Catalyst-Plugin-SmartURI/1.000/trunk/t/boilerplate.t
Catalyst-Plugin-SmartURI/1.000/trunk/t/pod.t
Log:
C::P::SmartURI - C::A::REST compat fix, new release
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/Changes
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/Changes 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/Changes 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,5 +1,9 @@
Revision history for Catalyst-Plugin-SmartURI
+0.034 2009-05-13 23:46:18
+ - fix compatibility with Catalyst::Action::REST v0.71
+ - move inline tests into t/lib
+
0.033 2009-04-29 19:46:04
- last dist was missing inc/
Deleted: Catalyst-Plugin-SmartURI/1.000/trunk/META.yml
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/META.yml 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/META.yml 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,28 +0,0 @@
----
-abstract: 'Configurable URIs for Catalyst'
-author:
- - 'Rafael Kitover <rkitover at cpan.org>'
-build_requires:
- ExtUtils::MakeMaker: 6.42
- Test::More: 0
-configure_requires:
- ExtUtils::MakeMaker: 6.42
-distribution_type: module
-generated_by: 'Module::Install version 0.85'
-license: perl
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
-name: Catalyst-Plugin-SmartURI
-no_index:
- directory:
- - inc
- - t
-requires:
- Catalyst: 5.80002
- Class::C3::Componentised: 0
- Task::Weaken: 0
- URI::SmartURI: 0
-resources:
- license: http://dev.perl.org/licenses/
-version: 0.033
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL 2009-05-14 01:07:51 UTC (rev 10141)
@@ -8,7 +8,12 @@
requires 'Class::C3::Componentised';
requires 'URI::SmartURI';
requires 'Task::Weaken';
+requires 'Moose';
+requires 'namespace::clean';
+requires 'parent';
build_requires 'Test::More';
+auto_provides;
+auto_install;
WriteAll;
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm 2009-05-14 01:07:51 UTC (rev 10141)
@@ -22,11 +22,11 @@
=head1 VERSION
-Version 0.033
+Version 0.034
=cut
-our $VERSION = '0.033';
+our $VERSION = '0.034';
=head1 SYNOPSIS
@@ -140,22 +140,6 @@
=back
-=head1 USING WITH Catalyst::Controller::REST
-
-In MyApp.pm do something like this:
-
- package MyApp;
-
- use Catalyst::Runtime '5.70';
- use parent 'Catalyst';
-
- use Catalyst::Action::REST ();
-
- __PACKAGE__->setup(qw/... your list of plugins including ... SmartURI .../);
-
-Because L<Catalyst::Action::REST> sets request_class at load time, SmartURI
-needs to see it at setup time to know which request class to extend.
-
=head1 EXTENDING
$c->prepare_uri actually creates the URI, which you can override.
@@ -228,10 +212,16 @@
unless ($request_class->isa('Catalyst::Request::SmartURI')) {
my $new_request_class = $app.'::Request::SmartURI';
+
+ my $inject_rest = (not $request_class->isa('Catalyst::Request::REST'))
+ && eval { Class::MOP::load_class('Catalyst::Request::REST') };
+
Class::C3::Componentised->inject_base(
$new_request_class,
'Catalyst::Request::SmartURI',
- $request_class
+ ($inject_rest ?
+ 'Catalyst::Request::REST' : ()),
+ $request_class,
);
Class::C3::reinitialize();
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/t/00-load.t
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/00-load.t 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/00-load.t 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use strict;
use warnings;
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/t/01-basic.t
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/01-basic.t 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/01-basic.t 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,66 +1,10 @@
-#!perl -T
+#!perl
use strict;
use warnings;
use Test::More tests => 8;
-
-{
- package TestApp;
-
- use Catalyst qw/SmartURI/;
-
- sub test_uri_for_redirect : Global {
- my ($self, $c) = @_;
- $c->res->redirect($c->uri_for('/test_uri_for_redirect'));
- }
-
- sub test_req_uri_with : Global {
- my ($self, $c) = @_;
- $c->res->output($c->req->uri_with({
- the_word_that_must_be_heard => 'mtfnpy'
- }));
- }
-
- sub test_uri_object : Global {
- my ($self, $c) = @_;
- $c->res->output($c->uri_for('/test_uri_object')->path);
- }
-
- sub per_request : Global {
- my ($self, $c) = @_;
- $c->uri_disposition('relative');
- $c->res->output($c->uri_for('/dummy'));
- }
-
- sub host_header : Global {
- my ($self, $c) = @_;
- $c->uri_disposition('host-header');
- $c->res->output($c->uri_for('/dummy'));
- }
-
-
- sub host_header_with_port : Global {
- my ($self, $c) = @_;
- $c->uri_disposition('host-header');
- $c->res->output($c->uri_for('/dummy'));
- }
-
- sub req_uri_class : Global {
- my ($self, $c) = @_;
- $c->res->output(ref($c->req->uri).' '.$c->req->uri);
- }
-
- sub req_referer_class : Global {
- my ($self, $c) = @_;
- $c->res->output(ref $c->req->referer);
- }
-
- sub dummy : Global {}
-
- __PACKAGE__->config->{'Plugin::SmartURI'}{disposition} = 'hostless';
- __PACKAGE__->setup();
-}
-
+use FindBin '$Bin';
+use lib "$Bin/lib";
use Catalyst::Test 'TestApp';
use HTTP::Request;
@@ -86,10 +30,10 @@
is(request($req)->content, 'http://www.hlagh.com:8080/dummy',
'host-header disposition with port');
-is(get('/req_uri_class'), 'URI::SmartURI::http http://localhost/req_uri_class',
+is(get('/req_uri_class'), 'MyURI::http http://localhost/req_uri_class',
'overridden $c->req->uri');
-like(get('/req_referer_class'), qr/^URI::SmartURI::/,
+like(get('/req_referer_class'), qr/^MyURI::/,
'overridden $c->req->referer');
# vim: expandtab shiftwidth=4 tw=80:
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/t/02-c-a-rest-compat.t
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/02-c-a-rest-compat.t 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/02-c-a-rest-compat.t 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,37 +1,17 @@
-#!perl -T
+#!perl
use strict;
use warnings;
use Test::More tests => 1;
+use FindBin '$Bin';
+use lib "$Bin/lib";
+use Catalyst::Test 'TestApp';
SKIP: {
skip 'Catalyst::Action::REST not installed', 1
if eval { require Catalyst::Action::REST }, $@;
-{
- package TestApp;
-
- use Catalyst 'SmartURI';
-
- sub foo : Global ActionClass('REST') {}
-
- sub foo_GET {
- my ($self, $c) = @_;
-
-# should break if request_class is not set correctly
- $c->req->accepted_content_types;
-
- $c->res->output($c->req->uri_with({foo => 'bar'}));
- }
-
- __PACKAGE__->config->{'Plugin::SmartURI'}{disposition} = 'hostless';
-
- __PACKAGE__->setup();
-}
-
-use Catalyst::Test 'TestApp';
-
is(get('/foo'), '/foo?foo=bar',
'C::A::REST and SmartURI are both functional');
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/t/03-uri-class.t
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/03-uri-class.t 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/03-uri-class.t 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,34 +1,12 @@
+#!perl
+
use strict;
use warnings;
-
+use FindBin '$Bin';
+use lib "$Bin/lib";
+use Catalyst::Test 'TestApp';
use Test::More tests => 1;
-{
- package MyURI;
+is(get('/test_my_uri'), '/dummy?foo=bar', 'configured uri_class');
- use base 'URI::SmartURI';
-
- sub mtfnpy {
- my $uri = shift;
- $uri->query_form([ $uri->query_form, qw(foo bar) ]);
- $uri
- }
-
- package TestApp;
-
- use Catalyst 'SmartURI';
-
- sub foo : Global {
- my ($self, $c) = @_;
- $c->res->output($c->uri_for('/foo')->mtfnpy)
- }
-
- __PACKAGE__->config->{'Plugin::SmartURI'}{uri_class} = 'MyURI';
- __PACKAGE__->setup;
-}
-
-use Catalyst::Test 'TestApp';
-
-is(get('/foo'), 'http://localhost/foo?foo=bar', 'configured uri_class');
-
# vim: expandtab shiftwidth=4 ts=4 tw=80:
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/t/boilerplate.t
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/boilerplate.t 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/boilerplate.t 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use strict;
use warnings;
Added: Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/MyURI.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/MyURI.pm (rev 0)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/MyURI.pm 2009-05-14 01:07:51 UTC (rev 10141)
@@ -0,0 +1,11 @@
+package MyURI;
+
+use parent 'URI::SmartURI';
+
+sub mtfnpy {
+ my $uri = shift;
+ $uri->query_form([ $uri->query_form, qw(foo bar) ]);
+ $uri
+}
+
+1;
Added: Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/MyURI.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/MyURI.pm (rev 0)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/MyURI.pm 2009-05-14 01:07:51 UTC (rev 10141)
@@ -0,0 +1,10 @@
+package TestApp::Controller::MyURI;
+
+use parent 'Catalyst::Controller';
+
+sub test_my_uri : Global {
+ my ($self, $c) = @_;
+ $c->res->output($c->uri_for('/dummy')->mtfnpy)
+}
+
+1;
Added: Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/REST.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/REST.pm (rev 0)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/REST.pm 2009-05-14 01:07:51 UTC (rev 10141)
@@ -0,0 +1,18 @@
+package TestApp::Controller::REST;
+
+use parent 'Catalyst::Controller';
+
+eval { Class::MOP::load_class('Catalyst::Action::REST') } && eval q{
+ sub foo : Global ActionClass('REST') {}
+
+ sub foo_GET {
+ my ($self, $c) = @_;
+
+# should break if request_class is not set correctly
+ $c->req->accepted_content_types;
+
+ $c->res->output($c->req->uri_with({foo => 'bar'}));
+ }
+};
+
+1;
Added: Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp/Controller/Root.pm 2009-05-14 01:07:51 UTC (rev 10141)
@@ -0,0 +1,53 @@
+package TestApp::Controller::Root;
+
+use parent 'Catalyst::Controller';
+
+sub test_uri_for_redirect : Global {
+ my ($self, $c) = @_;
+ $c->res->redirect($c->uri_for('/test_uri_for_redirect'));
+}
+
+sub test_req_uri_with : Global {
+ my ($self, $c) = @_;
+ $c->res->output($c->req->uri_with({
+ the_word_that_must_be_heard => 'mtfnpy'
+ }));
+}
+
+sub test_uri_object : Global {
+ my ($self, $c) = @_;
+ $c->res->output($c->uri_for('/test_uri_object')->path);
+}
+
+sub per_request : Global {
+ my ($self, $c) = @_;
+ $c->uri_disposition('relative');
+ $c->res->output($c->uri_for('/dummy'));
+}
+
+sub host_header : Global {
+ my ($self, $c) = @_;
+ $c->uri_disposition('host-header');
+ $c->res->output($c->uri_for('/dummy'));
+}
+
+
+sub host_header_with_port : Global {
+ my ($self, $c) = @_;
+ $c->uri_disposition('host-header');
+ $c->res->output($c->uri_for('/dummy'));
+}
+
+sub req_uri_class : Global {
+ my ($self, $c) = @_;
+ $c->res->output(ref($c->req->uri).' '.$c->req->uri);
+}
+
+sub req_referer_class : Global {
+ my ($self, $c) = @_;
+ $c->res->output(ref $c->req->referer);
+}
+
+sub dummy : Global {}
+
+1;
Added: Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp.pm (rev 0)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/lib/TestApp.pm 2009-05-14 01:07:51 UTC (rev 10141)
@@ -0,0 +1,12 @@
+package TestApp;
+
+use Catalyst qw/SmartURI/;
+
+__PACKAGE__->config({'Plugin::SmartURI' => {
+ disposition => 'hostless',
+ uri_class => 'MyURI',
+}});
+
+__PACKAGE__->setup;
+
+1;
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/t/pod.t
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/t/pod.t 2009-05-13 23:40:44 UTC (rev 10140)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/t/pod.t 2009-05-14 01:07:51 UTC (rev 10141)
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use strict;
use warnings;
More information about the Catalyst-commits
mailing list