File Coverage

blib/lib/Statistics/R/IO/RData.pm
Criterion Covered Total %
statement 3 5 60.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 5 7 71.4


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.0';
4 1     1   16620 use 5.010;
  1         3  
5              
6 1     1   925 use Moose;
  0            
  0            
7              
8             with 'Statistics::R::IO::Base';
9              
10             use Statistics::R::IO::REXPFactory;
11             use Carp;
12              
13             use namespace::clean;
14              
15              
16             sub read {
17             my $self = shift;
18            
19             my $data = $self->_read_and_uncompress;
20            
21             if (substr($data, 0, 5) ne "RDX2\n") {
22             croak 'File does not start with the RData magic number: ' .
23             unpack('H*', substr($data, 0, 5));
24             }
25              
26             my ($value, $state) = @{Statistics::R::IO::REXPFactory::unserialize(substr($data, 5))};
27             croak 'Could not parse RData file' unless $state;
28             croak 'Unread data remaining in the RData file' unless $state->eof;
29             Statistics::R::IO::REXPFactory::tagged_pairlist_to_rexp_hash $value;
30             }
31              
32            
33             __PACKAGE__->meta->make_immutable;
34              
35             1;
36              
37             __END__