Bletch, more tabs
Tomas Doran (t0m) [Sat, 23 May 2009 18:20:02 +0000 (19:20 +0100)]
lib/Catalyst/Controller/MessageDriven.pm
lib/Catalyst/Engine/Stomp.pm
t/01_notabs.t [new file with mode: 0644]
t/02_pod.t [new file with mode: 0644]
t/03_pod_coverage.t [new file with mode: 0644]

index 0c00a8d..4e87cb2 100644 (file)
@@ -13,7 +13,7 @@ Catalyst::Controller::MessageDriven
   use Moose;
   BEGIN { extends 'Catalyst::Controller::MessageDriven' }
 
-  sub some_action : Local { 
+  sub some_action : Local {
       my ($self, $c) = @_;
       # Reply with a minimal response message
       my $response = { type => 'testaction_response' };
@@ -24,40 +24,40 @@ Catalyst::Controller::MessageDriven
 
 A Catalyst controller base class for use with Catalyst::Engine::Stomp,
 which handles YAML-serialized messages. A top-level "type" key in the
-YAML determines the action dispatched to. 
+YAML determines the action dispatched to.
 
 =cut
 
 __PACKAGE__->config(
-                   'default'   => 'text/x-yaml',
-                   'stash_key' => 'response',
-                   'map'       => { 'text/x-yaml' => 'YAML' },
-                  );
+            'default'   => 'text/x-yaml',
+            'stash_key' => 'response',
+            'map'       => { 'text/x-yaml' => 'YAML' },
+           );
 
 sub begin :ActionClass('Deserialize') { }
 
 sub end :ActionClass('Serialize') {
-       my ($self, $c) = @_;
-
-       # Engine will send our reply based on the value of this header.
-       $c->response->headers->header( 'X-Reply-Address' => $c->req->data->{reply_to} );
-
-       # Custom error handler - steal errors from catalyst and dump them into
-       # the stash, to get them serialized out as the reply.
-       if (scalar @{$c->error}) {
-               my $error = join "\n", @{$c->error};
-               $c->stash->{response} = { status => 'ERROR', error => $error };
-               $c->error(0); # clear errors, so our response isn't clobbered
-       }
+    my ($self, $c) = @_;
+
+    # Engine will send our reply based on the value of this header.
+    $c->response->headers->header( 'X-Reply-Address' => $c->req->data->{reply_to} );
+
+    # Custom error handler - steal errors from catalyst and dump them into
+    # the stash, to get them serialized out as the reply.
+     if (scalar @{$c->error}) {
+         my $error = join "\n", @{$c->error};
+         $c->stash->{response} = { status => 'ERROR', error => $error };
+         $c->error(0); # clear errors, so our response isn't clobbered
+     }
 }
 
 sub default : Private {
-       my ($self, $c) = @_;
-       
-       # Forward the request to the appropriate action, based on the
-       # message type.
-       my $action = $c->req->data->{type};
-       $c->forward($action, [$c->req->data]);
+    my ($self, $c) = @_;
+
+    # Forward the request to the appropriate action, based on the
+    # message type.
+    my $action = $c->req->data->{type};
+    $c->forward($action, [$c->req->data]);
 }
 
 __PACKAGE__->meta->make_immutable;
index 20da9d2..21b275d 100644 (file)
@@ -46,10 +46,10 @@ Catalyst::Engine::Stomp - write message handling apps with Catalyst.
   # The default serialization is YAML, but this configuration
   # may be overridden in your controller:
   __PACKAGE__->config(
-           'default'   => 'text/x-yaml',
-           'stash_key' => 'rest',
-           'map'       => { 'text/x-yaml' => 'YAML' },
-          );
+              'default'   => 'text/x-yaml',
+            'stash_key' => 'rest',
+            'map'       => { 'text/x-yaml' => 'YAML' },
+           );
 
 =head1 DESCRIPTION
 
@@ -101,18 +101,18 @@ sub run {
 
     # subscribe, with client ack.
         foreach my $queue (@queues) {
-       my $queue_name = "/queue/$queue";
-       $self->connection->subscribe({
-                                     destination => $queue_name,
-                                     ack         => 'client',
-                                    });
+        my $queue_name = "/queue/$queue";
+        $self->connection->subscribe({
+                          destination => $queue_name,
+                          ack         => 'client',
+                         });
         }
 
     # enter loop...
     while (1) {
-       my $frame = $self->connection->receive_frame();
-       $self->handle_stomp_frame($app, $frame);
-       last if $ENV{ENGINE_ONESHOT};
+        my $frame = $self->connection->receive_frame();
+        $self->handle_stomp_frame($app, $frame);
+        last if $ENV{ENGINE_ONESHOT};
     }
     exit 0;
 }
@@ -142,7 +142,7 @@ sub finalize_headers {
     my ($self, $c) = @_;
     my $error = join "\n", @{$c->error};
     if ($error) {
-       $c->log->debug($error);
+        $c->log->debug($error);
     }
     return $self->next::method($c);
 }
@@ -158,13 +158,13 @@ sub handle_stomp_frame {
 
     my $command = $frame->command();
     if ($command eq 'MESSAGE') {
-       $self->handle_stomp_message($app, $frame);
+        $self->handle_stomp_message($app, $frame);
     }
     elsif ($command eq 'ERROR') {
-       $self->handle_stomp_error($app, $frame);
+        $self->handle_stomp_error($app, $frame);
     }
     else {
-       $app->log->debug("Got unknown Stomp command: $command");
+        $app->log->debug("Got unknown Stomp command: $command");
     }
 }
 
diff --git a/t/01_notabs.t b/t/01_notabs.t
new file mode 100644 (file)
index 0000000..391abe7
--- /dev/null
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+use File::Spec;
+use Test::More;
+
+if ( !-e "inc/.author" ) {
+    plan skip_all => 'NoTabs test only for developers.';
+}
+else {
+    eval { require Test::NoTabs };
+    if ( $@ ) {
+        plan tests => 1;
+        fail( 'You must install Test::NoTabs to run 01_no_tabs.t' );
+        exit;
+    }
+}
+
+Test::NoTabs->import;
+all_perl_files_ok(qw/lib/);
diff --git a/t/02_pod.t b/t/02_pod.t
new file mode 100644 (file)
index 0000000..05aa78a
--- /dev/null
@@ -0,0 +1,7 @@
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD} || -e 'inc/.author';
+
+all_pod_files_ok();
diff --git a/t/03_pod_coverage.t b/t/03_pod_coverage.t
new file mode 100644 (file)
index 0000000..5270b82
--- /dev/null
@@ -0,0 +1,13 @@
+use Test::More;
+
+eval "use Pod::Coverage 0.19";
+plan skip_all => 'Pod::Coverage 0.19 required' if $@;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD} || -e 'inc/.author';
+
+all_pod_coverage_ok(
+  {
+    also_private => [qw/BUILD BUILDARGS/]
+  }
+);