Subject: | [PATCH] Update plugin to use Moose instead of NEXT |
The plugin uses the old NEXT system which is deprecated in Catalyst.
This patch converts it to use the newer Moose::Role methods.
Subject: | 0001-Remove-NEXT-replace-with-Moose-Role.patch |
From 95e1d77a555dcc1caae2ab29cbbd843450e8e337 Mon Sep 17 00:00:00 2001
From: Toby Corkindale <tobyc@strategicdata.com.au>
Date: Thu, 21 Jan 2010 15:59:03 +1100
Subject: [PATCH] Remove NEXT, replace with Moose::Role
---
lib/Catalyst/Plugin/UploadProgress.pm | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/lib/Catalyst/Plugin/UploadProgress.pm b/lib/Catalyst/Plugin/UploadProgress.pm
index ee97eb3..c0910f3 100644
--- a/lib/Catalyst/Plugin/UploadProgress.pm
+++ b/lib/Catalyst/Plugin/UploadProgress.pm
@@ -2,11 +2,12 @@ package Catalyst::Plugin::UploadProgress;
use strict;
use warnings;
-use NEXT;
+use Moose::Role;
-our $VERSION = '0.04';
+our $VERSION = '0.10';
-sub prepare_body_chunk {
+# I'm concerned that this doesn't call super() at all..
+override 'prepare_body_chunk' => sub {
my ( $c, $chunk ) = @_;
my $body = $c->request->{_body};
@@ -33,9 +34,9 @@ sub prepare_body_chunk {
$c->cache->set( 'upload_progress_' . $id, $progress );
}
}
-}
+};
-sub prepare_body {
+override 'prepare_body' => sub {
my $c = shift;
# Detect if the user stopped the upload, prepare_body will die with an invalid
@@ -49,7 +50,7 @@ sub prepare_body {
$croaked = shift;
};
- $c->NEXT::prepare_body(@_);
+ super;
}
if ( $croaked ) {
@@ -67,9 +68,9 @@ sub prepare_body {
# rethrow the error
Catalyst::Exception->throw( $croaked );
}
-}
+};
-sub dispatch {
+override 'dispatch' => sub {
my $c = shift;
# if the URI query string is ?progress_id=<id> intercept the request
@@ -79,20 +80,18 @@ sub dispatch {
return $c->upload_progress_output( $1 );
}
- return $c->NEXT::ACTUAL::dispatch(@_);
-}
+ return super;
+};
-sub setup {
+after 'setup' => sub {
my $c = shift;
- $c->NEXT::setup(@_);
-
unless ( $c->can('cache') ) {
Catalyst::Exception->throw(
message => 'UploadProgress requires a cache plugin.'
);
}
-}
+};
sub upload_progress {
my ( $c, $upload_id ) = @_;
@@ -279,6 +278,9 @@ JSON output from C</upload_progress_output>.
Andy Grundman, <andy@hybridized.org>
+NEXT to Moose::Role conversion by Toby Corkindale, <tjc@cpan.org>, blame him
+for any faults there..
+
=head1 THANKS
The authors of L<Apache2::UploadProgress>, for the progress.js and
@@ -292,4 +294,4 @@ progress.css code:
This program is free software, you can redistribute it and/or modify it under
the same terms as Perl itself.
-=cut
\ No newline at end of file
+=cut
--
1.6.6