File Coverage

lib/MetaPOD/Format/JSON.pm
Criterion Covered Total %
statement 30 31 96.7
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 2 2 100.0
total 44 45 97.7


line stmt bran cond sub pod time code
1 3     3   292080 use strict;
  3         6  
  3         108  
2 3     3   15 use warnings;
  3         6  
  3         135  
3              
4             package MetaPOD::Format::JSON;
5             BEGIN {
6 3     3   83 $MetaPOD::Format::JSON::AUTHORITY = 'cpan:KENTNL';
7             }
8             {
9             $MetaPOD::Format::JSON::VERSION = '0.3.0';
10             }
11              
12             # ABSTRACT: Reference implementation of a C based MetaPOD Format
13              
14              
15 3     3   1007 use Moo;
  3         23962  
  3         24  
16 3     3   2753 use Carp qw( croak );
  3         9  
  3         208  
17 3     3   3045 use version 0.77;
  3         7176  
  3         21  
18              
19             with 'MetaPOD::Role::Format';
20              
21 3     3   2028 use MetaPOD::Format::JSON::v1;
  3         11  
  3         101  
22 3     3   2023 use MetaPOD::Format::JSON::v1_1;
  3         40  
  3         668  
23              
24             my $dispatch_table = [
25             {
26             version => version->parse('v1.0.0'),
27             handler => 'MetaPOD::Format::JSON::v1'
28             },
29             {
30             version => version->parse('v1.1.0'),
31             handler => 'MetaPOD::Format::JSON::v1_1'
32             }
33             ];
34              
35              
36             sub supported_versions {
37 26     26 1 131489 return qw( v1.0.0 v1.1.0 );
38             }
39              
40              
41             sub add_segment {
42 13     13 1 563359 my ( $self, $segment, $result ) = @_;
43 13         64 my $segver = $self->supports_version( $segment->{version} );
44 13         246 for my $v ( @{$dispatch_table} ) {
  13         43  
45 22 100       254 next unless $v->{version} == $segver;
46 13         146 $v->{handler}->add_segment( $segment, $result );
47 13         39 return $result;
48             }
49 0           croak "No implementation found for version $segver";
50             }
51              
52             1;
53              
54             __END__