File Coverage

blib/lib/Devel/QuickCover.pm
Criterion Covered Total %
statement 23 30 76.6
branch 5 12 41.6
condition n/a
subroutine 6 8 75.0
pod 0 2 0.0
total 34 52 65.3


line stmt bran cond sub pod time code
1             package Devel::QuickCover;
2              
3 2     2   173597 use strict;
  2         7  
  2         49  
4 2     2   8 use warnings;
  2         4  
  2         40  
5 2     2   14 use Carp 'croak';
  2         3  
  2         84  
6 2     2   9 use XSLoader;
  2         3  
  2         629  
7              
8             our $VERSION = '0.900013';
9              
10             XSLoader::load( 'Devel::QuickCover', $VERSION );
11              
12             my %DEFAULT_CONFIG = (
13             noatexit => 0, # Don't register an atexit handler to dump and cleanup
14             nostart => 0, # Don't start gathering coverage information on import
15             nodump => 0, # Don't dump the coverage report at the END of the program
16             output_directory => '/tmp', # Write report to that directory
17             metadata => {} , # Additional context information
18             );
19             our %CONFIG;
20              
21             sub import {
22 2     2   15 my ($class, @opts) = @_;
23              
24 2 50       8 croak('Invalid argument to import, it takes key-value pairs. FOO => BAR')
25             if 1 == @opts % 2;
26 2         6 my %options = @opts;
27              
28 2         7 %CONFIG = %DEFAULT_CONFIG;
29 2         6 for (keys %options) {
30 3 50       8 if (exists $DEFAULT_CONFIG{$_}) {
31 3         6 $CONFIG{$_} = delete $options{$_};
32             }
33             }
34              
35 2 50       7 if (keys %options > 0) {
36 0         0 croak('Invalid import option(s): ' . join ',', keys %options);
37             }
38              
39 2 100       1336 if (!$CONFIG{'nostart'}) {
40 1         21 Devel::QuickCover::start();
41             }
42             }
43              
44             sub set_output_directory {
45 0     0 0   my ($dir) = @_;
46 0 0         return unless $dir;
47              
48 0           $CONFIG{output_directory} = $dir;
49             }
50              
51             sub set_metadata {
52 0     0 0   my ($data) = @_;
53 0 0         return unless $data;
54              
55 0           $CONFIG{metadata} = $data;
56             }
57              
58             END {
59 2     2   4057 Devel::QuickCover::end($CONFIG{'nodump'});
60             }
61              
62             1;
63              
64             __END__