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   170769 use strict;
  1         2  
  1         81  
4 1     1   11 use warnings;
  1         2  
  1         58  
5              
6 1     1   622 use Parser::FIT;
  1         4  
  1         223  
7              
8             sub new {
9 1     1 0 258323 my $class = shift;
10              
11 1         3 my $self = {};
12              
13 1         3 bless($self, $class);
14              
15 1         4 return $self;
16             }
17              
18             sub parse {
19 1     1 0 33 my $self = shift;
20 1         10 my $file = shift;
21              
22 1         2 my $result = {};
23              
24             my $parser = Parser::FIT->new(on => {
25             _any => sub {
26 109     109   256 my ($msgType, $msg) = (shift, shift);
27 109 100       350 if(!exists $result->{$msgType}) {
28 7         24 $result->{$msgType} = [];
29             }
30              
31 109         153 push(@{$result->{$msgType}}, $msg);
  109         378  
32             }
33 1         17 });
34              
35 1         8 $parser->parse($file);
36              
37 1         37 return $result;
38             }
39              
40             1;
41              
42             __END__