File Coverage

blib/lib/Plack/Middleware/Acme/YadaYada.pm
Criterion Covered Total %
statement 21 22 95.4
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 31 33 93.9


line stmt bran cond sub pod time code
1             ## no critic (RequireUseStrict)
2             package Plack::Middleware::Acme::YadaYada;
3             BEGIN {
4 1     1   801 $Plack::Middleware::Acme::YadaYada::VERSION = '0.01';
5             }
6              
7             ## use critic (RequireUseStrict)
8 1     1   7 use strict;
  1         1  
  1         31  
9 1     1   4 use warnings;
  1         1  
  1         29  
10              
11 1     1   5 use parent 'Plack::Middleware';
  1         1  
  1         10  
12              
13 1     1   1079 use Try::Tiny;
  1         1538  
  1         175  
14              
15             sub call {
16 2     2 1 25495 my ( $self, $env ) = @_;
17              
18 2         17 my $app = $self->app;
19 2         112 my $retval;
20              
21             try {
22 2     2   63 $retval = $app->($env);
23             } catch {
24 1 50   1   22 if(/^Unimplemented/) {
25 1         6 $retval = [
26             501,
27             ['Content-Type' => 'text/plain'],
28             ['Not Implemented'],
29             ];
30             } else {
31 0         0 die;
32             }
33 2         14 };
34              
35 2         45 return $retval;
36             };
37              
38             1;
39              
40              
41              
42             =pod
43              
44             =head1 NAME
45              
46             Plack::Middleware::Acme::YadaYada - Middleware that handles the Yada Yada operator
47              
48             =head1 VERSION
49              
50             version 0.01
51              
52             =head1 SYNOPSIS
53              
54             use Plack::Builder;
55              
56             my $app = sub { ... };
57              
58             builder {
59             enable 'Acme::YadaYada';
60             $app;
61             };
62              
63             =head1 DESCRIPTION
64              
65             This middleware handles exceptions thrown by the Yada Yada operator and
66             returns "501 Not Implemented" if it encounters any.
67              
68             =head1 SEE ALSO
69              
70             L, L
71              
72             =head1 AUTHOR
73              
74             Rob Hoelz
75              
76             =head1 COPYRIGHT AND LICENSE
77              
78             This software is copyright (c) 2011 by Rob Hoelz.
79              
80             This is free software; you can redistribute it and/or modify it under
81             the same terms as the Perl 5 programming language system itself.
82              
83             =head1 BUGS
84              
85             Please report any bugs or feature requests on the bugtracker website
86             http://github.com/hoelzro/plack-middleware-acme-yadayada/issues
87              
88             When submitting a bug or request, please include a test-file or a
89             patch to an existing test-file that illustrates the bug or desired
90             feature.
91              
92             =cut
93              
94              
95             __END__