File Coverage

blib/lib/Parser/FIT/Simple.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 32 34 94.1


line stmt bran cond sub pod time code
1             package Parser::FIT::Simple;
2              
3 1     1   59959 use strict;
  1         22  
  1         27  
4 1     1   5 use warnings;
  1         1  
  1         21  
5              
6 1     1   416 use Parser::FIT;
  1         3  
  1         136  
7              
8             sub new {
9 1     1 0 69 my $class = shift;
10              
11 1         2 my $self = {};
12              
13 1         2 bless($self, $class);
14              
15 1         10 return $self;
16             }
17              
18             sub parse {
19 1     1 0 5 my $self = shift;
20 1         2 my $file = shift;
21              
22 1         6 my $result = {};
23              
24             my $parser = Parser::FIT->new(on => {
25             _any => sub {
26 109     109   143 my ($msgType, $msg) = (shift, shift);
27 109 100       181 if(!exists $result->{$msgType}) {
28 7         14 $result->{$msgType} = [];
29             }
30              
31 109         121 push(@{$result->{$msgType}}, $msg);
  109         239  
32             }
33 1         10 });
34              
35 1         5 $parser->parse($file);
36              
37 1         42 return $result;
38             }
39              
40             1;
41              
42             __END__