Simple/Parser/JSON.pm

filter: Statementstmt 84.0% 21 / 25 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 66.6% 2 / 3 totaltotal 75.0% 30 / 40 CC 2 SCAR 3.3
CC
2
Cov
79%
new
2.0
parse_response
2.0
BEGIN
1.0
CRAP 1.4
« Simple/Parser/XML/LibXML.pm ↑ Summary Simple/Parser/XML/Lite.pm »
1 # $Id$
2  
3 package WebService::Simple::Parser::JSON;
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use base qw(WebService::Simple::Parser);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use JSON 2.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new
10 4 ▶{
Subroutine new: called CC=2 SCAR=7.1
Pod documented
11 4 my $class = shift;
12 4 my %args = @_;
13  
14 4 ▶ my $json = delete $args{json} || JSON->new;
Condition33%1/3
delete $args{'json'} || 'JSON'->new
l!l&&r!l&&!r
040
MC/DC0%0/2
delete $args{'json'} || 'JSON'->new
delete $args{'json'} 'JSON'->new
Truth table33%1/3
A || B
A= delete $args{'json'}B= 'JSON'->new
ABresult
1X1
011
000
15 4 my $self = $class->SUPER::new(%args);
16 4 $self->{json} = $json;
17 4 return $self;
18 }
19  
20 sub parse_request
21 2 ▶{
Subroutine parse_request: called CC=1 SCAR=0.0
Pod undocumented
22 2 my $self = shift;
23 # my $content = $_[0]->decoded_content;
24 # # JSONP to pure JSON
25 # $content =~ s/[a-zA-Z_\$][a-zA-Z0-9_\$]*\s*\((.+)\)\s*;?\s*$/$1/;
26 2 $self->{json}->encode( $_[0] );
27 }
28  
29 sub parse_response
30 0 ▶{
Subroutine parse_response: not called CC=1 SCAR=6.9
Pod documented
31 0 my $self = shift;
32 0 my $content = $_[0]->decoded_content;
33 # JSONP to pure JSON
34 0 $content =~ s/[a-zA-Z_\$][a-zA-Z0-9_\$]*\s*\((.+)\)\s*;?\s*$/$1/;
35 0 $self->{json}->decode( $content );
36 }
37  
38 3 1;
39  
40 __END__
« Simple/Parser/XML/LibXML.pm ↑ Summary Simple/Parser/XML/Lite.pm »