JSON/Base.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 66.6% 2 / 3 totaltotal 97.8% 46 / 47 CC 2 SCAR 1.7
CC
2
Cov
100%
TO_JSON
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« JSON/Role/ToJson.pm ↑ Summary JSON/Types.pm »
1 package Geo::JSON::Base;
2  
3 6 our $VERSION = '0.007';
4  
5 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 with 'Geo::JSON::Role::ToJson';
7  
8 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶use Geo::JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Geo::JSON::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Geo::JSON::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 has type => (
17 is => 'ro',
18 isa => Str,
19 58 ▶ default => sub { ( ( ref $_[0] ) =~ m/::(\w+)$/ )[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 6 required => 1,
21 );
22  
23 6 has crs => ( is => 'ro', isa => Maybe [CRS], coerce => CRS->coercion );
24  
25 6 has bbox => ( is => 'rw', isa => Maybe [ ArrayRef [Num] ] );
26  
27 # used by JSON 'convert_blessed'
28 30 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=2 SCAR=6.9
Pod undocumented
29 30 my $self = $_[0];
30  
31 my %output = (
32 type => $self->type,
33 30 %{$self},
34 );
35  
36 # prevent empty 'crs' key
37 delete $output{crs}
38 30 ▶ unless defined $output{crs};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $output{"crs"} 20 10 30
39  
40 30 return \%output;
41 }
42  
43 7 ▶sub compute_bbox {
Subroutine compute_bbox: called CC=1 SCAR=0.0
Pod documented
44 7 return Geo::JSON::Utils::compute_bbox( shift->all_positions );
45 }
46  
47 4 ▶sub all_positions {
Subroutine all_positions: called CC=1 SCAR=0.0
Pod documented
48 4 return shift->coordinates;
49 }
50  
51 6 1;
52  
53 __END__
« JSON/Role/ToJson.pm ↑ Summary JSON/Types.pm »