Categorizer/Storable.pm

filter: Statementstmt 100% 20 / 20 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 94.1% 32 / 34 CC 4 SCAR 8.7
CC
4
Cov
92%
save_state
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« Categorizer/Learner/Guesser.pm ↑ Summary Categorizer/Category.pm »
1 package AI::Categorizer::Storable;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶sub save_state {
Subroutine save_state: called CC=4 SCAR=14.1
Pod documented
9 5 my ($self, $path) = @_;
10 5 ▶ if (-e $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $path) 4 1 5
11 4 ▶ File::Path::rmtree($path) or die "Couldn't overwrite $path: $!";
Branch: 1 branch
BranchTrueFalseTotal
File::Path::rmtree($path) or die "Couldn't overwrite ${path}: $!" 4 0 4
12 }
13 5 ▶ mkdir($path, 0777) or die "Can't create $path: $!";
Branch: 1 branch
BranchTrueFalseTotal
mkdir $path, 511 or die "Can't create ${path}: $!" 5 0 5
14 5 Storable::nstore($self, File::Spec->catfile($path, 'self'));
15 }
16  
17 5 ▶sub restore_state {
Subroutine restore_state: called CC=1 SCAR=0.0
Pod documented
18 5 my ($package, $path) = @_;
19 5 return Storable::retrieve(File::Spec->catfile($path, 'self'));
20 }
21  
22 11 1;
23 __END__
« Categorizer/Learner/Guesser.pm ↑ Summary Categorizer/Category.pm »