File Coverage

blib/lib/AI/Categorizer/Storable.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 30 33 90.9


line stmt bran cond sub pod time code
1             package AI::Categorizer::Storable;
2              
3 11     11   49 use strict;
  11         19  
  11         370  
4 11     11   10503 use Storable;
  11         33964  
  11         722  
5 11     11   73 use File::Spec ();
  11         18  
  11         280  
6 11     11   50 use File::Path ();
  11         18  
  11         1910  
7              
8             sub save_state {
9 5     5 1 768 my ($self, $path) = @_;
10 5 50       199 if (-e $path) {
11 5 50       3478 File::Path::rmtree($path) or die "Couldn't overwrite $path: $!";
12             }
13 5 50       384 mkdir($path, 0777) or die "Can't create $path: $!";
14 5         76 Storable::nstore($self, File::Spec->catfile($path, 'self'));
15             }
16              
17             sub restore_state {
18 5     5 1 2507 my ($package, $path) = @_;
19 5         189 return Storable::retrieve(File::Spec->catfile($path, 'self'));
20             }
21              
22             1;
23             __END__