File Coverage

blib/lib/ASP4/HTTPHandler.pm
Criterion Covered Total %
statement 63 70 90.0
branch 1 2 50.0
condition 0 3 0.0
subroutine 14 17 82.3
pod 0 7 0.0
total 78 99 78.7


line stmt bran cond sub pod time code
1              
2             package ASP4::HTTPHandler;
3              
4 9     9   60 use strict;
  9         12  
  9         276  
5 9     9   31 use warnings 'all';
  9         12  
  9         263  
6 9     9   2447 use Data::Properties::YAML;
  9         39174  
  9         525  
7              
8 0         0 BEGIN {
9             sub VARS {
10 72     72 0 9819 qw(
11             $Request $Response
12             $Session $Server
13             $Config $Form
14             $Stash
15             )
16             }
17 9     9   53 use vars __PACKAGE__->VARS;
  9     0   15  
  9         44  
18             }
19              
20              
21             sub new {
22 7123     7123 0 6874 my ($class, %args) = @_;
23 7123         15269 return bless \%args, $class;
24             }
25              
26              
27 5130     5130 0 5556 sub before_run { 1; }
28       5130 0   sub after_run { }
29              
30              
31             sub init_asp_objects
32             {
33 15382     15382 0 13913 my ($s, $context) = @_;
34            
35 15382         24597 $Request = $context->request;
36 15382         26904 $Response = $context->response;
37 15382         22991 $Session = $context->session;
38 15382         21582 $Server = $context->server;
39 15382         20866 $Form = $context->request->Form;
40 15382         23399 $Config = $context->config;
41 15382         19974 $Stash = $context->stash;
42            
43 15382 50       21302 my $class = ref($s) ? ref($s) : $s;
44 15382         23471 my @classes = $s->_parents( $class );
45 9     9   44 no strict 'refs';
  9         19  
  9         2266  
46 15382         19029 my %saw = ( );
47             map {
48 51151         34353 ${"$_\::Request"} = $Request;
  51151         64394  
49 51151         38462 ${"$_\::Response"} = $Response;
  51151         55205  
50 51151         34414 ${"$_\::Session"} = $Session;
  51151         56518  
51 51151         37758 ${"$_\::Server"} = $Server;
  51151         56065  
52 51151         31716 ${"$_\::Form"} = $Form;
  51151         53761  
53 51151         29739 ${"$_\::Config"} = $Config;
  51151         50942  
54 51151         28673 ${"$_\::Stash"} = $Stash;
  51151         68592  
55 15382         12834 } grep { ! $saw{$_}++ } @classes;
  51151         69790  
56            
57 15382         29764 return 1;
58             }# end init_asp_objects()
59              
60              
61             sub properties
62             {
63 0     0 0 0 my ($s, $file) = @_;
64            
65 0   0     0 $file ||= $Config->web->application_root . '/etc/properties.yaml';
66 0         0 return Data::Properties::YAML->new( properties_file => $file );
67             }# end properties()
68              
69             sub trim_form
70             {
71 9     9   48 no warnings 'uninitialized';
  9         17  
  9         1473  
72            
73             map {
74 0     0 0 0 $Form->{$_} =~ s/^\s+//;
  0         0  
75 0         0 $Form->{$_} =~ s/\s+$//;
76             } keys %$Form;
77             }# end trim()
78              
79              
80             sub _parents
81             {
82 51151     51151   43166 my ($s, $class ) = @_;
83            
84 51151         47535 my @classes = ( $class );
85 9     9   43 no strict 'refs';
  9         11  
  9         1023  
86 51151         34217 my $pkg = __PACKAGE__;
87 35769         44857 push @classes, map { $s->_parents( $_ ) }
88 35769         92706 grep { $_->isa($pkg) }
89 51151         36442 @{"$class\::ISA"};
  51151         95275  
90            
91 51151         88754 return @classes;
92             }# end _parents()
93              
94              
95             sub DESTROY
96             {
97 13301     13301   12932 my $s = shift;
98 13301         33389 undef(%$s);
99             }# end DESTROY()
100              
101             1;# return true:
102