OpenSearch/Response/ExtJS.pm

filter: Statementstmt 100% 34 / 34 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 88.4% 46 / 52 CC 6 SCAR 13.6
CC
6
Cov
89%
stringify
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« OpenSearch.pm ↑ Summary OpenSearch/Response.pm »
1 package Search::OpenSearch::Response::ExtJS;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'Search::OpenSearch::Response::JSON';
5 2 ▶use Types::Standard qw( HashRef Bool );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Sort::SQL;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '0.409';
10  
11 2 has 'metaData' => ( is => 'rw', isa => HashRef );
12 2 has 'success' => ( is => 'rw', isa => Bool );
13  
14 1 ▶sub stringify {
Subroutine stringify: called CC=6 SCAR=18.4
Pod documented
15 1 my $self = shift;
16  
17 1 my $resp = $self->as_hash;
18  
19 1 ▶ if ( !defined $resp->{metaData} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $resp->{"metaData"}) 1 0 1
20 1 my $sort_info = delete $resp->{sort_info};
21 1 ▶ if ($sort_info) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sort_info) 1 0 1
22 1 my $sorted = Sort::SQL->parse($sort_info);
23 1 $sort_info = {
24 field => $sorted->[0]->[0],
25 direction => $sorted->[0]->[1],
26 };
27 }
28 $resp->{metaData} = {
29 idProperty => 'uri',
30 root => 'results',
31 totalProperty => 'total',
32 successProperty => 'success',
33 start => delete $resp->{offset},
34 limit => delete $resp->{page_size},
35 1 sortInfo => $sort_info,
36 };
37 my @fields = (
38 1 ▶ @{ delete( $resp->{fields} ) || [] },
Condition50%1/2
delete $resp->{'fields'} || []
l!l
01
MC/DC0%0/1
delete $resp->{'fields'} || []
delete $resp->{'fields'}
Truth table50%1/2
A
A= delete $resp->{'fields'}
Aresult
11
00
39 1 @{ $self->default_fields }
40 );
41 1 $resp->{metaData}->{fields} = \@fields;
42 }
43  
44 1 ▶ $resp->{success} = 1 unless defined $resp->{success};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $resp->{"success"} 1 0 1
45  
46 # in devel mode use pretty()
47 1 ▶ return $self->debug
Branch: 1 branch
BranchTrueFalseTotal
$self->debug ? : 0 1 1
48 ? JSON->new->utf8->pretty(1)->encode($resp)
49 : encode_json($resp);
50 }
51  
52 2 1;
53  
54 __END__
« OpenSearch.pm ↑ Summary OpenSearch/Response.pm »