File Coverage

blib/lib/Hubot/Scripts/storable.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 2 0.0
condition 0 2 0.0
subroutine 3 5 60.0
pod 0 1 0.0
total 12 26 46.1


line stmt bran cond sub pod time code
1             package Hubot::Scripts::storable;
2             $Hubot::Scripts::storable::VERSION = '0.1.9';
3 1     1   1492 use strict;
  1         3  
  1         37  
4 1     1   6 use warnings;
  1         2  
  1         30  
5 1     1   2975 use Storable;
  1         3832  
  1         204  
6              
7             sub load {
8 0     0 0   my ( $class, $robot ) = @_;
9 0   0       my $store = $ENV{HUBOT_STORABLE_PATH} || './hubot.dat';
10              
11 0 0         my $data = -f $store ? retrieve($store) : {};
12 0           $robot->brain->mergeData($data);
13             $robot->brain->on(
14             'save',
15             sub {
16 0     0     my ( $e, $data ) = @_;
17 0           store $data, $store;
18             }
19 0           );
20             }
21              
22             1;
23              
24             =head1 NAME
25              
26             Hubot::Scripts::storable
27              
28             =head1 VERSION
29              
30             version 0.1.9
31              
32             =head1 SYNOPSIS
33              
34             storable: THIS IS NOT COMMAND
35             storable: retrieve robot's brain at boot up time and save it at shutdown time
36              
37             =head1 CONFIGURATION
38              
39             =over
40              
41             =item HUBOT_STORABLE_PATH
42              
43             F<./hubot.dat> is default to use.
44              
45             =back
46              
47             =head1 SEE ALSO
48              
49             L<Storable>
50              
51             =head1 AUTHOR
52              
53             Hyungsuk Hong <hshong@perl.kr>
54              
55             =cut