New upstream version 4.005+ds
authorAlexandre Mestiashvili <alex@biotec.tu-dresden.de>
Wed, 24 Jan 2018 10:57:36 +0000 (11:57 +0100)
committerAlexandre Mestiashvili <alex@biotec.tu-dresden.de>
Wed, 24 Jan 2018 10:57:36 +0000 (11:57 +0100)
Changes
META.json
META.yml
lib/Sereal/Encoder.pm
lib/Sereal/Encoder/Constants.pm
t/lib/Sereal/TestSet.pm

diff --git a/Changes b/Changes
index edcbc1ded873d9d0776369ba1e3416b671e70e6c..e73a6bd8b61c72a3387f08da156d27a811945ea6 100644 (file)
--- 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
index 807573a352dffbc2901cbcce21b3451da63f17bb..348e2a0e36cd5fb7ccd472dca4ad4e7f3f9f2e29 100644 (file)
--- 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"
 }
index 47c636f2b1752697b59718b7cf9244b08d7a991d..b6a2d3809545e90f4afc5ecb33b1911a797b0d4b 100644 (file)
--- 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'
index 3d4aed7ddf51b5598b615d10383514c9b2531a53..cafc9b22e8c6f46135084a67e28109b73c8cb998 100644 (file)
@@ -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
index 0d6bae3d5c69817fca1795c8898b0986ad1a3d4c..ac9ff2e992c2ba483f8ef4c04798c3245a80c853 100644 (file)
@@ -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);
 
index 54b956340fbcda010eb78d7450761ee2be1406d4..5392006e5f7e140bb54da449b5c552ed52439b11 100644 (file)
@@ -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;
 }