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