File Coverage

blib/lib/Statistics/R/IO/RData.pm
Criterion Covered Total %
statement 22 23 95.6
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package Statistics::R::IO::RData;
2             # ABSTRACT: Supply object methods for RData files
3             $Statistics::R::IO::RData::VERSION = '1.0001';
4 1     1   14560 use 5.010;
  1         2  
5              
6 1     1   453 use Class::Tiny::Antlers;
  1         3953  
  1         4  
7              
8             extends 'Statistics::R::IO::Base';
9              
10 1     1   462 use Statistics::R::IO::REXPFactory;
  1         2  
  1         31  
11 1     1   4 use Carp;
  1         1  
  1         36  
12              
13 1     1   4 use namespace::clean;
  1         1  
  1         3  
14              
15              
16             sub read {
17 49     49 1 466 my $self = shift;
18            
19 49         126 my $data = $self->_read_and_uncompress;
20            
21 42 50       140 if (substr($data, 0, 5) ne "RDX2\n") {
22 0         0 croak 'File does not start with the RData magic number: ' .
23             unpack('H*', substr($data, 0, 5));
24             }
25              
26 42         45 my ($value, $state) = @{Statistics::R::IO::REXPFactory::unserialize(substr($data, 5))};
  42         163  
27 42 50       131 croak 'Could not parse RData file' unless $state;
28 42 50       83 croak 'Unread data remaining in the RData file' unless $state->eof;
29 42         239 Statistics::R::IO::REXPFactory::tagged_pairlist_to_rexp_hash $value;
30             }
31              
32            
33             1;
34              
35             __END__