| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Gzip::Zopfli; | 
| 2 | 2 |  |  | 2 |  | 147799 | use warnings; | 
|  | 2 |  |  |  |  | 13 |  | 
|  | 2 |  |  |  |  | 67 |  | 
| 3 | 2 |  |  | 2 |  | 11 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 37 |  | 
| 4 | 2 |  |  | 2 |  | 10 | use Carp; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 141 |  | 
| 5 | 2 |  |  | 2 |  | 13 | use utf8; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 11 |  | 
| 6 |  |  |  |  |  |  | require Exporter; | 
| 7 |  |  |  |  |  |  | our @ISA = qw(Exporter); | 
| 8 |  |  |  |  |  |  | our @EXPORT_OK = qw/zopfli_compress zopfli_compress_file/; | 
| 9 |  |  |  |  |  |  | our %EXPORT_TAGS = ( | 
| 10 |  |  |  |  |  |  | all => \@EXPORT_OK, | 
| 11 |  |  |  |  |  |  | ); | 
| 12 |  |  |  |  |  |  | our $VERSION = '0.01'; | 
| 13 |  |  |  |  |  |  | require XSLoader; | 
| 14 |  |  |  |  |  |  | XSLoader::load ('Gzip::Zopfli', $VERSION); | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 2 |  |  | 2 |  | 1292 | use File::Slurper qw!read_binary write_binary!; | 
|  | 2 |  |  |  |  | 28741 |  | 
|  | 2 |  |  |  |  | 580 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub get_from | 
| 19 |  |  |  |  |  |  | { | 
| 20 | 0 |  |  | 0 | 0 |  | my (%options) = @_; | 
| 21 | 0 |  |  |  |  |  | my $from; | 
| 22 | 0 | 0 |  |  |  |  | if ($options{in}) { | 
|  |  | 0 |  |  |  |  |  | 
| 23 | 0 |  |  |  |  |  | $from = read_binary ($options{in}); | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  | elsif ($options{from}) { | 
| 26 | 0 |  |  |  |  |  | $from = $options{from}; | 
| 27 |  |  |  |  |  |  | } | 
| 28 | 0 | 0 |  |  |  |  | if (! $from) { | 
| 29 | 0 |  |  |  |  |  | carp "Specify one of from => scalar or in => file"; | 
| 30 |  |  |  |  |  |  | } | 
| 31 | 0 |  |  |  |  |  | return $from; | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | sub make_out | 
| 35 |  |  |  |  |  |  | { | 
| 36 | 0 |  |  | 0 | 0 |  | my ($out, %options) = @_; | 
| 37 | 0 |  |  |  |  |  | my $outfile = $options{out}; | 
| 38 | 0 | 0 |  |  |  |  | if ($outfile) { | 
| 39 | 0 |  |  |  |  |  | write_binary ($outfile, $out); | 
| 40 |  |  |  |  |  |  | } | 
| 41 | 0 |  |  |  |  |  | return $out; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | sub zopfli_compress_file | 
| 45 |  |  |  |  |  |  | { | 
| 46 | 0 |  |  | 0 | 1 |  | my ($o, %options) = @_; | 
| 47 | 0 |  |  |  |  |  | my $from = get_from (%options); | 
| 48 | 0 | 0 |  |  |  |  | if (! $from) { | 
| 49 | 0 |  |  |  |  |  | return undef; | 
| 50 |  |  |  |  |  |  | } | 
| 51 | 0 |  |  |  |  |  | my $out = ZopfliCompress ($from, no_warn => 1, %options); | 
| 52 | 0 |  |  |  |  |  | return make_out ($out, %options); | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | 1; |