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   59219 use strict;
  1         10  
  1         24  
4 1     1   4 use warnings;
  1         1  
  1         20  
5              
6 1     1   365 use Parser::FIT;
  1         4  
  1         141  
7              
8             sub new {
9 1     1 0 68 my $class = shift;
10              
11 1         3 my $self = {};
12              
13 1         2 bless($self, $class);
14              
15 1         11 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   172 my ($msgType, $msg) = (shift, shift);
27 109 100       185 if(!exists $result->{$msgType}) {
28 7         14 $result->{$msgType} = [];
29             }
30              
31 109         118 push(@{$result->{$msgType}}, $msg);
  109         272  
32             }
33 1         9 });
34              
35 1         4 $parser->parse($file);
36              
37 1         40 return $result;
38             }
39              
40             1;
41              
42             __END__