| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package ESPPlus::Storage; | 
| 2 | 6 |  |  | 6 |  | 122785 | use 5.006; | 
|  | 6 |  |  |  |  | 25 |  | 
|  | 6 |  |  |  |  | 229 |  | 
| 3 | 6 |  |  | 6 |  | 50 | use strict; | 
|  | 6 |  |  |  |  | 14 |  | 
|  | 6 |  |  |  |  | 172 |  | 
| 4 | 6 |  |  | 6 |  | 31 | use warnings; | 
|  | 6 |  |  |  |  | 13 |  | 
|  | 6 |  |  |  |  | 180 |  | 
| 5 | 6 |  |  | 6 |  | 30 | use Carp 'confess'; | 
|  | 6 |  |  |  |  | 8 |  | 
|  | 6 |  |  |  |  | 346 |  | 
| 6 | 6 |  |  | 6 |  | 6332 | use IO::File (); | 
|  | 6 |  |  |  |  | 81692 |  | 
|  | 6 |  |  |  |  | 130 |  | 
| 7 | 6 |  |  | 6 |  | 3735 | use ESPPlus::Storage::Util; | 
|  | 6 |  |  |  |  | 22 |  | 
|  | 6 |  |  |  |  | 280 |  | 
| 8 | 6 |  |  | 6 |  | 3333 | use ESPPlus::Storage::Record; | 
|  | 6 |  |  |  |  | 18 |  | 
|  | 6 |  |  |  |  | 180 |  | 
| 9 | 6 |  |  | 6 |  | 3879 | use ESPPlus::Storage::Reader; | 
|  | 6 |  |  |  |  | 18 |  | 
|  | 6 |  |  |  |  | 328 |  | 
| 10 | 6 |  |  | 6 |  | 3375 | use ESPPlus::Storage::Writer; | 
|  | 6 |  |  |  |  | 13 |  | 
|  | 6 |  |  |  |  | 270 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 6 |  |  | 6 |  | 32 | use vars qw($VERSION); | 
|  | 6 |  |  |  |  | 10 |  | 
|  | 6 |  |  |  |  | 452 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | $VERSION = '0.01'; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | BEGIN { | 
| 17 | 6 |  |  | 6 |  | 14 | for (qw(compress_function | 
| 18 |  |  |  |  |  |  | uncompress_function | 
| 19 |  |  |  |  |  |  | filename)) { | 
| 20 | 18 |  |  |  |  | 51 | attribute_builder( $_ ); | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | sub new { | 
| 25 | 4 |  |  | 4 | 1 | 370 | my $class = shift; | 
| 26 | 4 |  |  |  |  | 11 | my $p = shift; | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 4 |  |  |  |  | 16 | my $self = bless {}, $class; | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 4 |  |  |  |  | 15 | for my $param (qw(compress_function | 
| 31 |  |  |  |  |  |  | uncompress_function | 
| 32 |  |  |  |  |  |  | filename | 
| 33 |  |  |  |  |  |  | handle)) { | 
| 34 | 16 | 100 |  |  |  | 76 | next unless exists $p->{$param}; | 
| 35 | 7 |  |  |  |  | 39 | $self->{$param} = delete $p->{$param}; | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 4 | 100 |  |  |  | 21 | if (%$p) { | 
| 39 | 1 |  |  |  |  | 193 | confess "Invalid parameters " . join(', ', sort keys %$p) | 
| 40 |  |  |  |  |  |  | . " to $class->new"; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 3 | 50 | 33 |  |  | 21 | unless ($self->{'filename'} or $self->{'handle'}) { | 
| 44 | 0 |  |  |  |  | 0 | confess "You must provide either a filename or filehandle to " | 
| 45 |  |  |  |  |  |  | . "$class->new"; | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | # Be sure to kick off the file open if necessary | 
| 49 | 3 |  |  |  |  | 12 | $self->handle; | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 3 |  |  |  |  | 17 | return $self; | 
| 52 |  |  |  |  |  |  | } | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | sub handle { | 
| 55 | 11 |  |  | 11 | 1 | 25 | my $self = shift; | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 11 | 100 |  |  |  | 33 | if (@_) { | 
| 58 | 1 |  |  |  |  | 3 | $self->{'handle'} = shift; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 11 | 100 |  |  |  | 31 | unless (exists $self->{'handle'}) { | 
| 62 | 3 |  |  |  |  | 153 | $self->{'handle'} = IO::File->new( $self->filename, 'r' ); | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 11 |  |  |  |  | 499 | return $self->{'handle'}; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | sub reader { | 
| 69 | 2 |  |  | 2 | 1 | 10 | my $self = shift; | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 2 |  |  |  |  | 4 | my $class = "${\ref $self}::Reader"; | 
|  | 2 |  |  |  |  | 14 |  | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 2 |  |  |  |  | 15 | return $class->new( { uncompress_function => $self->{'uncompress_function'}, | 
| 74 |  |  |  |  |  |  | handle => $self->handle } ); | 
| 75 |  |  |  |  |  |  | } | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | sub writer { | 
| 78 | 1 |  |  | 1 | 1 | 377 | my $self = shift; | 
| 79 | 1 |  |  |  |  | 3 | my $class = "${\ref $self}::Writer"; | 
|  | 1 |  |  |  |  | 3 |  | 
| 80 |  |  |  |  |  |  |  | 
| 81 | 1 |  |  |  |  | 7 | return $class->new( { compress_function => $self->{'compress_function'}, | 
| 82 |  |  |  |  |  |  | handle => $self->handle } ); | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | 1; | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | __END__ |