[Catalyst-commits] r9896 - in Catalyst-Plugin-SmartURI/1.000/trunk: . lib/Catalyst/Plugin

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Mon Apr 27 15:48:11 GMT 2009


Author: caelum
Date: 2009-04-27 16:48:10 +0100 (Mon, 27 Apr 2009)
New Revision: 9896

Removed:
   Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST
Modified:
   Catalyst-Plugin-SmartURI/1.000/trunk/Changes
   Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST.SKIP
   Catalyst-Plugin-SmartURI/1.000/trunk/META.yml
   Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL
   Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm
Log:
P::SmartURI - convert to Moose

Modified: Catalyst-Plugin-SmartURI/1.000/trunk/Changes
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/Changes	2009-04-27 14:52:27 UTC (rev 9895)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/Changes	2009-04-27 15:48:10 UTC (rev 9896)
@@ -1,38 +1,42 @@
 Revision history for Catalyst-Plugin-SmartURI
 
-0.01  2008-03-08 03:30:31
-    First version.
+0.032  2009-04-27 15:42:07
+    - converted to Moose
+    - some minor POD cleanups
 
-0.01_01  2008-04-01 08:33:13
-    First dev release.
+0.030  2008-11-19 17:54:37
+    - fixed for Catalyst 5.8
 
-0.02  2008-06-03 21:58:17
-    Moved Catalyst::SmartURI into a separate dist as URI::SmartURI
+0.029  2008-10-09 07:02:46
+    - fixed the host-header stuff for when there's no port.
 
-0.021  2008-06-16 22:20:42
-    Minor speedup, avoiding unnecessary string evals.
+0.028  2008-08-22 03:53:49
+    - added note to the POD about usage with C::C::REST.
 
-0.022  2008-06-24 16:52:55
-    Fix weird bug with initialization that sometimes happens.
+0.027  2008-07-06 14:17:12
+    - improved request class, better Host header parsing, fixed POD.
 
-0.023  2008-06-28 01:14:49
-    Weaken saved context.
+0.025  2008-06-28 08:33:57
+    - fucked up the pod for SYNOPSIS...
 
 0.024  2008-06-28 03:01:53
-    Added 'host-header' disposition.
-    Converted conf key to 'Plugin::SmartURI'
+    - added 'host-header' disposition.
+    - converted conf key to 'Plugin::SmartURI'
 
-0.025  2008-06-28 08:33:57
-    Fucked up the pod for SYNOPSIS...
+0.023  2008-06-28 01:14:49
+    - weaken saved context.
 
-0.027  2008-07-06 14:17:12
-    Improved request class, better Host header parsing, fixed POD.
+0.022  2008-06-24 16:52:55
+    - fix weird bug with initialization that sometimes happens.
 
-0.028  2008-08-22 03:53:49
-    Added note to the POD about usage with C::C::REST.
+0.021  2008-06-16 22:20:42
+    - minor speedup, avoiding unnecessary string evals.
 
-0.029  2008-10-09 07:02:46
-    Fixed the host-header stuff for when there's no port.
+0.02  2008-06-03 21:58:17
+    - moved Catalyst::SmartURI into a separate dist as URI::SmartURI
 
-0.030  2008-11-19 17:54:37
-    Fixed for Catalyst 5.8
+0.01_01  2008-04-01 08:33:13
+    - first dev release.
+
+0.01  2008-03-08 03:30:31
+    - first version.

Deleted: Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST	2009-04-27 14:52:27 UTC (rev 9895)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST	2009-04-27 15:48:10 UTC (rev 9896)
@@ -1,24 +0,0 @@
-Changes
-inc/Module/AutoInstall.pm
-inc/Module/Install.pm
-inc/Module/Install/AutoInstall.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Include.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-lib/Catalyst/Plugin/SmartURI.pm
-Makefile.PL
-MANIFEST			This list of files
-MANIFEST.SKIP
-META.yml
-README
-t/00-load.t
-t/01-basic.t
-t/02-c-a-rest-compat.t
-t/03-uri-class.t
-t/boilerplate.t
-t/pod.t

