File Coverage

blib/lib/Compress/Zstd/CompressionDictionary.pm
Criterion Covered Total %
statement 17 17 100.0
branch 1 2 50.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 1 1 100.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Compress::Zstd::CompressionDictionary;
2 1     1   460 use 5.008001;
  1         3  
3 1     1   5 use strict;
  1         2  
  1         19  
4 1     1   4 use warnings;
  1         2  
  1         22  
5              
6 1     1   5 use Compress::Zstd ();
  1         2  
  1         126  
7              
8             sub new_from_file {
9 1     1 1 106 my ($class, $file, $level) = @_;
10 1 50       46 open my $fh, '<', $file or die $!;
11 1         7 local $/;
12 1         249 my $dict = <$fh>;
13 1         14 close $fh;
14 1   50     1375 $class->new($dict, $level || 1);
15             }
16              
17             1;
18             __END__
19              
20             =encoding utf-8
21              
22             =head1 NAME
23              
24             Compress::Zstd::CompressionDictionary - Zstd compression dictionary
25              
26             =head1 SYNOPSIS
27              
28             use Compress::Zstd::CompressionContext;
29             use Compress::Zstd::CompressionDictionary;
30              
31             my $cdict = Compress::Zstd::CompressionDictionary->new_from_file($filename, $level);
32             my $cctx = Compress::Zstd::CompressionContext->new;
33             my $dest = $cctx->compress_using_dict($src, $cdict);
34              
35             =head1 DESCRIPTION
36              
37             (Experimental) The Compress::Zstd::CompressionDictionary module provides Zstd compression dictionaries.
38              
39             =head1 METHODS
40              
41             =head2 Compress::Zstd::CompressionDictionary->new($dict) :Compress::Zstd::CompressionDictionary
42              
43             Create an instance of Compress::Zstd::CompressionDictionary.
44              
45             =head2 Compress::Zstd::CompressionDictionary->new_from_file($filename) :Compress::Zstd::CompressionDictionary
46              
47             Create an instance of Compress::Zstd::CompressionDictionary from file.
48              
49             =head1 SEE ALSO
50              
51             L<Compress::Zstd>
52              
53             =head1 LICENSE
54              
55             Copyright (c) 2016, Jiro Nishiguchi
56             All rights reserved.
57              
58             Redistribution and use in source and binary forms, with or without modification,
59             are permitted provided that the following conditions are met:
60              
61             1. Redistributions of source code must retain the above copyright notice, this
62             list of conditions and the following disclaimer.
63              
64             2. Redistributions in binary form must reproduce the above copyright notice,
65             this list of conditions and the following disclaimer in the documentation
66             and/or other materials provided with the distribution.
67              
68             THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
69             ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
70             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
71             DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
72             ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
73             (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74             LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
75             ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76             (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
77             SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78              
79             =head1 AUTHOR
80              
81             Jiro Nishiguchi E<lt>jiro@cpan.orgE<gt>
82              
83             Zstandard by Facebook, Inc.
84              
85             =cut