package Devel::QuickCover;

use strict;
use warnings;
use Carp 'croak';
use XSLoader;

our $VERSION = '0.900010';

XSLoader::load( 'Devel::QuickCover', $VERSION );

    noatexit         => 0,      # Don't register an atexit handler to dump and cleanup
    nostart          => 0,      # Don't start gathering coverage information on import
    nodump           => 0,      # Don't dump the coverage report at the END of the program
    output_directory => '/tmp', # Write report to that directory
    metadata         => {}    , # Additional context information
our %CONFIG;

sub import {
    my ($class, @opts) = @_;

    croak('Invalid argument to import, it takes key-value pairs. FOO => BAR')
        if 1 == @opts % 2;
    my %options = @opts;

    for (keys %options) {
        if (exists $DEFAULT_CONFIG{$_}) {
            $CONFIG{$_} = delete $options{$_};

    if (keys %options > 0) {
        croak('Invalid import option(s): ' . join ',', keys %options);

    if (!$CONFIG{'nostart'}) {

sub set_output_directory {
    my ($dir) = @_;
    return unless $dir;

    $CONFIG{output_directory} = $dir;

sub set_metadata {
    my ($data) = @_;
    return unless $data;

    $CONFIG{metadata} = $data;





=encoding utf8

=head1 NAME

Devel::QuickCover - Quick & dirty code coverage for Perl

=head1 VERSION

Version 0.900000


    use Devel::QuickCover;
    my $x = 1;
    my $z = 1 + $x;


The following program sets up the coverage hook on C<use> and dumps
a report (to C</tmp> by default) at the end of execution.

    use Devel::QuickCover;
    my $x = 1;
    my $z = 1 + $x;

The following program sets up the coverage hook on C<start()> and
dumps a report to C<some_dir> on C<end()>, at which point
the coverage hook gets uninstalled. So in this case, we only get
coverage information for C<bar()>. We also get the specified metadata
in the coverage information. We also ask not to register an atexit()
handler to dump cover data / cleanup; it will be done from C<end()>.

    use Devel::QuickCover (
      nostart => 1,
      nodump => 1,
      noatexit => 1,
      output_directory => "some_dir/",
      metadata => { git_tag = "deadbeef" });


For now, we support calling C<start()> only once.

When you call C<end()>, you can optionally pass a C<nodump>
boolean argument, to indicate whether you wish to skip generating
the cover files.

=head1 Use with Devel::Cover

Devel::QuickCover is distributed with the scripts and that can be used to convert its output into a format that
Devel::Cover understands. Once you have generated your coverage reports,
aggregate them by running

and convert them into the Devel::Cover database format by running

Then you can view the reports with the standard Devel::Cover tools.

=head1 AUTHORS

=over 4

=item * Gonzalo Diethelm C<< gonzus AT cpan DOT org >>

=item * Andreas Gu├░mundsson C<< andreasg AT nasarde DOT org >>

=item * Andrei Vereha C<< avereha AT cpan DOT org >>

=item * Mattia Barbon


=head1 THANKS

=over 4

=item * p5pclub