From: Tomas Doran Date: Sat, 30 Jun 2012 10:35:42 +0000 (+0100) Subject: Use String::RewritePrefix, it's already a Cat dep X-Git-Tag: 0.10021~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-Authentication.git;a=commitdiff_plain;h=d5e3af2f76a0b603ff282d161a4f952941b4f93d Use String::RewritePrefix, it's already a Cat dep --- diff --git a/Changes b/Changes index 113a5da..a8b09a0 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension Catalyst::Plugin::Authentication + - Change Catalyst::Authentication::Realm to use String::RewritePrefix + rather than doing namespace mangling manually. - Fix whitespace and tabs, add Test::EOL and Test::NoTabs - Document optional methods in stores needed for auto_create_user and auto_update_user in realms. diff --git a/Makefile.PL b/Makefile.PL index d31da22..b8cd666 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -23,7 +23,7 @@ requires 'Catalyst::Plugin::Session' => '0.10'; requires 'Moose'; requires 'MooseX::Emulate::Class::Accessor::Fast'; requires 'namespace::clean'; - +requires 'String::RewritePrefix'; test_requires 'Test::More' => '0.88'; test_requires 'Test::Exception'; diff --git a/lib/Catalyst/Authentication/Realm.pm b/lib/Catalyst/Authentication/Realm.pm index 9a61a2e..28ce7ea 100644 --- a/lib/Catalyst/Authentication/Realm.pm +++ b/lib/Catalyst/Authentication/Realm.pm @@ -2,6 +2,7 @@ package Catalyst::Authentication::Realm; use strict; use warnings; +use String::RewritePrefix; use base qw/Class::Accessor::Fast/; @@ -41,11 +42,10 @@ sub new { ## follow catalyst class naming - a + prefix means a fully qualified class, otherwise it's ## taken to mean C::P::A::Store::(specifiedclass) - if ($storeclass !~ /^\+(.*)$/ ) { - $storeclass = "Catalyst::Authentication::Store::${storeclass}"; - } else { - $storeclass = $1; - } + $storeclass = String::RewritePrefix->rewrite({ + '' => 'Catalyst::Authentication::Store::', + '+' => '', + }, $storeclass); # a little niceness - since most systems seem to use the password credential class, # if no credential class is specified we use password. @@ -55,11 +55,10 @@ sub new { ## follow catalyst class naming - a + prefix means a fully qualified class, otherwise it's ## taken to mean C::A::Credential::(specifiedclass) - if ($credentialclass !~ /^\+(.*)$/ ) { - $credentialclass = "Catalyst::Authentication::Credential::${credentialclass}"; - } else { - $credentialclass = $1; - } + $credentialclass = String::RewritePrefix->rewrite({ + '' => 'Catalyst::Authentication::Credential::', + '+' => '', + }, $credentialclass); # if we made it here - we have what we need to load the classes