blib/lib/Plack/App/JSONRPC.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 50 / 50 CC 3 SCAR 3.1
CC
3
Cov
100%
prepare_app
2.0
call
2.0
BEGIN
1.0
CRAP 1.4
↑ Summary
1 package Plack::App::JSONRPC;
2 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = "0.02";
6  
7 2 ▶use parent qw(Plack::Component);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use JSON::RPC::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Plack::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Plack::Util::Accessor qw(rpc);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶sub prepare_app {
Subroutine prepare_app: called CC=2 SCAR=6.9
Pod documented
13 4 my ($self) = @_;
14 4 my $rpc = JSON::RPC::Spec->new;
15 4 ▶ while (my ($name, $callback) = each %{$self->{methods}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"methods"};}) 12 4 16
16 12 $rpc->register($name, $callback);
17 }
18 4 $self->rpc($rpc);
19 4 return;
20 }
21  
22 4 ▶sub call {
Subroutine call: called CC=2 SCAR=6.9
Pod documented
23 4 my ($self, $env) = @_;
24 4 my $req = Plack::Request->new($env);
25 4 my $body = $self->rpc->parse($req->content);
26 4 ▶ if (length $body) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $body) 3 1 4
27 3 return [200, ['Content-Type' => 'application/json'], [$body]];
28 }
29 1 return [204, [], []];
30 }
31  
32 2 1;
33 __END__
↑ Summary