Commit 13bad323 authored by Roberto C. Sánchez's avatar Roberto C. Sánchez

* New upstream release.

parents 9e68a863 b2c83d9c
use Module::Build;
my $build = Module::Build->new
(
sign => 1,
module_name => 'Data::Serializer',
dist_author => 'Neil Neely (neil@neely.cx)',
license => 'perl',
......@@ -13,7 +14,7 @@ my $build = Module::Build->new
'Data::Dumper' => 2.08,
},
build_requires => {
'AutoSplit' => 0,
#'AutoSplit' => 0,
'IO::File' => 0,
'Test::More' => 0,
'File::Spec' => 0,
......@@ -30,6 +31,7 @@ my $build = Module::Build->new
'YAML::Syck' => 0,
'PHP::Serialization' => 0,
'JSON' => 0,
'JSON::XS' => 0,
'JSON::Syck' => 0,
'XML::Simple' => 0,
'XML::Dumper' => 0,
......@@ -37,7 +39,8 @@ my $build = Module::Build->new
'Compress::PPMd' => 0,
'MIME::Base64' => 0,
},
autosplit => 'lib/Data/Serializer.pm',
#autosplit => 'lib/Data/Serializer.pm',
);
$build->create_build_script;
Revision history for Perl extension Data::Serializer
0.44 Thu Dec 13 2008
- Added 'raw' flag to constructor, allows for more convenient
raw access to underlying serializers
- retrieve altered to read in full contents of file specified, this change could be disruptive
if you were using retrieve in a non-standard way, so be aware of it.
- store and retrieve when the raw flag is set will do what you would expect
and store and retrieve serialized data from files in their raw underlying
serializer format with no Data::Serializer markup included
- Removed last usage of Autoloader (decided it isn't worth the irritation of keeping it)
- Updated Data::Serializer::Cookbook to reference the raw flag and de-emphasis the use of raw_ methods.
Thanks to Charles Gowing <charles.gowing@novainfo.com> for noticing that retrieve with portable set to 0 was quite
broken. That led to revisiting the 'raw' concept and improving it. Now does work with portable set to 0 (using raw
set to a true value is likely a better choice however).
0.43 Wed Dec 19 2007
- Converted to utilizing Module::Build to support recommended options
- Added recommended module list
......
Changes
MANIFEST
MANIFEST.SKIP
README
INSTALL
#SIGNATURE
Build.PL
Makefile.PL
lib/Data/Serializer.pm
......@@ -20,6 +22,8 @@ lib/Data/Serializer/Cookbook.pm
lib/Data/Serializer/JSON.pm
lib/Data/Serializer/JSON/Syck.pm
t/ExtUtils/TBone.pm
t/00-01-Signature.t
t/00-02-Kwalitee.t
t/01-01-Data-Dumper.t
t/01-02-Data-Denter.t
t/01-03-Storable.t
......
^Makefile$
^blib/
^pm_to_blib
^blibdirs
^Build$
^_build/
^testout/
---
name: Data-Serializer
version: 0.43
author:
- Neil Neely (neil@neely.cx)
abstract: Modules that serialize data structures
license: perl
resources:
license: http://dev.perl.org/licenses/
requires:
AutoLoader: 0
Data::Dumper: 2.08
Digest::SHA: 0
Exporter: 0
IO::File: 0
build_requires:
AutoSplit: 0
File::Spec: 0
IO::File: 0
Test::More: 0
recommends:
Compress::PPMd: 0
Compress::Zlib: 0
Config::General: 0
Crypt::Blowfish: 0
Crypt::CBC: 0
Data::Denter: 0
Data::Taxi: 0
FreezeThaw: 0
JSON: 0
JSON::Syck: 0
MIME::Base64: 0
PHP::Serialization: 0
Storable: 0
XML::Dumper: 0
XML::Simple: 0
YAML: 0
YAML::Syck: 0
provides:
Data::Serializer:
file: lib/Data/Serializer.pm
version: 0.43
Data::Serializer::Config::General:
file: lib/Data/Serializer/Config/General.pm
version: 0.02
Data::Serializer::Cookbook:
file: lib/Data/Serializer/Cookbook.pm
version: 0.03
Data::Serializer::Data::Denter:
file: lib/Data/Serializer/Data/Denter.pm
version: 0.02
Data::Serializer::Data::Dumper:
file: lib/Data/Serializer/Data/Dumper.pm
version: 0.05
Data::Serializer::Data::Taxi:
file: lib/Data/Serializer/Data/Taxi.pm
version: 0.02
Data::Serializer::FreezeThaw:
file: lib/Data/Serializer/FreezeThaw.pm
version: 0.02
Data::Serializer::JSON:
file: lib/Data/Serializer/JSON.pm
version: 0.02
Data::Serializer::JSON::Syck:
file: lib/Data/Serializer/JSON/Syck.pm
version: 0.02
Data::Serializer::PHP::Serialization:
file: lib/Data/Serializer/PHP/Serialization.pm
version: 0.02
Data::Serializer::Storable:
file: lib/Data/Serializer/Storable.pm
version: 0.03
Data::Serializer::XML::Dumper:
file: lib/Data/Serializer/XML/Dumper.pm
version: 0.02
Data::Serializer::XML::Simple:
file: lib/Data/Serializer/XML/Simple.pm
version: 0.02
Data::Serializer::YAML:
file: lib/Data/Serializer/YAML.pm
version: 0.02
Data::Serializer::YAML::Syck:
file: lib/Data/Serializer/YAML/Syck.pm
version: 0.02
generated_by: Module::Build version 0.2808
--- #YAML:1.0
name: Data-Serializer
version: 0.44
abstract: ~
license: ~
generated_by: ExtUtils::MakeMaker version 6.36
distribution_type: module
requires:
AutoLoader: 0
AutoSplit: 0
Data::Dumper: 2.08
Digest::SHA: 0
Exporter: 0
File::Spec: 0
IO::File: 0
Test::More: 0
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
use Module::Build::Compat;
Module::Build::Compat->run_build_pl(args => \@ARGV);
Module::Build::Compat->write_makefile(build_class => 'Module::Build');
# Note: this file was auto-generated by Module::Build::Compat version 0.03
use ExtUtils::MakeMaker;
WriteMakefile
(
'NAME' => 'Data::Serializer',
'VERSION_FROM' => 'lib/Data/Serializer.pm',
'PREREQ_PM' => {
'AutoLoader' => '0',
'AutoSplit' => '0',
'Data::Dumper' => '2.08',
'Digest::SHA' => '0',
'Exporter' => '0',
'File::Spec' => '0',
'IO::File' => '0',
'Test::More' => '0'
},
'INSTALLDIRS' => 'site',
'EXE_FILES' => [],
'PL_FILES' => {}
)
;
......@@ -112,6 +112,12 @@ METHODS
Compresses serialized data. Default is not to use it. Will compress
if set to a true value $obj->compress(1);
raw - all calls to serializer and deserializer will automatically use
raw mode
Setting this to a true value will force serializer and deserializer
to work in raw mode (see raw_serializer and raw_deserializer). The
default is for this to be off.
serializer - change the serializer
Currently have 8 supported serializers: Storable, FreezeThaw,
Data::Denter, Config::General, YAML, PHP::Serialization,
......@@ -229,7 +235,7 @@ TODO
would be welcome.
COPYRIGHT AND LICENSE
Copyright (c) 2001-2007 Neil Neely. All rights reserved.
Copyright (c) 2001-2008 Neil Neely. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.2 or, at
......@@ -264,6 +270,7 @@ SEE ALSO
JSON(3)
JSON::Syck(3)
Compress::Zlib(3)
Compress::PPMd(3)
Digest(3)
Digest::SHA(3)
Crypt(3)
......
libdata-serializer-perl (0.44-1) unstable; urgency=low
* New upstream release.
-- Roberto C. Sanchez <roberto@debian.org> Sat, 15 Mar 2008 23:44:39 -0400
libdata-serializer-perl (0.43-4) unstable; urgency=low
* Delete /usr/lib/perl5 only if it exists (Closes: #467149)
......
......@@ -56,9 +56,12 @@ You want to read in data serialized outside of Data::Serializer
to process data serialized by XML::Dumper.
Solution
$serializer->serializer('XML::Dumper');
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper', raw => 1);
my $hash_ref = $serializer->raw_deserialize($xml_data);
my $hash_ref = $serializer->deserialize($xml_data);
Note: the raw_deserialize method can be used as well, but the above
approach is preferred.
You want to write serialized data in a form understood outside of Data::Serializer
You need to write a program that can write out data in a format other
......@@ -67,22 +70,25 @@ You want to write serialized data in a form understood outside of Data::Serializ
we will be exporting data using XML::Dumper format.
Solution
$serializer->serializer('XML::Dumper');
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper', raw => 1);
my $xml_data = $serializer->serialize($hash_ref);
my $xml_data = $serializer->raw_serialize($hash_ref);
Note: the raw_serialize method can be used as well, but the above
approach is preferred.
You want to convert data between two different serializers native formats
You have data serialized by php that you want to convert to xml for use
by other programs.
Solution
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper');
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper', raw => 1);
my $php_serializer = Data::Serializer->(serializer => 'PHP::Serialization');
my $php_serializer = Data::Serializer->(serializer => 'PHP::Serialization', raw => 1);
my $hash_ref = $php_serializer->raw_deserialize($php_data);
my $hash_ref = $php_serializer->deserialize($php_data);
my $xml_data = $xml_serializer->raw_serialize($hash_ref);
my $xml_data = $xml_serializer->serialize($hash_ref);
Keeping data persistent between executions of a program.
You have a program that you run every 10 minutes, it uses SNMP to pull
......@@ -110,7 +116,7 @@ AUTHOR
Neil Neely <neil@neely.cx>.
COPYRIGHT
Copyright (c) 2001-2007 Neil Neely. All rights reserved.
Copyright (c) 2001-2008 Neil Neely. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
......
......@@ -8,9 +8,10 @@ use Carp;
use IO::File;
require 5.004 ;
require Exporter;
require AutoLoader;
#require AutoLoader;
@ISA = qw(Exporter AutoLoader);
#@ISA = qw(Exporter AutoLoader);
@ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
......@@ -18,7 +19,7 @@ require AutoLoader;
@EXPORT = qw( );
@EXPORT_OK = qw( );
$VERSION = '0.43';
$VERSION = '0.44';
# Preloaded methods go here.
{
......@@ -32,6 +33,7 @@ $VERSION = '0.43';
secret => undef,
portable => '1',
compress => '0',
raw => '0',
options => {},
transient => '0',
serializer_token => '1',
......@@ -158,6 +160,15 @@ $VERSION = '0.43';
}
return $return;
}
sub raw {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{raw};
if (@_) {
$_internal{$id}->{raw} = (shift);
}
return $return;
}
sub serializer_token {
my $self = (shift);
my $id = $$self;
......@@ -192,10 +203,6 @@ $VERSION = '0.43';
#END of public functions, all following functions are for internal use only
# Autoload methods go after =cut, and are processed by the autosplit program.
1;
__END__
#Documentation follows
=head1 NAME
......@@ -358,6 +365,10 @@ Aids in the portability of serialized data.
Compresses serialized data. Default is not to use it. Will compress if set to a true value
$obj->compress(1);
=item B<raw> - all calls to serializer and deserializer will automatically use raw mode
Setting this to a true value will force serializer and deserializer to work in raw mode
(see raw_serializer and raw_deserializer). The default is for this to be off.
=item B<serializer> - change the serializer
......@@ -486,7 +497,7 @@ would be welcome.
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2001-2007 Neil Neely. All rights reserved.
Copyright (c) 2001-2008 Neil Neely. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.2 or,
......@@ -702,6 +713,10 @@ sub serialize {
my $self = (shift);
my ($serializer,$cipher,$digester,$encoding,$compressor) = ('','','','','');
if ($self->raw) {
return $self->raw_serialize(@_);
}
#we always serialize no matter what.
#define serializer for token
......@@ -762,15 +777,19 @@ sub retrieve {
my $self = (shift);
my $file_or_fh = (shift);
if (ref($file_or_fh)) {
#Read in whole file at once
#local $/;
#it is a file handle so read straight from it
my $input = <$file_or_fh>;
my $input = join('', <$file_or_fh>);
chomp($input);
return $self->deserialize($input);
#We didn't open the filehandle, so we shouldn't close it.
} else {
my $fh = new IO::File;
$fh->open($file_or_fh, O_RDONLY) || croak "Cannot read from $file_or_fh: $!";
my $input = <$fh>;
#Read in whole file at once
#local $/;
my $input = join('', <$fh>);
chomp($input);
$fh->close;
return $self->deserialize($input);
......@@ -820,6 +839,11 @@ sub raw_deserialize {
sub deserialize {
my $self = (shift);
if ($self->raw) {
return $self->raw_deserialize(@_);
}
my $value = (shift);
my $token = $self->_get_token($value);
my ($serializer,$cipher, $digester,$encoding, $compressor);
......@@ -855,3 +879,7 @@ sub deserialize {
return wantarray ? @return : $return[0];
}
1;
__END__
......@@ -5,7 +5,7 @@ use warnings;
use strict;
use vars ('$VERSION');
$VERSION = '0.03';
$VERSION = '0.04';
1;
......@@ -82,9 +82,11 @@ to be able to process data serialized by XML::Dumper.
=head2 Solution
$serializer->serializer('XML::Dumper');
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper', raw => 1);
my $hash_ref = $serializer->raw_deserialize($xml_data);
my $hash_ref = $serializer->deserialize($xml_data);
Note: the raw_deserialize method can be used as well, but the above approach is preferred.
=head1 You want to write serialized data in a form understood outside of Data::Serializer
......@@ -95,9 +97,11 @@ For our example we will be exporting data using XML::Dumper format.
=head2 Solution
$serializer->serializer('XML::Dumper');
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper', raw => 1);
my $xml_data = $serializer->serialize($hash_ref);
my $xml_data = $serializer->raw_serialize($hash_ref);
Note: the raw_serialize method can be used as well, but the above approach is preferred.
=head1 You want to convert data between two different serializers native formats
......@@ -106,13 +110,13 @@ programs.
=head2 Solution
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper');
my $xml_serializer = Data::Serializer->(serializer => 'XML::Dumper', raw => 1);
my $php_serializer = Data::Serializer->(serializer => 'PHP::Serialization');
my $php_serializer = Data::Serializer->(serializer => 'PHP::Serialization', raw => 1);
my $hash_ref = $php_serializer->raw_deserialize($php_data);
my $hash_ref = $php_serializer->deserialize($php_data);
my $xml_data = $xml_serializer->raw_serialize($hash_ref);
my $xml_data = $xml_serializer->serialize($hash_ref);
=head1 Keeping data persistent between executions of a program.
......@@ -144,7 +148,7 @@ Neil Neely <F<neil@neely.cx>>.
=head1 COPYRIGHT
Copyright (c) 2001-2007 Neil Neely. All rights reserved.
Copyright (c) 2001-2008 Neil Neely. All rights reserved.
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
......
use lib "./t"; # to pick up a ExtUtils::TBone
use ExtUtils::TBone;
##
## This is a placeholder test - When I get around to making a signature, I'll test it here
##
my $T = typical ExtUtils::TBone; # standard log
$T->begin('0');
$T->msg("This is a palceholder for when this module actually has a signature"); # message for the log
#my $T = typical ExtUtils::TBone; # standard log
#
#my $mod_sig = (eval { require Module::Signature; 1 });
#unless ($mod_sig) {
# $T->begin('0 # Skipped: Module::Signature not installed');
# exit;
#}
#unless (-e 'SIGNATURE') {
# $T->begin('0 # Skipped: No signature!');
# exit;
#}
#
#$T->begin('1');
#$T->msg("Comparing Signature"); # message for the log
#$T->ok_eq(Module::Signature::verify(),Module::Signature::SIGNATURE_OK(), 'Signature');
#use Test::More tests => 1;
#
#SKIP: {
# skip( 'No signature!', 1 ) unless -e 'SIGNATURE';
# if (eval { require Module::Signature; 1 }) {
# ok(Module::Signature::verify() == Module::Signature::SIGNATURE_OK()
# => "Valid signature" );
# }
# else {
# diag("Next time around, consider install Module::Signature,\n".
# "so you can verify the integrity of this distribution.\n");
# skip("Module::Signature not installed", 1)
# }
#}
__END__
## in a separate test file
use Test::More;
eval { require Test::Kwalitee; Test::Kwalitee->import() };
plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;
......@@ -23,7 +23,7 @@ foreach my $serializer (keys %serializers) {
$T->msg("No serializers found!!") unless (@serializers);
my @types = qw(fh-storage storage);
my @types = qw(fh-storage storage rawstorage);
find_features($T,@types);
......
......@@ -307,8 +307,9 @@ sub run_test {
} elsif (grep {/rawnew/} $features) {
my $newobj = Data::Serializer->new(
serializer=>$serializer,
portable=>undef,
serializer_token=>undef,
raw => 1,
#portable=>undef,
#serializer_token=>undef,
);
$frozen = $obj->serialize($testrefs{$test});
$thawed = $obj->deserialize($frozen);
......@@ -327,6 +328,14 @@ sub run_test {
$obj->store($testrefs{$test},$file_path);
$thawed = $obj->retrieve($file_path);
unlink($file_path);
} elsif (grep {/rawstorage/} $features) {
my $newobj = Data::Serializer->new(
serializer=>$serializer,
raw => 1,
);
$newobj->store($testrefs{$test},$file_path);
$thawed = $newobj->retrieve($file_path);
unlink($file_path);
} else {
$frozen = $obj->serialize($testrefs{$test});
$thawed = $obj->deserialize($frozen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment