Plack.pm

filter: Statementstmt 48.5% 33 / 68 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 10 / 12 Podpod 100% 1 / 1 totaltotal 44.9% 44 / 98 CC 8 SCAR 34.3
CC
8
Cov
40%
__ANON__
72.0
__ANON__
2.0
psgi_app
1.9
CRAP 31.0
↑ Summary Plack/Transport.pm »
1 package SOAP::WSDL::Server::Plack;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use MooseX::FollowPBP;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: Plack application for SOAP::WSDL Server modules
6  
7 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Plack::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 2 has 'dispatch_to' => (
17 is => 'rw',
18 isa => 'Str',
19 required => 1,
20 documentation => 'Perl module with the SOAP method implementation',
21 );
22  
23  
24 2 has 'soap_service' => (
25 is => 'rw',
26 isa => 'Str',
27 required => 1,
28 documentation => 'Perl module with the SOAP::WSDL server implementation',
29 );
30  
31  
32 2 has 'transport_class' => (
33 is => 'rw',
34 isa => 'Str',
35 documentation => 'Transport class',
36 );
37  
38  
39 4 ▶sub psgi_app {
Subroutine psgi_app: called CC=1 SCAR=6.4
Pod documented
40 4 my ($self) = @_;
41  
42 0 ▶ return sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
43 0 my $env = shift;
44 0 my $req = Plack::Request->new($env);
45 0 my $res;
46 0 my $logger = $req->logger();
47 0 ▶ $logger = sub { } unless defined $logger;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $logger 0 0 0
48  
49 0 my $dispatch_to = $self->get_dispatch_to();
50 0 ▶ if (!$dispatch_to) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dispatch_to) 0 0 0
51 0 $logger->({
52 level => 'error',
53 message => "No 'dispatch_to' variable set in PlackHandler",
54 });
55 0 $res = $req->new_response(500);
56 0 return $res->finalize();
57 }
58 0 Plack::Util::load_class($dispatch_to);
59  
60 0 my $soap_service_package = $self->get_soap_service();
61 0 ▶ if (!$soap_service_package) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($soap_service_package) 0 0 0
62 0 $logger->({
63 level => 'error',
64 message => "No 'soap_service' variable set in PlackHandler",
65 });
66 0 $res = $req->new_response(500);
67 0 return $res->finalize();
68 }
69 0 Plack::Util::load_class($soap_service_package);
70  
71 0 my $transport_class = $self->get_transport_class();
72 0 ▶ unless ($transport_class) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($transport_class) 0 0 0
73 # if no transport class was specified, use this package's
74 # Transport class with its handle() method
75 0 $transport_class = __PACKAGE__ . '::Transport';
76 }
77 0 Plack::Util::load_class($transport_class);
78  
79 0 my $server = $soap_service_package->new({
80 dispatch_to => $dispatch_to, # methods
81 transport_class => $transport_class, # handle() class
82 });
83  
84 0 my $response_msg = $server->handle($req);
85 0 ▶ if (defined $response_msg && $response_msg =~ /^\d{3}$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response_msg and $response_msg =~ /^\d{3}$/) 0 0 0
Condition0%0/3
defined $response_msg and $response_msg =~ /^\d{3}$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $response_msg and $response_msg =~ /^\d{3}$/
defined $response_msg $response_msg =~ /^\d{3}$/
Truth table0%0/3
A and B
A= defined $response_msgB= $response_msg =~ /^\d{3}$/
ABresult
0X0
100
111
86 0 $logger->({
87 level => 'error',
88 message => "Dispatcher returned HTTP $response_msg",
89 });
90 0 $res = $req->new_response($response_msg);
91 0 return $res->finalize();
92 }
93  
94 0 ▶ if ($response_msg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response_msg) { } 0 0 0
95 0 $res = $req->new_response(200);
96 0 $res->content_type('text/xml; charset="utf-8"');
97 0 $res->body($response_msg);
98 0 return $res->finalize();
99 }
100 else {
101 0 $logger->({
102 level => 'error',
103 message => "No response returned from dispatcher",
104 });
105 0 $res = $req->new_response(500);
106 0 return $res->finalize();
107 }
108 }
109 4 }
110  
111 2 __PACKAGE__->meta->make_immutable();
112  
113  
114 __END__
↑ Summary Plack/Transport.pm »