File Coverage

blib/lib/Rex/Report.pm
Criterion Covered Total %
statement 21 22 95.4
branch 3 4 75.0
condition 7 8 87.5
subroutine 6 6 100.0
pod 0 2 0.0
total 37 42 88.1


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Report;
6              
7 133     133   1506 use v5.12.5;
  133         436  
8 133     107   818 use warnings;
  107         231  
  107         2626  
9 107     102   587 use Data::Dumper;
  102         176  
  102         21024  
10              
11             our $VERSION = '1.14.3'; # VERSION
12              
13             my $report;
14              
15             sub create {
16 104     104 0 4179 my ( $class, $type ) = @_;
17 104 100 100     1066 if ( $report && $type && ref($report) =~ m/::\Q$type\E$/ ) { return $report; }
  1   66     25  
18              
19 103   100     1145 $type ||= "Base";
20              
21 103         432 my $c = "Rex::Report::$type";
22 103     67   7609 eval "use $c";
  67         863  
  67         272  
  67         1058  
23              
24 103 50       1809 if ($@) {
25 0         0 die("No reporting class $type found.");
26             }
27              
28 103         601 $report = $c->new;
29 103         1542 return $report;
30             }
31              
32 1     1 0 33 sub destroy { $report = undef; }
33              
34             1;