blib/lib/Plack/Middleware/GNUTerryPratchett.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 96.7% 30 / 31 CC 2 SCAR 2.5
CC
2
Cov
96%
__ANON__
2.0
call
1.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 package Plack::Middleware::GNUTerryPratchett;
2  
3 # ABSTRACT: Adds automatically an X-Clacks-Overhead header.
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.01';
10  
11 1 ▶use parent qw/Plack::Middleware/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶sub call {
Subroutine call: called CC=1 SCAR=0.0
Pod documented
14 1 my $self = shift;
15 1 my $res = $self->app->(@_);
16  
17 $self->response_cb(
18 $res,
19 1 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
20 1 my $res = shift;
21 1 my $headers = $res->[1];
22 1 ▶ return if ( Plack::Util::header_exists( $headers, 'X-Clacks-Overhead' ) );
Branch: 1 branch
BranchTrueFalseTotal
if Plack::Util::header_exists($headers, "X-Clacks-Overhead") 0 1 1
23 1 Plack::Util::header_set( $headers, 'X-Clacks-Overhead', 'GNU Terry Pratchett' );
24 1 return;
25 }
26 1 );
27 }
28  
29 1 1;
30  
31 =pod
32  
33 =head1 NAME
34  
35 Plack::Middleware::GNUTerryPratchett - Adds automatically an X-Clacks-Overhead header.
36  
37 =head1 VERSION
38  
39 version 0.01
40  
41 =head1 SYNOPSIS
42  
43 use Plack::Builder;
44  
45 my $app = builder {
46 enable "Plack::Middleware::GNUTerryPratchett";
47 sub {[ '200', ['Content-Type' => 'text/html'], ['hello world']] }
48 };
49  
50 =head1 DESCRIPTION
51  
52 Plack::Middleware::GNUTerryPratchett adds automatically an X-Clacks-Overhead header.
53  
54 In Terry Pratchett's Discworld series, the clacks are a series of semaphore towers loosely based on the concept of the telegraph. Invented by an artificer named Robert Dearheart, the towers could send messages "at the speed of light" using standardized codes. Three of these codes are of particular import:
55  
56 B<G>: send the message on
57  
58 B<N>: do not log the message
59  
60 B<U>: turn the message around at the end of the line and send it back again
61 When Dearheart died, his name was inserted into the overhead of the clacks with a "GNU" in front of it to memorialize him forever (or for at least as long as the clacks are standing.)
62  
63 For more information: L<http://www.gnuterrypratchett.com/>
64  
65 =head1 AUTHOR
66  
67 Tiago Peczenyj <tiago.peczenyj@gmail.com>
68  
69 =cut
↑ Summary