MIN_PERL_VERSION => '5.14.0',
LICENSE => 'perl',
SIGN => 1,
- PREREQ_PM => {},
- BUILD_REQUIRES => {
- qw/File::Slurp 0/,
+ EXE_FILES => [ 'bin/bro-perl' ],
+ PREREQ_PM => {
+ 'File::Slurp' => '9999.19',
+ 'Getopt::Long' => '2.45',
},
+ BUILD_REQUIRES => {},
INC => '-Ibrotli',
MYEXTLIB => 'brotli/libbrotli$(LIB_EXT)',
clean => { FILES => 'brotli/libbrotli$(LIB_EXT)' },
This module requires these other modules and libraries:
-* File::Slurp (only used for testing)
+* File::Slurp
+* Getopt::Long
Additionally, it requires a C compiler.
--- /dev/null
+#!perl
+#
+
+use warnings;
+use strict;
+use 5.014;
+
+use File::Slurp;
+use Getopt::Long;
+
+use IO::Compress::Brotli;
+use IO::Uncompress::Brotli;
+
+GetOptions(
+ 'c|custom-dictionary=s' => \(my $DICTIONARY),
+ 'd|decompress' => \(my $DECOMPRESS),
+ 'h|help' => \(my $HELP),
+ 'i|input=s' => \(my $INPUT),
+ 'o|output=s' => \(my $OUTPUT),
+ 'q|quality=i' => \(my $QUALITY = 11),
+ 'r|repeat=i' => \(my $REPEAT),
+ 's|stream=i' => \(my $STREAM),
+ 'v|verbose' => \(my $VERBOSE),
+ 'w|window=i' => \(my $WINDOW = 22),
+);
+
+if( $HELP ) {
+ say "Usage: $0 [--force] [--quality n] [--decompress] [--input filename] [--output filename]".
+ " [--repeat iters] [--verbose] [--window n] [--custom-dictionary filename] [--stream size]";
+ exit 1;
+}
+
+my ($ifh, $ofh) = (\*STDIN, \*STDOUT);
+
+if( $INPUT ) {
+ open $ifh, "<", $INPUT
+ or die "Cannot open input file $INPUT.\n";
+}
+binmode $ifh;
+
+if( $OUTPUT ) {
+ open $ofh, ">", $OUTPUT
+ or die "Cannot open output file $OUTPUT.\n";
+}
+binmode $ofh;
+
+if( $DECOMPRESS ) {
+ if( $STREAM ) {
+ my $brotli = IO::Uncompress::Brotli->create();
+ while( read $ifh, (my $buf), $STREAM ) {
+ print $ofh $brotli->decompress($buf);
+ }
+ }
+ else {
+ my $encoded = read_file( $ifh );
+ my $decoded = unbro( $encoded );
+ write_file( $ofh, $decoded );
+ }
+}
+else {
+ if( $STREAM ) {
+ my $brotli = IO::Compress::Brotli->create();
+ $brotli->quality( $QUALITY );
+ $brotli->window( $WINDOW );
+ while( read $ifh, (my $buf), $STREAM ) {
+ print $ofh $brotli->compress($buf);
+ }
+ }
+ else {
+ my $decoded = read_file( $ifh );
+ my $encoded = bro( $decoded, $QUALITY, $WINDOW );
+ write_file( $ofh, $encoded );
+ }
+}
+
--- /dev/null
+#!/usr/bin/perl
+use v5.14;
+use warnings;
+
+use Test::More tests => 2;
+
+BEGIN {
+ use_ok('IO::Compress::Brotli');
+ use_ok('IO::Uncompress::Brotli');
+}
--- /dev/null
+#!/usr/bin/perl
+use v5.14;
+use warnings;
+
+use Test::More tests => 80;
+use File::Slurp;
+
+use IO::Uncompress::Brotli;
+
+my $todo_re = qr/empty\.compressed\.(?:1[7-9]|2)|x\.compressed\.0[12]/;
+
+for my $test (<brotli/tests/testdata/*.compressed*>) {
+ my ($expected) = $test =~ s/\.compressed.*//r;
+ $expected = read_file $expected;
+
+ if($test !~ $todo_re) {
+ my $decoded = unbro (scalar read_file $test);
+ is $decoded, $expected, "$test";
+ }
+
+ open FH, '<', $test;
+ my $unbro = IO::Uncompress::Brotli->create;
+ my ($buf, $out);
+ until (eof FH) {
+ read FH, $buf, 100;
+ $out .= $unbro->decompress($buf);
+ }
+ is $out, $expected, "$test (streaming)";
+}
--- /dev/null
+#!/usr/bin/perl
+use v5.14;
+use warnings;
+
+use Test::More tests => 114;
+use File::Slurp;
+
+use IO::Compress::Brotli;
+use IO::Uncompress::Brotli;
+
+for my $test (<brotli/tests/testdata/*.compressed>) {
+ my ($source) = $test =~ s/\.compressed$//r;
+ $source = read_file $source;
+
+ for my $quality (9,11) {
+ my $encoded = bro($source, $quality);
+ my $decoded = unbro($encoded);
+
+ is $decoded, $source, "$test - quality $quality";
+ }
+
+ for my $quality (1,5,9,11) {
+ my $enc = IO::Compress::Brotli->create;
+ $enc->quality($quality);
+ my $encoded = $enc->compress($source, 1);
+ $encoded .= $enc->finish();
+
+ my $dec = IO::Uncompress::Brotli->create;
+ my $decoded = $dec->decompress($encoded);
+
+ is $decoded, $source, "$test - streaming / quality $quality";
+ }
+}
+++ /dev/null
-# Before 'make install' is performed this script should be runnable with
-# 'make test'. After 'make install' it should work as 'perl IO-Compress-Brotli.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-BEGIN { use_ok('IO::Compress::Brotli') };
-
-#########################
-
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
-
+++ /dev/null
-#!/usr/bin/perl
-use v5.14;
-use warnings;
-
-use Test::More tests => 81;
-use File::Slurp;
-BEGIN{ use_ok('IO::Uncompress::Brotli'); }
-
-my $todo_re = qr/empty\.compressed\.(?:1[7-9]|2)|x\.compressed\.0[12]/;
-
-for my $test (<brotli/tests/testdata/*.compressed*>) {
- my ($expected) = $test =~ s/\.compressed.*//r;
- $expected = read_file $expected;
-
- if($test !~ $todo_re) {
- my $decoded = unbro (scalar read_file $test);
- is $decoded, $expected, "$test";
- }
-
- open FH, '<', $test;
- my $unbro = IO::Uncompress::Brotli->create;
- my ($buf, $out);
- until (eof FH) {
- read FH, $buf, 100;
- $out .= $unbro->decompress($buf);
- }
- is $out, $expected, "$test (streaming)";
-}