Modified: Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST.SKIP
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST.SKIP	2009-04-27 14:52:27 UTC (rev 9895)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/MANIFEST.SKIP	2009-04-27 15:48:10 UTC (rev 9896)
@@ -1,5 +1,4 @@
-\..*\.swp
-.svn
-.exists
-MANIFEST.bak
-Makefile.old
+# stolen from Devel::REPL
+^(?!script/|examples/|lib/|inc/|t/|Makefile.PL$|README$|MANIFEST$|Changes$|META.yml$)
+.svn/
+.swp$

Modified: Catalyst-Plugin-SmartURI/1.000/trunk/META.yml
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/META.yml	2009-04-27 14:52:27 UTC (rev 9895)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/META.yml	2009-04-27 15:48:10 UTC (rev 9896)
@@ -3,9 +3,12 @@
 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.79'
+generated_by: 'Module::Install version 0.85'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -16,12 +19,10 @@
     - inc
     - t
 requires:
-  Catalyst: 5.7007
-  Class::Accessor::Fast: 0
+  Catalyst: 5.80002
   Class::C3::Componentised: 0
   Task::Weaken: 0
   URI::SmartURI: 0
-  parent: 0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.031
+version: 0.032

Modified: Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL	2009-04-27 14:52:27 UTC (rev 9895)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/Makefile.PL	2009-04-27 15:48:10 UTC (rev 9896)
@@ -4,12 +4,10 @@
 all_from 'lib/Catalyst/Plugin/SmartURI.pm';
 author   'Rafael Kitover <rkitover at cpan.org>';
 
-requires 'Catalyst' => '5.7007';
+requires 'Catalyst' => '5.80002';
 requires 'Class::C3::Componentised';
-requires 'Class::Accessor::Fast';
 requires 'URI::SmartURI';
 requires 'Task::Weaken';
-requires 'parent';
 
 build_requires 'Test::More';
 

Modified: Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm	2009-04-27 14:52:27 UTC (rev 9895)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm	2009-04-27 15:48:10 UTC (rev 9896)
@@ -1,18 +1,19 @@
 package Catalyst::Plugin::SmartURI;
 
-use strict;
-use warnings;
-use parent 'Class::Accessor::Fast';
+use Moose;
+use mro 'c3';
 
-use Class::C3;
 use Class::C3::Componentised;
 use Scalar::Util 'weaken';
 use Catalyst::Exception ();
 
-__PACKAGE__->mk_accessors(qw/uri_disposition uri_class/);
+use namespace::clean -except => 'meta';
 
-my $context; # keep a copy for the Request class to use
+has uri_disposition => (is => 'rw', isa => 'Str');
+has uri_class       => (is => 'rw', isa => 'Str');
 
+my $context; # keep a weakend copy for the Request class to use
+
 my ($conf_disposition, $conf_uri_class); # configured values
 
 =head1 NAME
@@ -21,11 +22,11 @@
 
 =head1 VERSION
 
-Version 0.031
+Version 0.032
 
 =cut
 
-our $VERSION = '0.031';
+our $VERSION = '0.032';
 
 =head1 SYNOPSIS
 
@@ -57,9 +58,9 @@
 To use your own URI class, just subclass L<URI::SmartURI> and set
 uri_class, or write a class that follows the same interface.
 
-This plugin installs a custom $c->request_class, however it does so in a way
-that won't break if you've already set $c->request_class yourself, ie. by using
-L<Catalyst::Action::REST> (thanks mst!).
+This plugin installs a custom C<$c->request_class>, however it does so in a way
+that won't break if you've already set C<$c->request_class> yourself, ie. by
+using L<Catalyst::Action::REST> (thanks mst!).
 
 There is a minor performance penalty in perls older than 5.10, due to
 L<Class::C3>, but only at initialization time.
@@ -70,24 +71,24 @@
 
 =head2 $c->req->uri_with
 
