blib/lib/JSON/RPC/Lite.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 100% 47 / 47 CC 2 SCAR 1.7
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package JSON::RPC::Lite;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use version; our $VERSION = version->declare("v1.0.0");
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use JSON::RPC::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Plack::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
11 3 my $pkg = caller(0);
12 3 my $rpc = JSON::RPC::Spec->new;
13 2 ▶ my $method = sub ($$) {
Subroutine __ANON__: called CC=1 SCAR=0.0
14 2 $rpc->register(@_);
15 3 };
16 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 *{"${pkg}::method"} = $method;
18 3 ▶ *{"${pkg}::as_psgi_app"} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
19 3 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
20 3 my $req = Plack::Request->new(@_);
21 3 my $body = $rpc->parse($req->content);
22 3 my $header = ['Content-Type' => 'application/json'];
23 3 ▶ if (length $body) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $body) 2 1 3
24 2 return [200, $header, [$body]];
25 }
26 1 return [204, [], []];
27 2 };
28 3 };
29 }
30  
31 3 1;
32 __END__
↑ Summary