GX/Engine.pm

filter: Statementstmt 57.1% 12 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod n/a totaltotal 51.7% 15 / 29 CC 2 SCAR 10.0
CC
2
Cov
52%
_render_reload_error
6.0
_initialize_config
2.0
_validate_class_name
2.0
CRAP 2.7
« GX/HTTP/Request.pm ↑ Summary GX/Callback/Queue.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/Engine.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::Engine;
7  
8 2 ▶use GX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use GX::HTML::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 # ----------------------------------------------------------------------------------------------------------------------
13 # Class setup
14 # ----------------------------------------------------------------------------------------------------------------------
15  
16 2 ▶use GX::Class ( extends => 'GX::Component::Singleton' );
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 build;
19  
20  
21 # ----------------------------------------------------------------------------------------------------------------------
22 # Export mechanism
23 # ----------------------------------------------------------------------------------------------------------------------
24  
25 2 __PACKAGE__->_install_import_method;
26  
27  
28 # ----------------------------------------------------------------------------------------------------------------------
29 # Private methods
30 # ----------------------------------------------------------------------------------------------------------------------
31  
32 0 ▶sub _initialize_config {
Subroutine _initialize_config: not called CC=1 SCAR=6.9
33  
34 return {
35 0 'buffer_size' => 8192, # 8 KiB
36 'max_request_size' => 1048576, # 1 MiB
37 'max_request_memory_usage' => 16384 # 16 KiB
38 };
39  
40 }
41  
42 0 ▶sub _render_reload_error {
Subroutine _render_reload_error: not called CC=2 SCAR=17.9
43  
44 0 my $invocant = shift;
45 0 my $error = shift;
46  
47 # The generated HTML should be kept in sync with GX::View::Error and GX::Exception::as_html()
48  
49 0 ▶ my $message = GX::HTML::Util::escape_html( defined $error ? "$error" : 'Reload error' );
Branch: 1 branch
BranchTrueFalseTotal
defined $error ? : 0 0 0
50  
51 0 $message =~ s/\n/<br \/>/g;
52  
53 0 my $html = <<HTML;
54 <?xml version="1.0" encoding="UTF-8"?>
55 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
56 <html xmlns="http://www.w3.org/1999/xhtml">
57 <head>
58 <title>Reload error</title>
59 <meta http-equiv="Cache-Control" content="no-cache" />
60 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
61 <meta http-equiv="Expires" content="0" />
62 <meta http-equiv="Pragma" content="no-cache" />
63 <meta name="robots" content="noindex, nofollow" />
64 <style type="text/css">
65 body, code, div, h1, h2, p, table, tbody, tr, td { margin:0; padding:0 }
66 body { padding:50px; font-size:15px; font-family:Arial, sans-serif; color:#333 }
67 h1 { margin:0 0 25px 0; font-size: 32px }
68 h2 { margin:0 0 25px 0; font-size: 24px }
69 li { margin-bottom:25px }
70 p { margin:15px 0 }
71 table { width:100%; empty-cells:show; border-spacing:1px }
72 code { font-family:"DejaVu Sans Mono", Monaco, "Lucida Console", "Andale Mono", monospace }
73 div.message { margin:25px 0; padding:15px; background:#F4CDCD }
74 div.subexceptions { margin:50px 0 }
75 div.stack_trace { margin:50px 0 }
76 div.stack_trace p strong { padding:3px 5px; background: #FEEFB3; font-size:13px; font-family:"DejaVu Sans Mono", Monaco, "Lucida Console", "Andale Mono", monospace }
77 div.viewport { overflow:auto }
78 table.source code { font-size:13px; color:#444 }
79 table.source td { padding:2px 5px; background:#EEE }
80 table.source td.line { text-align:right }
81 table.source td.code { width:100% }
82 table.source tr.highlight td { background:#E3E3E3 }
83 table.source tr.highlight td code { color:#333 }
84 </style>
85 </head>
86 <body>
87 <h1>Reload error</h1>
88 <div class="exception">
89 <div class="message"><code>$message</code></div>
90 </div>
91 </body>
92 </html>
93 HTML
94  
95 0 utf8::encode( $html );
96  
97 0 return $html;
98  
99 }
100  
101 0 ▶sub _validate_class_name {
Subroutine _validate_class_name: not called CC=1 SCAR=6.9
102  
103 0 return $_[1] =~ /^(?:[_a-zA-Z]\w*::)+?Engine$/;
104  
105 }
106  
107  
108 2 1;
109  
110 __END__
« GX/HTTP/Request.pm ↑ Summary GX/Callback/Queue.pm »