-Returns a $c->uri_class object (L<URI::SmartURI> by default) in the configured
-$c->uri_disposition.
+Returns a C<<$c->uri_class>> object (L<URI::SmartURI> by default) in the configured
+C<<$c->uri_disposition>>.
 
 =head2 $c->req->uri
 
-Returns a $c->uri_class object. If the context hasn't been prepared yet, uses
+Returns a C<<$c->uri_class>> object. If the context hasn't been prepared yet, uses
 the configured value for uri_class.
 
-$c->req->uri->relative will be relative to $c->req->base.
+C<$c->req->uri->relative> will be relative to C<$c->req->base>.
 
 =head2 $c->req->referer
 
-Returns a $c->uri_class object for the referer (or configured uri_class if
-there's no context) with reference set to $c->req->uri if it comes from
-$c->req->base.
+Returns a C<$c->uri_class> object for the referer (or configured uri_class if
+there's no context) with reference set to C<<$c->req->uri>> if it comes from
+C<<$c->req->base>>.
 
-In other words, if referer is your web server, you can do
-$c->req->referer->relative and it will do the right thing.
+In other words, if referer is your app, you can do
+C<<$c->req->referer->relative>> and it will do the right thing.
 
 =head1 CONFIGURATION
 
@@ -134,8 +135,8 @@
 
 =item $c->uri_class($class)
 
-Set the URI class to use for $c->uri_for and $c->req->uri_with for the duration
-of the request.
+Set the URI class to use for C<<$c->uri_for>> and C<<$c->req->uri_with> for the
+duration of the request.
 
 =back
 
@@ -169,7 +170,9 @@
 
 {
     package Catalyst::Request::SmartURI;
-    use base 'Catalyst::Request';
+    use Moose;
+    extends 'Catalyst::Request';
+    use namespace::clean -except => 'meta';
 
     sub uri_with {
         my $req = shift;
@@ -204,6 +207,8 @@
             return $uri_class->new($referer);
         }
     }
+
+    __PACKAGE__->meta->make_immutable;
 }
 
 sub setup {
@@ -214,12 +219,10 @@
     $conf_uri_class   ||= 'URI::SmartURI';
     $conf_disposition ||= 'absolute';
 
-    unless (do { no strict 'refs'; %{$conf_uri_class.'::'} }) {
-        eval "require $conf_uri_class";
-        Catalyst::Exception->throw(
-            message => "Could not load configured uri_class $conf_uri_class: $@"
-        ) if $@;
-    }
+    eval { Class::MOP::load_class($conf_uri_class) };
+    Catalyst::Exception->throw(
+        message => "Could not load configured uri_class $conf_uri_class: $@"
+    ) if $@;
 
     my $request_class = $app->request_class;
 
@@ -238,25 +241,16 @@
     $app->next::method(@_)
 }
 
-{
-my %loaded;
-
 sub prepare_uri {
     my ($c, $uri)   = @_;
     my $disposition = $c->uri_disposition || $conf_disposition;
     my $uri_class   = $c->uri_class       || $conf_uri_class;
 # Need the || for $c->welcome_message, otherwise initialization works fine.
 
-    unless ($loaded{$uri_class} || do { no strict 'refs'; %{$uri_class.'::'} }) {
-        eval "require $uri_class";
-        if ($@) {
-            Catalyst::Exception->throw(
-                message => "Could not load configured uri_class $conf_uri_class: $@"
-            );
-        } else {
-            $loaded{$uri_class}++
-        }
-    }
+    eval { Class::MOP::load_class($uri_class) };
+    Catalyst::Exception->throw(
+        message => "Could not load configured uri_class $uri_class: $@"
+    ) if $@;
 
     my $res;
     if ($disposition eq 'host-header') {
@@ -277,7 +271,6 @@
 
     $res
 }
-}
 
 # Reset accessors to configured values at beginning of request.
 sub prepare {
@@ -293,6 +286,8 @@
     $c
 }
 
+__PACKAGE__->meta->make_immutable;
+
 =head1 SEE ALSO
 
 L<URI::SmartURI>, L<Catalyst>, L<URI>




More information about the Catalyst-commits mailing list