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.0002';
4 1     1   51967 use 5.010;
  1         3  
5              
6 1     1   286 use Class::Tiny::Antlers;
  1         3286  
  1         5  
7              
8             extends 'Statistics::R::IO::Base';
9              
10 1     1   428 use Statistics::R::IO::REXPFactory;
  1         3  
  1         38  
11 1     1   6 use Carp;
  1         1  
  1         41  
12              
13 1     1   5 use namespace::clean;
  1         2  
  1         3  
14              
15              
16             sub read {
17 49     49 1 727 my $self = shift;
18            
19 49         187 my $data = $self->_read_and_uncompress;
20            
21 42 50       212 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         84 my ($value, $state) = @{Statistics::R::IO::REXPFactory::unserialize(substr($data, 5))};
  42         250  
27 42 50       200 croak 'Could not parse RData file' unless $state;
28 42 50       132 croak 'Unread data remaining in the RData file' unless $state->eof;
29 42         369 Statistics::R::IO::REXPFactory::tagged_pairlist_to_rexp_hash $value;
30             }
31              
32            
33             1;
34              
35             __END__