File Coverage

blib/lib/Filter/gunzip.pm
Criterion Covered Total %
statement 14 16 87.5
branch 1 2 50.0
condition 1 3 33.3
subroutine 5 5 100.0
pod n/a
total 21 26 80.7


line stmt bran cond sub pod time code
1             # Copyright 2010, 2011, 2013, 2014, 2019 Kevin Ryde
2              
3             # This file is part of Filter-gunzip.
4             #
5             # Filter-gunzip is free software; you can redistribute it and/or modify it
6             # under the terms of the GNU General Public License as published by the Free
7             # Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Filter-gunzip is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Filter-gunzip. If not, see .
17              
18             package Filter::gunzip;
19 2     2   9590 use strict;
  2         9  
  2         44  
20 2     2   9 use Carp;
  2         2  
  2         78  
21 2     2   9 use DynaLoader;
  2         3  
  2         67  
22              
23 2     2   16 use vars qw($VERSION @ISA);
  2         3  
  2         321  
24             $VERSION = 8;
25             @ISA = ('DynaLoader');
26              
27             # uncomment this to run the ### lines
28             # use Smart::Comments;
29              
30             my $use_xs = 1;
31             if (! eval { __PACKAGE__->bootstrap($VERSION) }) {
32             ### filter gunzip no XS: $@
33             $use_xs = 0;
34             } elsif (! eval { require PerlIO::gzip; 1 }) {
35             ### filter gunzip have XS but no have PerlIO gzip: $@
36             $use_xs = 0;
37             }
38              
39             sub import {
40 1     1   6 my ($class) = @_;
41 1 50 33     92 if ($use_xs && _filter_by_layer()) {
42             ### applied gzip layer ...
43             } else {
44             ### use Filter gunzip Filter ...
45 0           require Filter::gunzip::Filter;
46 0           Filter::gunzip::Filter->import;
47             }
48             }
49              
50             1;
51             __END__