blib/lib/Dancer/Handler/Debug.pm

filter: Statementstmt 100% 48 / 48 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 11 / 11 Podpod 33.3% 1 / 3 totaltotal 91.3% 63 / 69 CC 4 SCAR 4.5
CC
4
Cov
94%
run
3.0
start
2.0
BEGIN
1.0
CRAP 1.6
« lib/Dancer/Object/Singleton.pm ↑ Summary lib/Dancer/HTTP.pm »
1 package Dancer::Handler::Debug;
2 2 our $AUTHORITY = 'cpan:SUKRIA';
3 #ABSTRACT: a debug handler for easy tracing
4 2 $Dancer::Handler::Debug::VERSION = '1.3522';
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use HTTP::Server::Simple::PSGI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use base 'Dancer::Object', 'Dancer::Handler', 'HTTP::Server::Simple::PSGI';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Dancer::Config 'setting';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Dancer::SharedData;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶sub run {
Subroutine run: called CC=3 SCAR=11.0
Pod documented
16 2 my ($self, $req) = @_;
17  
18 2 my ($method, $path, $query, @env ) = @ARGV;
19 2 my $host = "127.0.0.1";
20 2 my $port = "3000";
21  
22 my $env = {
23 'HTTP_ACCEPT' => '*/*',
24 'HTTP_HOST' => "$host:$port",
25 'HTTP_USER_AGENT' => 'curl',
26 'QUERY_STRING' => $query,
27 'REMOTE_ADDR' => "$host:$port",
28 'REMOTE_HOST' => "$host:$port",
29 'REQUEST_METHOD' => $method,
30 'REQUEST_URI' => $path,
31 'SERVER_NAME' => $host,
32 'SERVER_PORT' => $port,
33 'SERVER_PROTOCOL' => 'HTTP/1.1',
34 'SERVER_SOFTWARE' => 'HTTP::Server::Simple/0.41',
35 'SERVER_URL' => "http://$host:$port/",
36 2 ▶ map { /=/ ? split /=/, $_, 2 : () } @env
Branch: 1 branch
BranchTrueFalseTotal
/=/ ? : 1 0 1
37 };
38  
39 2 $req = Dancer::Request->new(env => $env);
40
41 2 my $headers = HTTP::Headers->new(
42 'User-Agent' => 'curl',
43 'Host', "$host:$port",
44 'Accept', '*/*'
45 );
46 2 $req->headers($headers);
47  
48 # now simulate a PSGI response for the current request only
49 2 ▶ my $res = eval { $self->{psgi_app}->($env) }
Condition50%1/2
eval { do { $self->{'psgi_app'}->($env) } } || [500, ['Content-Type', 'text/plain'], ['Internal Server Error']]
l!l
20
MC/DC0%0/1
eval { do { $self->{'psgi_app'}->($env) } } || [500, ['Content-Type', 'text/plain'], ['Internal Server Error']]
eval { do { $self->{'psgi_app'}->($env) } }
Truth table50%1/2
A
A= eval { do { $self->{'psgi_app'}->($env) } }
Aresult
11
00
50 || [500, ['Content-Type', 'text/plain'], ["Internal Server Error"]];
51  
52 2 $self->_handle_response($res);
53 2 print "\n";
54  
55 2 return $res;
56 }
57  
58 2 ▶sub start {
Subroutine start: called CC=2 SCAR=6.9
Pod undocumented
59 2 my ($self, $req) = @_;
60 2 ▶ print STDERR ">> Dancer dummy debug server\n" if setting('startup_info');
Branch: 1 branch
BranchTrueFalseTotal
if setting("startup_info") 0 2 2
61
62 2 my $dancer = Dancer::Handler::Debug->new();
63 2 ▶ my $psgi = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
64 2 my $env = shift;
65 2 my $req = Dancer::Request->new(env => $env);
66 2 $dancer->handle_request($req);
67 2 };
68 2 $dancer->{psgi_app} = $psgi;
69 2 $dancer->run($req);
70 }
71  
72 2 ▶sub dance { start(@_) }
Subroutine dance: called CC=1 SCAR=0.0
Pod undocumented
73 2 1;
74  
75 __END__
« lib/Dancer/Object/Singleton.pm ↑ Summary lib/Dancer/HTTP.pm »