From: adam Date: Mon, 16 Oct 2006 22:19:00 +0000 (+0000) Subject: Ran perltidy X-Git-Tag: 0.67_01~72 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=eccb21379de1fbdc65740e0cb4158d3b4d055cab Ran perltidy --- diff --git a/lib/Catalyst/Action/Deserialize.pm b/lib/Catalyst/Action/Deserialize.pm index 2d778b4..2d5343f 100644 --- a/lib/Catalyst/Action/Deserialize.pm +++ b/lib/Catalyst/Action/Deserialize.pm @@ -19,35 +19,35 @@ sub execute { my $self = shift; my ( $controller, $c, $test ) = @_; - my $nreq = bless($c->request, 'Catalyst::Request::REST'); + my $nreq = bless( $c->request, 'Catalyst::Request::REST' ); $c->request($nreq); - unless(defined($self->plugins)) { + unless ( defined( $self->plugins ) ) { my $mpo = Module::Pluggable::Object->new( - 'require' => 1, - 'search_path' => [ 'Catalyst::Action::Deserialize' ], + 'require' => 1, + 'search_path' => ['Catalyst::Action::Deserialize'], ); my @plugins = $mpo->plugins; - $self->plugins(\@plugins); + $self->plugins( \@plugins ); } my $content_type = $c->request->content_type; - my $sclass = 'Catalyst::Action::Deserialize::'; + my $sclass = 'Catalyst::Action::Deserialize::'; my $sarg; my $map = $controller->serialize->{'map'}; - if (exists($map->{$content_type})) { + if ( exists( $map->{$content_type} ) ) { my $mc; - if (ref($map->{$content_type}) eq "ARRAY") { - $mc = $map->{$content_type}->[0]; + if ( ref( $map->{$content_type} ) eq "ARRAY" ) { + $mc = $map->{$content_type}->[0]; $sarg = $map->{$content_type}->[1]; } else { $mc = $map->{$content_type}; } $sclass .= $mc; - if (! grep(/^$sclass$/, @{$self->plugins})) { + if ( !grep( /^$sclass$/, @{ $self->plugins } ) ) { die "Cannot find plugin $sclass for $content_type!"; } } else { - if (exists($controller->serialize->{'default'})) { + if ( exists( $controller->serialize->{'default'} ) ) { $sclass .= $controller->serialize->{'default'}; } else { die "I cannot find a default serializer!"; @@ -55,17 +55,17 @@ sub execute { } my @demethods = qw(POST PUT OPTIONS); - my $method = $c->request->method; - if (grep /^$method$/, @demethods) { - if (defined($sarg)) { - $sclass->execute($controller, $c, $sarg); + my $method = $c->request->method; + if ( grep /^$method$/, @demethods ) { + if ( defined($sarg) ) { + $sclass->execute( $controller, $c, $sarg ); } else { - $sclass->execute($controller, $c); + $sclass->execute( $controller, $c ); } $self->NEXT::execute( @_, ); } else { - $self->NEXT::execute( @_ ); + $self->NEXT::execute(@_); } -}; +} 1; diff --git a/lib/Catalyst/Action/Deserialize/Data/Serializer.pm b/lib/Catalyst/Action/Deserialize/Data/Serializer.pm index 35917ec..ef43574 100644 --- a/lib/Catalyst/Action/Deserialize/Data/Serializer.pm +++ b/lib/Catalyst/Action/Deserialize/Data/Serializer.pm @@ -16,23 +16,24 @@ use Data::Serializer; sub execute { my $self = shift; my ( $controller, $c, $serializer ) = @_; - + my $body = $c->request->body; if ($body) { my $rbody; - if (-f $c->request->body) { - open(BODY, "<", $c->request->body); - while (my $line = ) { + if ( -f $c->request->body ) { + open( BODY, "<", $c->request->body ); + while ( my $line = ) { $rbody .= $line; } close(BODY); } - my $dso = Data::Serializer->new(serializer => $serializer); - my $rdata = $dso->raw_deserialize($rbody); + my $dso = Data::Serializer->new( serializer => $serializer ); + my $rdata = $dso->raw_deserialize($rbody); $c->request->data($rdata); } else { - $c->log->debug('I would have deserialized, but there was nothing in the body!'); + $c->log->debug( + 'I would have deserialized, but there was nothing in the body!'); } -}; +} 1; diff --git a/lib/Catalyst/Action/Deserialize/YAML.pm b/lib/Catalyst/Action/Deserialize/YAML.pm index aa6c411..b972830 100644 --- a/lib/Catalyst/Action/Deserialize/YAML.pm +++ b/lib/Catalyst/Action/Deserialize/YAML.pm @@ -16,14 +16,15 @@ use YAML::Syck; sub execute { my $self = shift; my ( $controller, $c, $test ) = @_; - + my $body = $c->request->body; if ($body) { - my $rdata = LoadFile($c->request->body); + my $rdata = LoadFile( $c->request->body ); $c->request->data($rdata); } else { - $c->log->debug('I would have deserialized, but there was nothing in the body!'); + $c->log->debug( + 'I would have deserialized, but there was nothing in the body!'); } -}; +} 1; diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index f071d8f..d04fa0d 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -17,8 +17,8 @@ sub dispatch { my ( $self, $c ) = @_; my $controller = $self->class; - my $method = $self->name . "_" . uc($c->request->method); - if ($controller->can($method)) { + my $method = $self->name . "_" . uc( $c->request->method ); + if ( $controller->can($method) ) { return $controller->$method($c); } else { $self->_return_405($c); @@ -30,18 +30,21 @@ sub _return_405 { my ( $self, $c ) = @_; my $controller = $self->class; - my $methods = Class::Inspector->methods($controller); + my $methods = Class::Inspector->methods($controller); my @allowed; - foreach my $method (@{$methods}) { + foreach my $method ( @{$methods} ) { my $name = $self->name; - if ($method =~ /^$name\_(.+)$/) { - push(@allowed, $1); + if ( $method =~ /^$name\_(.+)$/ ) { + push( @allowed, $1 ); } } $c->response->content_type('text/plain'); $c->response->status(405); - $c->response->header('Allow' => \@allowed); - $c->response->body("Method " . $c->request->method . " not implemented for " . $c->uri_for($self->reverse)); + $c->response->header( 'Allow' => \@allowed ); + $c->response->body( "Method " + . $c->request->method + . " not implemented for " + . $c->uri_for( $self->reverse ) ); } 1; diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index d747576..4896438 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -24,36 +24,36 @@ sub execute { return 1 if $c->response->status =~ /^(?:204|3\d\d)$/; # Load the Serialize Classes - unless(defined($self->plugins)) { + unless ( defined( $self->plugins ) ) { my $mpo = Module::Pluggable::Object->new( - 'require' => 1, - 'search_path' => [ 'Catalyst::Action::Serialize' ], + 'require' => 1, + 'search_path' => ['Catalyst::Action::Serialize'], ); my @plugins = $mpo->plugins; - $self->plugins(\@plugins); + $self->plugins( \@plugins ); } # Look up what serializer to use from content_type map - # + # # If we don't find one, we use the default my $content_type = $c->request->content_type; - my $sclass = 'Catalyst::Action::Serialize::'; + my $sclass = 'Catalyst::Action::Serialize::'; my $sarg; my $map = $controller->serialize->{'map'}; - if (exists($map->{$content_type})) { + if ( exists( $map->{$content_type} ) ) { my $mc; - if (ref($map->{$content_type}) eq "ARRAY") { - $mc = $map->{$content_type}->[0]; + if ( ref( $map->{$content_type} ) eq "ARRAY" ) { + $mc = $map->{$content_type}->[0]; $sarg = $map->{$content_type}->[1]; } else { $mc = $map->{$content_type}; } $sclass .= $mc; - if (! grep(/^$sclass$/, @{$self->plugins})) { + if ( !grep( /^$sclass$/, @{ $self->plugins } ) ) { die "Cannot find plugin $sclass for $content_type!"; } } else { - if (exists($controller->serialize->{'default'})) { + if ( exists( $controller->serialize->{'default'} ) ) { $sclass .= $controller->serialize->{'default'}; } else { die "I cannot find a default serializer!"; @@ -61,17 +61,17 @@ sub execute { } # Go ahead and serialize ourselves - if (defined($sarg)) { - $sclass->execute($controller, $c, $sarg); + if ( defined($sarg) ) { + $sclass->execute( $controller, $c, $sarg ); } else { - $sclass->execute($controller, $c); + $sclass->execute( $controller, $c ); } - if (! $c->response->content_type ) { - $c->response->content_type($c->request->content_type); + if ( !$c->response->content_type ) { + $c->response->content_type( $c->request->content_type ); } return 1; -}; +} 1; diff --git a/lib/Catalyst/Action/Serialize/Data/Serializer.pm b/lib/Catalyst/Action/Serialize/Data/Serializer.pm index 0b0fb4b..138fd36 100644 --- a/lib/Catalyst/Action/Serialize/Data/Serializer.pm +++ b/lib/Catalyst/Action/Serialize/Data/Serializer.pm @@ -17,9 +17,9 @@ sub execute { my ( $controller, $c, $serializer ) = @_; my $stash_key = $controller->serialize->{'stash_key'} || 'rest'; - my $dso = Data::Serializer->new(serializer => $serializer); + my $dso = Data::Serializer->new( serializer => $serializer ); $c->response->output( $dso->raw_serialize( $c->stash->{$stash_key} ) ); return 1; -}; +} 1; diff --git a/lib/Catalyst/Action/Serialize/YAML.pm b/lib/Catalyst/Action/Serialize/YAML.pm index 5488cc4..ec328ca 100644 --- a/lib/Catalyst/Action/Serialize/YAML.pm +++ b/lib/Catalyst/Action/Serialize/YAML.pm @@ -20,6 +20,6 @@ sub execute { my $stash_key = $controller->serialize->{'stash_key'} || 'rest'; $c->response->output( Dump( $c->stash->{$stash_key} ) ); return 1; -}; +} 1; diff --git a/lib/Catalyst/Controller/REST.pm b/lib/Catalyst/Controller/REST.pm index 8b3a064..5e6c359 100644 --- a/lib/Catalyst/Controller/REST.pm +++ b/lib/Catalyst/Controller/REST.pm @@ -8,17 +8,19 @@ __PACKAGE__->mk_accessors(qw(serialize)); __PACKAGE__->config( serialize => { - 'default' => 'YAML', + 'default' => 'YAML', 'stash_key' => 'rest', - 'map' => { - 'text/x-yaml' => 'YAML', + 'map' => { + 'text/x-yaml' => 'YAML', 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ], }, } ); -sub begin :ActionClass('Deserialize') {} +sub begin : ActionClass('Deserialize') { +} -sub end :ActionClass('Serialize') {} +sub end : ActionClass('Serialize') { +} 1;