Jmespath.pm

filter: Statementstmt 60.8% 28 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 60.0% 9 / 15 Podpod 0.0% 0 / 2 totaltotal 45.6% 37 / 81 CC 7 SCAR 29.7
CC
7
Cov
47%
search
56.0
compile
2.0
__ANON__
2.0
CRAP 19.6
« Jmespath/TreeInterpreter.pm ↑ Summary Jmespath/ArityException.pm »
1 package Jmespath;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Jmespath::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Jmespath::Visitor;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use JSON qw(encode_json decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 our $VERSION = '0.01';
10 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub compile {
14 0 ▶ my ( $class, $expression ) = @_;
Subroutine compile: not called CC=1 SCAR=6.9
Pod undocumented
15 0 return Jmespath::Parser->new->parse( Encode::encode_utf8($expression) );
16 }
17  
18 sub search {
19 0 ▶ my ( $class, $expression, $data, $options ) = @_;
Subroutine search: not called CC=7 SCAR=40.3
Pod undocumented
20 0 my ($result);
21 try {
22 0 ▶ $result = Jmespath::Parser->new->parse( $expression )
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 ->search( $data, $options );
24 } catch {
25 0 ▶ $_->throw;
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 };
27 0 ▶ return $result if not defined $result;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 0 0 0
28  
29 # JSON block result
30 0 ▶ if ( ( ref ($result) eq 'HASH' ) or
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq "HASH" or ref $result eq "ARRAY") 0 0 0
Condition0%0/3
ref $result eq "HASH" or ref $result eq "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $result eq "HASH" or ref $result eq "ARRAY"
ref $result eq "HASH" ref $result eq "ARRAY"
Truth table0%0/3
A or B
A= ref $result eq "HASH"B= ref $result eq "ARRAY"
ABresult
1X1
011
000
31 ( ref ($result) eq 'ARRAY' ) ) {
32 try {
33 0 ▶ $result = JSON->new
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 ->utf8(1)
35 ->allow_nonref
36 ->space_after
37 ->allow_blessed(1)
38 ->convert_blessed(1)
39 ->encode( $result );
40 0 return $result;
41 } catch {
42 0 ▶ Jmespath::ValueException->new( message => "cannot encode" )->throw;
Subroutine __ANON__: not called CC=1 SCAR=6.9
43 0 };
44 }
45  
46 0 ▶ if ( $result =~ /[0-9]+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result =~ /[0-9]+/u) 0 0 0
47 0 return $result;
48 }
49  
50 # Unquoted string result
51 0 ▶ if ( $ENV{JP_UNQUOTED} == 0 or
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"JP_UNQUOTED"} == 0 or not defined $ENV{"JP_UNQUOTED"}) 0 0 0
Condition0%0/3
$ENV{"JP_UNQUOTED"} == 0 or not defined $ENV{"JP_UNQUOTED"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{"JP_UNQUOTED"} == 0 or not defined $ENV{"JP_UNQUOTED"}
$ENV{"JP_UNQUOTED"} == 0 not defined $ENV{"JP_UNQUOTED"}
Truth table0%0/3
A or not(B)
A= $ENV{"JP_UNQUOTED"} == 0B= not defined $ENV{"JP_UNQUOTED"}
ABresult
1X1
011
000
52 not defined $ENV{JP_UNQUOTED} ) {
53 0 $result = q{"} . $result . q{"};
54 }
55 0 return $result;
56 }
57  
58 1 1;
59  
60 __END__
61  
62 =head1 NAME
63  
64 Jmespath - Enabling easy querying for JSON structures.
65  
« Jmespath/TreeInterpreter.pm ↑ Summary Jmespath/ArityException.pm »