File Coverage

blib/lib/HTTP/Status/Constants.pm
Criterion Covered Total %
statement 31 31 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod n/a
total 41 41 100.0


line stmt bran cond sub pod time code
1             package HTTP::Status::Constants;
2              
3 1     1   15561 use v5.10.0;
  1         3  
  1         85  
4              
5 1     1   4 use strict;
  1         1  
  1         27  
6 1     1   3 use warnings;
  1         3  
  1         23  
7              
8 1     1   412 use version 0.77; our $VERSION = version->declare('v0.1.0');
  1         1604  
  1         4  
9              
10 1     1   533 use Const::Exporter;
  1         10815  
  1         4  
11 1     1   506 use HTTP::Status ();
  1         2815  
  1         23  
12 1     1   5 use Package::Stash;
  1         1  
  1         151  
13              
14             =head1 NAME
15              
16             HTTP::Status::Constants - interpolable HTTP status constants
17              
18             =for readme plugin version
19              
20             =head1 SYNOPSIS
21              
22             use HTTP::Status::Constants;
23              
24             ...
25              
26             $response->status( $HTTP_NOT_FOUND );
27              
28             ...
29              
30             my %handlers => (
31             $HTTP_OK => sub { ... },
32             $HTTP_CREATED => sub { ... },
33             ...
34             );
35              
36             =head1 DESCRIPTION
37              
38             This module is basically a wrapper around L that allows
39             you to use the constants as read-only scalar variables instead of
40             function names.
41              
42             This means the constants can be used in contexts where you need
43             interpolated variables, such as hash keys or in strings.
44              
45             =begin :readme
46              
47             See the L documentation for more details on the POD
48             syntax that this module recognizes.
49              
50             See L for command-line usage.
51              
52             =head1 INSTALLATION
53              
54             See
55             L.
56              
57             =for readme plugin requires heading-level=2 title="Required Modules"
58              
59             =for readme plugin changes
60              
61             =end :readme
62              
63             =head1 SEE ALSO
64              
65             L
66              
67             =head1 AUTHOR
68              
69             Robert Rothenberg, C<< >>
70              
71             =head1 LICENSE AND COPYRIGHT
72              
73             Copyright 2014 Robert Rothenberg.
74              
75             This program is free software; you can redistribute it and/or modify it
76             under the terms of the the Artistic License (2.0). You may obtain a
77             copy of the full license at:
78              
79             L
80              
81             =for readme stop
82              
83             Any use, modification, and distribution of the Standard or Modified
84             Versions is governed by this Artistic License. By using, modifying or
85             distributing the Package, you accept this license. Do not use, modify,
86             or distribute the Package, if you do not accept this license.
87              
88             If your Modified Version has been derived from a Modified Version made
89             by someone other than you, you are nevertheless required to ensure that
90             your Modified Version complies with the requirements of this license.
91              
92             This license does not grant you the right to use any trademark, service
93             mark, tradename, or logo of the Copyright Holder.
94              
95             This license includes the non-exclusive, worldwide, free-of-charge
96             patent license to make, have made, use, offer to sell, sell, import and
97             otherwise transfer the Package with respect to any patent claims
98             licensable by the Copyright Holder that are necessarily infringed by the
99             Package. If you institute patent litigation (including a cross-claim or
100             counterclaim) against any party alleging that the Package constitutes
101             direct or contributory patent infringement, then this Artistic License
102             to you shall terminate on the date that such litigation is filed.
103              
104             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
105             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
106             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
107             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
108             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
109             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
110             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
111             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
112              
113             =for readme continue
114              
115             =cut
116              
117             BEGIN {
118 1     1   9 my $stash = Package::Stash->new('HTTP::Status');
119 1         40 my $syms = $stash->get_all_symbols('CODE');
120              
121 1         2 my @exports;
122              
123 1         1 foreach my $sym (keys %{$syms}) {
  1         10  
124 124 100       211 next unless $sym =~ /^HTTP_/;
125 58         43 my $val = &{$syms->{$sym}};
  58         114  
126 58         87 push @exports, '$' . $sym => $val;
127             }
128              
129 1         11 Const::Exporter->import( default => \@exports );
130             }
131              
132              
133             1;