File Coverage

blib/lib/BioX/Workflow/Debug.pm
Criterion Covered Total %
statement 8 12 66.6
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 13 18 72.2


line stmt bran cond sub pod time code
1             package BioX::Workflow::Debug;
2              
3 2     2   1269 use Storable qw(dclone);
  2         3  
  2         115  
4              
5 2     2   8 use Moose::Role;
  2         3  
  2         16  
6              
7             =head1 BioX::Workflow::Debug
8              
9             Options for debugging. Stick your whole environment in memory, and figure out what went wrong.
10              
11             =head2 Variables
12              
13             =head3 save_object_env
14              
15             Save object env. This will save all the variables. Useful for debugging, but gets unweildly for larger workflows.
16              
17             =cut
18              
19             has 'save_object_env' => (
20             is => 'rw',
21             isa => 'Bool',
22             default => 0,
23             predicate => 'has_save_object_env',
24             clearer => 'clear_save_object_env',
25             );
26              
27             =head2 _classes
28              
29             Saves a snapshot of the entire namespace for the initial environment, and each rule.
30              
31             =cut
32              
33             has '_classes' => (
34             traits => ['NoGetopt'],
35             is => 'rw',
36             isa => 'HashRef',
37             default => sub { return {} },
38             required => 0,
39             predicate => 'has_classes',
40             clearer => 'clear_classes',
41             );
42              
43             =head2 save_env
44              
45             At each rule save the env for debugging purposes.
46              
47             =cut
48              
49             sub save_env {
50 15     15 1 29 my $self = shift;
51              
52 15 50       408 return unless $self->save_object_env;
53              
54 0           $DB::single = 2;
55 0           $self->_classes->{ $self->key } = dclone($self);
56 0           return;
57 0           $DB::single = 2;
58             }
59              
60             1;