From: Alexandre Mestiashvili Date: Wed, 24 Jan 2018 10:57:36 +0000 (+0100) Subject: New upstream version 4.005+ds X-Git-Tag: archive/raspbian/4.017+ds-1+rpi1~1^2~3^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=172ec6da76993862fee52f252a34cc37ddb40c57;p=libsereal-encoder-perl.git New upstream version 4.005+ds --- diff --git a/Changes b/Changes index edcbc1d..e73a6bd 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,9 @@ Revision history for Perl extension Sereal-Encoder * of the decoder before upgrading to version 4 of the * * encoder! * **************************************************************** +4.005 Tues Jan 23, 2018 + * Document encode_to_file() + 4.004 Sun Nov 12 * Fix build issues from C++ style comments * Fixup build_requires diff --git a/META.json b/META.json index 807573a..348e2a0 100644 --- a/META.json +++ b/META.json @@ -62,6 +62,6 @@ "url" : "git://github.com/Sereal/Sereal.git" } }, - "version" : "4.004", + "version" : "4.005", "x_serialization_backend" : "JSON::PP version 2.27400" } diff --git a/META.yml b/META.yml index 47c636f..b6a2d38 100644 --- a/META.yml +++ b/META.yml @@ -34,5 +34,5 @@ requires: resources: bugtracker: https://github.com/Sereal/Sereal/issues repository: git://github.com/Sereal/Sereal.git -version: '4.004' +version: '4.005' x_serialization_backend: 'CPAN::Meta::YAML version 0.011' diff --git a/lib/Sereal/Encoder.pm b/lib/Sereal/Encoder.pm index 3d4aed7..cafc9b2 100644 --- a/lib/Sereal/Encoder.pm +++ b/lib/Sereal/Encoder.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use XSLoader; -our $VERSION = '4.004'; # Don't forget to update the TestCompat set for testing against installed decoders! +our $VERSION = '4.005'; # Don't forget to update the TestCompat set for testing against installed decoders! our $XS_VERSION = $VERSION; $VERSION= eval $VERSION; # not for public consumption, just for testing. @@ -90,6 +90,7 @@ XSLoader::load('Sereal::Encoder', $XS_VERSION); sub encode_to_file { my ($self, $file, $struct, $append)= @_; + $self= $self->new() unless ref $self; my $mode= $append ? ">>" : ">"; open my $fh, $mode, $file or die "Failed to open '$file' for " . ($append ? "append" : "write") . ": $!"; @@ -453,6 +454,16 @@ A header is intended for embedding small amounts of meta data, such as routing information, in a document that allows users to avoid deserializing main body needlessly. +=head2 encode_to_file + + Sereal::Decoder->encode_to_file($file,$data,$append); + $encoder->encode_to_file($file,$data,$append); + +Encode the data specified and write it the named file. +If $append is true then the written data is appended to any +existing data, otherwise any existing data will be overwritten. +Dies if any errors occur during writing the encoded data. + =head1 EXPORTABLE FUNCTIONS =head2 sereal_encode_with_object diff --git a/lib/Sereal/Encoder/Constants.pm b/lib/Sereal/Encoder/Constants.pm index 0d6bae3..ac9ff2e 100644 --- a/lib/Sereal/Encoder/Constants.pm +++ b/lib/Sereal/Encoder/Constants.pm @@ -4,7 +4,7 @@ use warnings; require Exporter; our @ISA= qw(Exporter); -our $VERSION = '4.004'; # Don't forget to update the TestCompat set for testing against installed encoders! +our $VERSION = '4.005'; # Don't forget to update the TestCompat set for testing against installed encoders! our (@EXPORT_OK, %DEFINE, %TAG_INFO_HASH, @TAG_INFO_ARRAY); diff --git a/t/lib/Sereal/TestSet.pm b/t/lib/Sereal/TestSet.pm index 54b9563..5392006 100644 --- a/t/lib/Sereal/TestSet.pm +++ b/t/lib/Sereal/TestSet.pm @@ -632,34 +632,35 @@ sub setup_tests { sub have_encoder_and_decoder { my ($min_v)= @_; # $Class is the already-loaded class, so the one we're testing - my $need = $Class =~ /Encoder/ ? "Decoder" : "Encoder"; - my $need_class = "Sereal::$need"; - - eval "use $Class; 1" - or do { - note("Could not locate $Class for testing" . ($@ ? " (Exception: $@)" : "")); - return(); - }; + my @need = $Class =~ /Encoder/ ? ("Decoder") : + $Class =~ /Decoder/ ? ("Encoder") : + ("Encoder", "Decoder"); + my @need_class = ($Class, map { "Sereal::$_" } @need); + + foreach my $class (@need_class) { + eval "use $class; 1" + or do { + note("Could not locate $class for testing" . ($@ ? " (Exception: $@)" : "")); + return(); + }; + my $cmp_v= $class->VERSION; + + if ($min_v and $cmp_v < $min_v) { + diag("Could not load correct version of $class for testing " + ."(got: $cmp_v, needed at least $min_v)"); + return; + } - eval "use $need_class; 1" - or do { - note("Could not locate $need_class for testing" . ($@ ? " (Exception: $@)" : "")); - return(); - }; - my $cmp_v = $need_class->VERSION; - if ($min_v and $cmp_v < $min_v) { - diag("Could not load correct version of $need_class for testing " - ."(got: $cmp_v, needed at least $min_v)"); - return; - } - $cmp_v =~ s/_//; - $cmp_v = sprintf("%.2f", int($cmp_v*100)/100); - my %compat_versions = map {$_ => 1} $Class->_test_compat(); - if (not defined $cmp_v or not exists $compat_versions{$cmp_v}) { - diag("Could not load correct version of $need_class for testing " - ."(got: $cmp_v, needed any of ".join(", ", keys %compat_versions).")"); - return(); + $cmp_v =~ s/_//; + $cmp_v = sprintf("%.2f", int($cmp_v*100)/100); + my %compat_versions = map {$_ => 1} $Class->_test_compat(); + if (not defined $cmp_v or not exists $compat_versions{$cmp_v}) { + diag("Could not load correct version of $class for testing " + ."(got: $cmp_v, needed any of ".join(", ", keys %compat_versions).")"); + return(); + } } + return 1; }