| 1 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | package Data::Remember::YAML; | ||||||||||||||||||||
| 5 | { | ||||||||||||||||||||
| 6 | 5 | $Data::Remember::YAML::VERSION = '0.140490'; | |||||||||||||||||||
| 7 | } | ||||||||||||||||||||
| 8 | 5 | ▶ | use base qw/ Data::Remember::Memory /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | # ABSTRACT: a frozen memory brain plugin for Data::Remember | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 5 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 5 | ▶ | use YAML::Syck (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 5 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||
| 16 | 5 | my $class = shift; | |||||||||||||||||||
| 17 | 5 | my %args = @_; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | croak 'You must specify a "file" to load the data from.' | ||||||||||||||||||||
| 20 | 5 | ▶ | unless $args{file}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 5 | my $brain; | |||||||||||||||||||
| 23 | 5 | ▶ | if (-f $args{file}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 5 | $brain = YAML::Syck::LoadFile($args{file}); | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||
| 27 | 0 | carp qq{Empty brain, "$args{file}" is not a file.}; | |||||||||||||||||||
| 28 | 0 | $brain = {}; | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | bless { | ||||||||||||||||||||
| 32 | brain => $brain, | ||||||||||||||||||||
| 33 | file => $args{file}, | ||||||||||||||||||||
| 34 | 5 | }, $class; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 2 | ▶ | sub load { | ||||||||||||||||||
|
Subroutine
load: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 39 | 2 | my $self = shift; | |||||||||||||||||||
| 40 | 2 | ▶ | my $file = shift || $self->{file}; | ||||||||||||||||||
|
Condition66%2/3
shift() || $self->{'file'}
MC/DC0%0/2
shift() || $self->{'file'}
shift()
$self->{'file'}
Truth table66%2/3
A || B
A= shift()B= $self->{'file'}
| |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 2 | $self->{brain} = YAML::Syck::LoadFile($file); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 2 | ▶ | sub dump { | ||||||||||||||||||
|
Subroutine
dump: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 47 | 2 | my $self = shift; | |||||||||||||||||||
| 48 | 2 | ▶ | my $file = shift || $self->{file}; | ||||||||||||||||||
|
Condition66%2/3
shift() || $self->{'file'}
MC/DC0%0/2
shift() || $self->{'file'}
shift()
$self->{'file'}
Truth table66%2/3
A || B
A= shift()B= $self->{'file'}
| |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 2 | YAML::Syck::DumpFile($file, $self->{brain}); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 5 | 1; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||