Throwable/Role/Status/ImATeapot.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 40 SCAR 30.0
CC
4
Cov
0%
text_body
20.0
default_status_code
2.0
default_reason
2.0
CRAP 20.0
1 package HTTP::Throwable::Role::Status::ImATeapot;
2 our $AUTHORITY = 'cpan:STEVAN';
3 $HTTP::Throwable::Role::Status::ImATeapot::VERSION = '0.027';
4 use Types::Standard qw(Bool);
5  
6 use Moo::Role;
7  
8 with(
9 'HTTP::Throwable',
10 );
11  
12 has 'short' => (is => 'ro', isa => Bool, default => 0);
13 has 'stout' => (is => 'ro', isa => Bool, default => 0);
14  
15 sub default_status_code { 418 }
16 sub default_reason { q{I'm a teapot} }
17  
18 my $TEAPOT = <<'END';
19 (
20 _ ) )
21 _,(_)._ (( I'M A LITTLE TEAPOT__X__
22 ___,(_______). )
23 ,'__. / \ /\_
24 /,' / |""| \ / /
25 | | | |__| |,' /
26 \`.| /
27 `. : : /
28 `. :.,'
29 `-.________,-'
30 END
31  
32 sub text_body {
33 my $self = shift;
34 my $base = $TEAPOT;
35 my $msg = $self->short && $self->stout ? " SHORT AND STOUT"
36 : $self->short ? " SHORT NOT STOUT"
37 : $self->stout ? " MERELY STOUT"
38 : " WITH A SPOUT";
39  
40 $base =~ s/__X__/$msg/;
41  
42 return $base;
43 }
44  
45 no Moo::Role; 1;
46  
47 =pod
48  
49 =encoding UTF-8
50  
51 =head1 NAME
52  
53 HTTP::Throwable::Role::Status::ImATeapot - 418 I'm a teapot
54  
55 =head1 VERSION
56  
57 version 0.027
58  
59 =head1 DESCRIPTION
60  
61 This exception provides RFC2324 support, in accordance with section 2.3.3:
62  
63 Any attempt to brew coffee with a teapot should result in the error code
64 "418 I'm a teapot". The resulting entity body MAY be short and stout.
65  
66 Boolean attributes C<short> and C<stout> are provided, and default to false.
67  
68 =head1 AUTHORS
69  
70 =over 4
71  
72 =item *
73  
74 Stevan Little <stevan.little@iinteractive.com>
75  
76 =item *
77  
78 Ricardo Signes <rjbs@cpan.org>
79  
80 =back
81  
82 =head1 COPYRIGHT AND LICENSE
83  
84 This software is copyright (c) 2011 by Infinity Interactive, Inc.
85  
86 This is free software; you can redistribute it and/or modify it under
87 the same terms as the Perl 5 programming language system itself.
88  
89 =cut
90  
91 __END__