Data-Serializer-0.60000755000764000764 012205015356 13467 5ustar00neilneil000000000000MANIFEST000444000764000764 302712205015356 14700 0ustar00neilneil000000000000Data-Serializer-0.60Changes MANIFEST MANIFEST.SKIP README INSTALL #SIGNATURE Build.PL Makefile.PL lib/Data/Serializer.pm lib/Data/Serializer/Raw.pm lib/Data/Serializer/Persistent.pm lib/Data/Serializer/Storable.pm lib/Data/Serializer/FreezeThaw.pm lib/Data/Serializer/Data/Dumper.pm lib/Data/Serializer/Data/Denter.pm lib/Data/Serializer/Data/Taxi.pm lib/Data/Serializer/Config/General.pm lib/Data/Serializer/YAML.pm lib/Data/Serializer/YAML/Syck.pm lib/Data/Serializer/PHP/Serialization.pm lib/Data/Serializer/XML/Dumper.pm lib/Data/Serializer/XML/Simple.pm lib/Data/Serializer/Cookbook.pm lib/Data/Serializer/JSON.pm lib/Data/Serializer/Bencode.pm lib/Data/Serializer/Convert/Bencode.pm lib/Data/Serializer/Convert/Bencode_XS.pm lib/Data/Serializer/JSON/Syck.pm t/ExtUtils/TBone.pm xt/00-01-Signature.t xt/00-02-Kwalitee.t t/01-01-Data-Dumper.t t/01-02-Data-Denter.t t/01-03-Storable.t t/01-04-FreezeThaw.t t/01-05-Config-General.t t/01-06-YAML.t t/01-07-XML-Dumper.t t/01-08-PHP-Serialization.t t/01-09-XML-Simple.t t/01-10-Data-Taxi.t t/01-11-YAML-Syck.t t/01-12-JSON.t t/01-13-JSON-Syck.t t/01-14-Bencode.t t/01-15-Convert-Bencode.t t/01-16-Convert-Bencode_XS.t t/02-01-Orig-Raw.t t/02-02-Fast-Raw.t t/03-Non-Portable.t t/04-01-Compress-Zlib.t t/04-02-Compress-PPMd.t t/05-Encryption.t t/06-B64-Encoding.t t/07-01-MD5-Digest.t t/07-02-SHA1-Digest.t t/07-03-SHA-256-Digest.t t/08-Store-Retrieve.t t/09-Feature-Combos.t xt/10-01-Pod.t xt/10-02-Pod-Coverage.t t/serializer-testlib examples/README META.yml Module meta-data (added by MakeMaker) INSTALL000444000764000764 37412205015356 14562 0ustar00neilneil000000000000Data-Serializer-0.60INSTALLATION ============ First unpack the kit, if you have not already done so: tar -xzvf Data-Serializer-x.xx.tar.gz cd Data-Serializer-x.xx Data::Serializer can be installed with: perl Makefile.PL make make test make install MANIFEST.SKIP000444000764000764 12012205015356 15414 0ustar00neilneil000000000000Data-Serializer-0.60^Makefile$ ^blib/ ^pm_to_blib ^blibdirs ^Build$ ^_build/ ^testout/ ^MYMETA.yml$ README000444000764000764 2371412205015356 14454 0ustar00neilneil000000000000Data-Serializer-0.60NAME Data::Serializer:: - Modules that serialize data structures SYNOPSIS use Data::Serializer; $obj = Data::Serializer->new(); $obj = Data::Serializer->new( serializer => 'Storable', digester => 'MD5', cipher => 'DES', secret => 'my secret', compress => 1, ); $serialized = $obj->serialize({a => [1,2,3],b => 5}); $deserialized = $obj->deserialize($serialized); print "$deserialized->{b}\n"; DESCRIPTION Provides a unified interface to the various serializing modules currently available. Adds the functionality of both compression and encryption. By default Data::Serializer(3) adds minor metadata and encodes serialized data structures in it's own format. If you are looking for a simple unified pass through interface to the underlying serializers then look into Data::Serializer::Raw(3) that comes bundled with Data::Serializer(3). EXAMPLES Please see Data::Serializer::Cookbook(3) METHODS new - constructor $obj = Data::Serializer->new(); $obj = Data::Serializer->new( serializer => 'Data::Dumper', digester => 'SHA-256', cipher => 'Blowfish', secret => undef, portable => '1', compress => '0', serializer_token => '1', options => {}, ); new is the constructor object for Data::Serializer(3) objects. * The default *serializer* is "Data::Dumper" * The default *digester* is "SHA-256" * The default *cipher* is "Blowfish" * The default *secret* is "undef" * The default *portable* is 1 * The default *encoding* is "hex" * The default *compress* is 0 * The default *compressor* is "Compress::Zlib" * The default *serializer_token* is 1 * The default *options* is "{}" (pass nothing on to serializer) serialize - serialize reference $serialized = $obj->serialize({a => [1,2,3],b => 5}); Serializes the reference specified. Will compress if compress is a true value. Will encrypt if secret is defined. deserialize - deserialize reference $deserialized = $obj->deserialize($serialized); Reverses the process of serialization and returns a copy of the original serialized reference. freeze - synonym for serialize $serialized = $obj->freeze({a => [1,2,3],b => 5}); thaw - synonym for deserialize $deserialized = $obj->thaw($serialized); raw_serialize - serialize reference in raw form $serialized = $obj->raw_serialize({a => [1,2,3],b => 5}); This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) If you desire this functionality you should look at Data::Serializer::Raw(3) instead, it is faster and leaner. raw_deserialize - deserialize reference in raw form $deserialized = $obj->raw_deserialize($serialized); This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) If you desire this functionality you should look at Data::Serializer::Raw(3) instead, it is faster and leaner. secret - specify secret for use with encryption $obj->secret('mysecret'); Changes setting of secret for the Data::Serializer(3) object. Can also be set in the constructor. If specified than the object will utilize encryption. portable - encodes/decodes serialized data Uses encoding method to ascii armor serialized data Aids in the portability of serialized data. compress - compression of data 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. If you desire this functionality you should look at Data::Serializer::Raw(3) instead, it is faster and leaner. serializer - change the serializer Currently supports the following serializers: Bencode(3) Convert::Bencode(3) Convert::Bencode_XS(3) Config::General(3) Data::Denter(3) Data::Dumper(3) Data::Taxi(3) FreezeThaw(3) JSON(3) JSON::Syck(3) PHP::Serialization(3) Storable(3) XML::Dumper(3) XML::Simple(3) YAML(3) YAML::Syck(3) Default is to use Data::Dumper. Each serializer has its own caveat's about usage especially when dealing with cyclical data structures or CODE references. Please see the appropriate documentation in those modules for further information. cipher - change the cipher method Utilizes Crypt::CBC(3) and can support any cipher method that it supports. digester - change digesting method Uses Digest(3) so can support any digesting method that it supports. Digesting function is used internally by the encryption routine as part of data verification. compressor - changes compresing module Currently Compress::Zlib(3) and Compress::PPMd(3) are the only options encoding - change encoding method Encodes data structure in ascii friendly manner. Currently the only valid options are hex, or b64. The b64 option uses Base64 encoding provided by MIME::Base64(3), but strips out newlines. serializer_token - add usage hint to data Data::Serializer(3) prepends a token that identifies what was used to process its data. This is used internally to allow runtime determination of how to extract serialized data. Disabling this feature is not recommended. (Use Data::Serializer::Raw(3) instead). options - pass options through to underlying serializer Currently is only supported by Config::General(3), and XML::Dumper(3). my $obj = Data::Serializer->new(serializer => 'Config::General', options => { -LowerCaseNames => 1, -UseApacheInclude => 1, -MergeDuplicateBlocks => 1, -AutoTrue => 1, -InterPolateVars => 1 }, ) or die "$!\n"; or my $obj = Data::Serializer->new(serializer => 'XML::Dumper', options => { dtd => 1, } ) or die "$!\n"; store - serialize data and write it to a file (or file handle) $obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]); or $obj->store({a => [1,2,3],b => 5},$fh); Serializes the reference specified using the serialize method and writes it out to the specified file or filehandle. If a file path is specified you may specify an optional mode and permission as the next two arguments. See IO::File for examples. Trips an exception if it is unable to write to the specified file. retrieve - read data from file (or file handle) and return it after deserialization my $ref = $obj->retrieve($file); or my $ref = $obj->retrieve($fh); Reads first line of supplied file or filehandle and returns it deserialized. AUTHOR Neil Neely . Feature requests are certainly welcome. http://neil-neely.blogspot.com/ BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer TODO Extend the persistent framework. Perhaps Persistent::Base(3) framework would be useful to explore further. Volunteers for putting this together would be welcome. COPYRIGHT AND LICENSE Copyright (c) 2001-2011 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 your option, any later version of Perl 5 you may have available. See http://www.perl.com/language/misc/Artistic.html ACKNOWLEDGEMENTS Gurusamy Sarathy and Raphael Manfredi for writing MLDBM(3), the module which inspired the creation of Data::Serializer(3). And thanks to all of you who have provided the feedback that has improved this module over the years. In particular I'd like to thank Florian Helmberger, for the numerous suggestions and bug fixes. DEDICATION This module is dedicated to my beautiful wife Erica. SEE ALSO Bencode(3) Convert::Bencode(3) Convert::Bencode_XS(3) Config::General(3) Data::Denter(3) Data::Dumper(3) Data::Taxi(3) FreezeThaw(3) JSON(3) JSON::Syck(3) PHP::Serialization(3) Storable(3) XML::Dumper(3) XML::Simple(3) YAML(3) YAML::Syck(3) Compress::Zlib(3) Compress::PPMd(3) Digest(3) Digest::SHA(3) Crypt::CBC(3) MIME::Base64(3) IO::File(3) Data::Serializer::Config::Wrest(3) - adds supports for Config::Wrest(3) Build.PL000444000764000764 245112205015356 15043 0ustar00neilneil000000000000Data-Serializer-0.60use Module::Build; my $build = Module::Build->new ( #sign => 1, module_name => 'Data::Serializer', dist_author => 'Neil Neely (neil@neely.cx)', license => 'perl', create_makefile_pl => 'passthrough', build_class => 'Module::Build', requires => { 'Exporter' => 0, 'AutoLoader' => 0, 'IO::File' => 0, 'Digest::SHA' => 0, 'Data::Dumper' => 2.08, }, build_requires => { #'AutoSplit' => 0, 'IO::File' => 0, 'Test::More' => 0, 'File::Spec' => 0, }, recommends => { 'Crypt::CBC' => 0, 'Crypt::Blowfish' => 0, 'Data::Denter' => 0, 'Data::Taxi' => 0, 'Storable' => 0, 'FreezeThaw' => 0, 'Config::General' => 0, 'YAML' => 0, 'YAML::Syck' => 0, 'PHP::Serialization' => 0, 'JSON' => 0, 'JSON::XS' => 0, 'JSON::Syck' => 0, 'XML::Simple' => 0, 'XML::Dumper' => 0, 'Bencode' => 0, 'Convert::Bencode' => 0, 'Convert::Bencode_XS' => 0, 'Compress::Zlib' => 0, 'Compress::PPMd' => 0, 'MIME::Base64' => 0, }, #autosplit => 'lib/Data/Serializer.pm', ); $build->create_build_script; Makefile.PL000444000764000764 233312205015356 15520 0ustar00neilneil000000000000Data-Serializer-0.60# Note: this file was auto-generated by Module::Build::Compat version 0.35 unless (eval "use Module::Build::Compat 0.02; 1" ) { print "This module requires Module::Build to install itself.\n"; require ExtUtils::MakeMaker; my $yn = ExtUtils::MakeMaker::prompt (' Install Module::Build now from CPAN?', 'y'); unless ($yn =~ /^y/i) { die " *** Cannot install without Module::Build. Exiting ...\n"; } require Cwd; require File::Spec; require CPAN; # Save this 'cause CPAN will chdir all over the place. my $cwd = Cwd::cwd(); CPAN::Shell->install('Module::Build::Compat'); CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate or die "Couldn't install Module::Build, giving up.\n"; chdir $cwd or die "Cannot chdir() back to $cwd: $!"; } eval "use Module::Build::Compat 0.02; 1" or die $@; Module::Build::Compat->run_build_pl(args => \@ARGV); my $build_script = 'Build'; $build_script .= '.com' if $^O eq 'VMS'; exit(0) unless(-e $build_script); # cpantesters convention require Module::Build; Module::Build::Compat->write_makefile(build_class => 'Module::Build'); META.yml000444000764000764 532212205015356 15020 0ustar00neilneil000000000000Data-Serializer-0.60--- name: Data-Serializer version: 0.60 author: - "Neil Neely (neil@neely.cx)" abstract: Modules that serialize data structures license: perl build_requires: File::Spec: 0 IO::File: 0 Test::More: 0 requires: AutoLoader: 0 Data::Dumper: 2.08 Digest::SHA: 0 Exporter: 0 IO::File: 0 recommends: Bencode: 0 Compress::PPMd: 0 Compress::Zlib: 0 Config::General: 0 Convert::Bencode: 0 Convert::Bencode_XS: 0 Crypt::Blowfish: 0 Crypt::CBC: 0 Data::Denter: 0 Data::Taxi: 0 FreezeThaw: 0 JSON: 0 JSON::Syck: 0 JSON::XS: 0 MIME::Base64: 0 PHP::Serialization: 0 Storable: 0 XML::Dumper: 0 XML::Simple: 0 YAML: 0 YAML::Syck: 0 configure_requires: Module::Build: 0.35 generated_by: Module::Build version 0.35 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 provides: Data::Serializer: file: lib/Data/Serializer.pm version: 0.60 Data::Serializer::Bencode: file: lib/Data/Serializer/Bencode.pm version: 0.03 Data::Serializer::Config::General: file: lib/Data/Serializer/Config/General.pm version: 0.02 Data::Serializer::Convert::Bencode: file: lib/Data/Serializer/Convert/Bencode.pm version: 0.03 Data::Serializer::Convert::Bencode_XS: file: lib/Data/Serializer/Convert/Bencode_XS.pm version: 0.03 Data::Serializer::Cookbook: file: lib/Data/Serializer/Cookbook.pm version: 0.05 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.04 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::Persistent: file: lib/Data/Serializer/Persistent.pm version: 0.01 Data::Serializer::Raw: file: lib/Data/Serializer/Raw.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.03 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 resources: license: http://dev.perl.org/licenses/ Changes000444000764000764 4002612205015355 15061 0ustar00neilneil000000000000Data-Serializer-0.60Revision history for Perl extension Data::Serializer 0.60 Tue Aug 20 2013 Move some non-critical tests from t/ to xt/ as they are not needed for verifying functionality of the module, merely ensuring a clean release. No changes to core Data::Serializer functionality with this release. 0.59 Thr Jun 16 2011 XML::Simple utf8 testing disabled, looks like XML::SAX works with utf8, but XML::Parser does not Recommend against using XML::Simple if you need to work with utf8 until this is resolved Fixes http://rt.cpan.org/Public/Bug/Display.html?id=68871 Thanks to perl testers - Robert Buels rmb32@cornell.edu in particular 0.58 Tue Jun 14 2011 - Added utf8 to the decode in the JSON deserializing code. Fixes https://rt.cpan.org/Public/Bug/Display.html?id=68125 Thanks to colink@perldreamer.com for finding the bug and supplying good tests and a suggested fix and to lp@sunnyspot.org for the suggested ->utf8-> fix (which really was functionally identical to what colink recommended) 0.57 Mon Jan 17 2011 - Updated remainder of test suite to armor against XML::Simple dependency problems that I first attempted to fix in 0.53. Only modified tests, no change to module code Thanks to the cpantesters automated reporting for finding this. 0.56 Fri Jan 14 2011 - Moved store/retrieve internals to Data::Serializer::Persistent (internals only) This defers the inclusion of IO::File to happen only if store or retrieve is called - Added store/retireve to Data::Serializer::Raw 0.55 Fri Jan 14 2011 - Added support for Bencode, Convert::Bencode, and Convert::Bencode_XS - Documentation updates 0.54 Thu Jan 13 2011 - Added Data::Serializer::Raw as a lightweight means of providing a unified raw access to the underlying serializers also improved caching of serializer object inside of Data::Serializer Thanks to Peter Makholm for the profiling done by Benchmark::Serialize 0.53 Mon Jan 10 2011 - Modified tests for XML::Simple - it has sub-dependencies on either XML::Parser or XML::SAX the test harness was posting a failure if neither of these were present. Now it will treat XML::Simple as if it weren't installed if it is missing it's own depenencies. This version only modifies the test harness no modification to module code. Thanks to the cpantesters automated reporting for finding this. 0.52 Mon Jan 3 2011 - Simplfied object by removing %_internal references, base $serializer object is much simpler now. This eliminated the need for an overridden DESTROY method, and should truly fix the memory leak problem originally reported by fabrice@dulaunoy.com, essentially it was confusing the Garbage collector (Fix Bug#39592) 0.51 Wed Dec 29 2010 - Modified JSON deserializer to handle corrupt input (Bug#63259) Thanks to neil.whelchel@gmail.com for report and patch 0.50 Wed Dec 29 2010 - Modified dedigest function to armor against corrupt input values (Bug#63258) Thanks to neil.whelchel@gmail.com for report and patch 0.49 Tue Apr 15 2009 - Modified XML::Simple serializer to support options patch supplied by John Alden 0.48 Tue Aug 20 2008 - Cleaned up DESTROY method to not undef _fields (This was my error, not the submitted patch) Thanks to Dulaunoy Fabrice for showing me the error of my ways 0.47 Tue Aug 19 2008 - Added explicit DESTROY method to prevent memory leaks in long running applications with circular references patch supplied by Dulaunoy Fabrice 0.46 Wed Apr 23 2008 - Fixed Module::Build implementation, will now generate proper META.yml file 0.45 Wed Apr 23 2008 - Removed support for Tie::Transient, the module is long gone. If ever a standard emerges for tagging data as transient then Data::Serializer will support it. - Added utf8 call to Data::Serializer::JSON patch supplied by Makamaka in response to complex bug discussion that started under Crypt::CBC http://rt.cpan.org/Public/Bug/Display.html?id=35239 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 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 - Added build_requires list - Added use warnings calls to all modules - Patched to support JSON 2 by Makamaka (Thanks Makamaka!) - Removed Autoloader from sub-modules -sub modules are tiny two method affairs that really don't need autosplit - and Module::Build makes it a pain - Removed 'require Exporter' from sub modules, as they weren't using them in anyway (just cleaning up) 0.42 Fri Oct 26 2007 - Added support for Compress::PPMd Thanks to Strzelecki Łukasz for recommending the addition as well as supplying relevant code samples. 0.41 Wed May 17 2007 - Bowing to peer pressure and adding in the Test::Pod stuff in production, this means adding a prereq of Test::More - Updated Data::Serializer::Cookbook - Added an examples/ dir to the distribution - put a copy of the Cookbook in the examples dir via pod2text as README - Would be happy to add user submitted examples (send to neil@neely.cx) 0.40 Wed May 16 2007 - Updated contact information to be neil@neely.cx, this is a purely cosmetic change 0.39 Mon Mar 5 10:39:00 MST 2007 - Left "use File::Slurp" inside of Serializer.pm from some testing, removed this needless dependency 0.38 Mon Mar 5 09:15:00 MST 2007 - Modified Data::Serializer::Storable to always use nfreeze, whether portable flag is set or not Thanks to David Sepiashvili for pointing out the original logic wasn't very useful - Removed tests for self references in JSON::Syck, as they are no longer supported - if you try to use them with current versions of JSON::Syck it will error out. Thanks to David Cantrell of the cpan-testers for finding this problem, and helping to track it down. 0.37 Wed Mar 22 11:10:52 MDT 2006 - Added use strict statement to Data::Serializer::Cookbook to make CPANTS happy (not really important) - renamed internal transient method to be _transient (should be deprecated completely one of these days) - documented compressor method (noted that it isn't currently supported, just a placeholder) - Added tests for Test::Pod and Test::Pod::Coverage - test are disabled for distribution as I don't want to add a Test::More dependency to Data::Serializer at this point. - Nothing important changed, so this version was not publicly released 0.36 Thu Mar 16 10:10:04 MDT 2006 - Added support for JSON, JSON::Syck, and YAML::Syck Thanks to Naoya Ito for writing the patch and making my job very easy. 0.35 Wed Nov 03 07:37:31 MDT 2005 - Anchored token extractor When portable was disabled, binary type data could confuse the token extractor and break the ability to deserialize data. Thanks to Carl Eklof for reporting this via RT (https://rt.cpan.org/). and also for suggesting the fix 0.34 Mon Oct 17 12:02:04 MDT 2005 - Fixed Serialized scalars from Data::Dumper Previously would only serialize scalar references, now will serialize scalars too Thanks to Chris for reporting this via RT (https://rt.cpan.org/). 0.33 Wed Sep 28 16:37:50 MDT 2005 - Added support for Data::Taxi - Minor documentation changes 0.32 Tue Sep 27 15:49:45 MDT 2005 - Fixed bug with declaring 'options' for an underlying serializer Thanks to rk1990@google.com for finding and supplying the patch to fix it. 0.31 Tue Sep 27 12:10:11 MDT 2005 - Fixed bug in the test suite introduced in .30 Thanks to the cpan-testers for identifying this quickly 0.30 Thu Sep 15 08:49:28 MDT 2005 - Modified call to Digest module to bring it up to current. - Changed default digester to SHA-256 Thanks to Mark Shelor for sending out the notice that sha1 is now considered vulnerable. * If you explicitly want to use SHA1 that will still work, but be advised that is no longer considered secure. This only impacts serialization if you are using it with encryption. 0.29 Mon Feb 07 18:42:14 MDT 2005 - Modified constructor to test exists rather then defined allowing features to be disabled in the constructor. - Modified deserialize to check if values are true, not just defined to enable features also fixed a bug in deserialize for tokenless deserializations where compressor was checked instead of compress to determine if the data needed to be decompressed - Cleaned up a couple bugs that prevented it from compiling when autosplit was disabled Thanks to John Alden for detailed bug reports, and excellent recommendations. 0.28 Mon Dec 06 13:08:42 MST 2004 - Test qw compatibility bug in older perl versions fixed: From the 5.6 perldelta: The qw// operator is now evaluated at compile time into a true list instead of being replaced with a run time call to split(). This removes the confusing misbehavior of qw// in scalar context, which had inherited that behavior from split(). To keep the module compatible with older version of perl the test was changed to explicitly return a list and thus circumvent this limitation of qw in older versions of perl. Thanks to nothingmuch@woobling.org for having multiple perl versions in the cpan testers results to make finding the compatibility problem possible. 0.27 Mon Dec 06 08:51:53 MST 2004 - Fixed version bug in test suite Routine in test suite that tested storing to open filehandles was using open() in a fashion incompatible with earlier versions of perl. Converted it to use IO::File instead. Thanks to the cpan testers for catching this one, in particular nothingmuch@woobling.org 0.26 Fri Dec 03 11:49:34 MST 2004 - Modified Data::Serializer::Data::Dumper removed the '2.08' requirement from use statement, this is handled in the Makefile.PL so was redundant anyway. Was causing problems with build in perl 5.8.6 Thanks to Ian Tue Oct 05 15:30:02 MST 2004 - Modified Data::Serializer::Storable to use nfreeze when the portable flag is set. This should help make the use of Storable within Data::Serializer actually be portable when you ask it to be. Thanks to Nick Edwards for requesting the feature -Modified Data::Serializer::Data::Dumper to handle self-references correctly. Was not correctly handling the serializing of self-referencing data structures. Thanks to Ticha for finding the bug, and to Gurusamy Sarathy (Data::Dumper author) for suggesting the fix. 0.25 Sat Jun 01 06:38:13 MST 2004 - Fixed misbehaving sloppy reference passing in test harness. (Bug only visible in win32) Thanks to =?ISO-8859-1?Q?=22Murat_=DCnalan=22?= For debugging and providing the patch to get this to work. 0.24 Sat May 29 14:22:42 MST 2004 - Fixed bug in new 08-Store-Retrieve.t test Now using File::Spec to correctly build path for test Thanks to =?ISO-8859-1?Q?=22Murat_=DCnalan=22?= For being on the ball in catching this bug. 0.23 Fri May 28 17:21:11 MST 2004 - Added store and retrieve functions for simple persistence Thanks to Nick Stutterer and =?ISO-8859-1?Q?=22Murat_=DCnalan=22?= For requesting this useful feature. - Updated cookbook persistence example 0.22 Fri Mar 5 16:39:36 MST 2004 - Split up and organized test suite - Added support for XML::Simple - Created Data::Serializer::Cookbook 0.21 Tue Feb 24 16:57:19 MST 2004 - Added support for PHP::Serializer - Added support for XML::Dumper - Added raw_serialize and raw_deserialize methods allows direct access to underlying serializers useful to import/export data between aps that don't understand Data::Serializer (like say serialized PHP data) - Added test for serializing scalars 0.20 Fri Feb 13 17:32:02 MST 2004 - Improved test suite to test combination of features - cleaned up bug in handing of 'non-portable' serialized data 0.19 Fri Feb 13 14:46:30 MDT 2004 - Modified makefile to include dependancy on Digest::SHA1 Thanks (again) to Florian Helmberger for finding this discrepancy. 0.18 Fri Feb 13 11:17:24 MDT 2004 - Added support for MIME::Base64 for 'ascii armoring' serialized data. - Minor modifications to pod documentation 0.17 Thu Jul 11 15:10:41 MDT 2002 - Added support for YAML as a new serializer Thanks to Florian Helmberger for writing the relevant patch to do this. 0.16 Tue Jul 9 08:33:46 MDT 2002 - Added support for Config::General as a new serializer - Added method 'options' for passing arguments to underlying serializers currently only supported for Config::General - Converted installation tests to use ExtUtils::Tbone (included) - Added more robust testing of all serializers and features Thanks to Thomas Linden who wrote a patch adding support for Config::General to Data::Serializer and for suggesting the addition of the options method 0.15 Mon Jul 1 13:32:46 MDT 2002 - Correct Makefile.PL testing bug In particular we tested for Crypt::CBC and assumed Crypt::Blowfish would also be installed. This is obviously not the case. We do not want to force this as a dependency as encryption is a feature, not a requirement for serializing data structures. Thanks to 'Automated Perl Test Account ' 0.14 Mon Jul 1 08:43:42 MDT 2002 - Corrected typo's in pod documentation Thanks to Florian Helmberger 0.13 Mon Jan 14 12:49:10 MST 2002 - Added support for Tie::Transient Thanks to recomendation from brian moseley ) 0.12 Mon Jan 14 12:23:28 MST 2002 - Cleaned up installation tests 0.11 Tue Jan 8 13:28:43 MST 2002 - Removed build dependencies for all but Data::Dumper Thanks to recomendation from brian moseley 0.10 Mon Jan 7 13:00:24 MST 2002 - Added Support for Data::Denter 0.09 Fri Nov 2 08:14:07 2001 - Cleaned up documentation 0.08 Mon Oct 16 07:54:32 2001 - Fixed bug in digest verification - Fixed 5.005_03 compatibility bug Thanks to Tatsuhiko Miyagawa 0.07 Wed Oct 5 11:42:20 2001 - changed token system to be more flexible - added compression - cleaned up 'portability' option - updated documentation - updated tests 0.06 Wed Oct 4 16:27:02 2001 - added Encryption 0.05 Wed Oct 4 14:30:13 2001 - added t/ tests 0.04 Wed Oct 4 12:35:44 2001 - added documentation 0.03 Wed Oct 4 11:32:10 2001 - added serializer_token to assist deserialization 0.02 Tue Oct 3 15:32:19 2001 - completed generic serializer/deserializer interface 0.01 Tue Oct 3 11:11:36 2001 - original version; created by h2xs 1.19 xt000755000764000764 012205015356 14043 5ustar00neilneil000000000000Data-Serializer-0.6010-01-Pod.t000444000764000764 20112205015356 15514 0ustar00neilneil000000000000Data-Serializer-0.60/xtuse Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); 00-02-Kwalitee.t000444000764000764 25412205015356 16547 0ustar00neilneil000000000000Data-Serializer-0.60/xt## in a separate test file use Test::More; eval { require Test::Kwalitee; Test::Kwalitee->import() }; plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@; 00-01-Signature.t000444000764000764 250412205015356 16762 0ustar00neilneil000000000000Data-Serializer-0.60/xtuse 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__ 10-02-Pod-Coverage.t000444000764000764 24312205015356 17254 0ustar00neilneil000000000000Data-Serializer-0.60/xtuse Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); lib000755000764000764 012205015356 14156 5ustar00neilneil000000000000Data-Serializer-0.60Data000755000764000764 012205015356 15027 5ustar00neilneil000000000000Data-Serializer-0.60/libSerializer.pm000444000764000764 5207412205015356 17663 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Datapackage Data::Serializer; use warnings; use strict; use vars qw($VERSION); use Carp; require 5.004 ; $VERSION = '0.60'; #Global cache of modules we've loaded my %_MODULES; my %_fields = ( serializer => 'Data::Dumper', digester => 'SHA-256', cipher => 'Blowfish', encoding => 'hex', compressor => 'Compress::Zlib', secret => undef, portable => '1', compress => '0', raw => '0', options => {}, serializer_token => '1', ); sub new { my ($class, %args) = @_; my $dataref = {%_fields}; foreach my $field (keys %_fields) { $dataref->{$field} = $args{$field} if exists $args{$field}; } my $self = $dataref; bless $self, $class; #preintitialize serializer object $self->_serializer_obj(); return $self; } sub _serializer_obj { my $self = (shift); my $method = (shift); my $reset = (shift); my $serializer = $self->{serializer}; #remove cache if asked to if ($reset) { delete $self->{serializer_obj}; } #If we're given the same method that we are already using, nothing to change if (defined $method && $method ne $serializer) { $serializer = $method; } else { #safe to return our cached object if we have it return $self->{serializer_obj} if (exists $self->{serializer_obj}); } $self->_module_loader($serializer,"Data::Serializer"); #load in serializer module if necessary my $serializer_obj = {}; $serializer_obj->{options} = $self->{options}; bless $serializer_obj, "Data::Serializer::$serializer"; #Cache it for later retrieval only if this is the default serializer for the object #ugly logic to support legacy token method that would allow the base to have a different serializer #than what it is reading if ($serializer eq $self->{serializer}) { $self->{serializer_obj} = $serializer_obj; } return $serializer_obj; } sub _persistent_obj { my $self = (shift); return $self->{persistent_obj} if (exists $self->{persistent_obj}); $self->_module_loader('Data::Serializer::Persistent'); my $persistent_obj = { parent => $self }; bless $persistent_obj, "Data::Serializer::Persistent"; $self->{persistent_obj} = $persistent_obj; return $persistent_obj; } sub serializer { my $self = (shift); my $return = $self->{serializer}; if (@_) { $self->{serializer} = (shift); #Reinitialize object $self->_serializer_obj($self->{serializer}, 1); } return $return; } sub digester { my $self = (shift); my $return = $self->{digester}; if (@_) { my $value = (shift); $self->{digester} = $value; } return $return; } sub cipher { my $self = (shift); my $return = $self->{cipher}; if (@_) { $self->{cipher} = (shift); } return $return; } sub compressor { my $self = (shift); my $return = $self->{compressor}; if (@_) { $self->{compressor} = (shift); } return $return; } sub secret { my $self = (shift); my $return = $self->{secret}; if (@_) { $self->{secret} = (shift); } return $return; } sub encoding { my $self = (shift); my $return = $self->{encoding}; if (@_) { $self->{encoding} = (shift); } return $return; } sub portable { my $self = (shift); my $return = $self->{portable}; if (@_) { $self->{portable} = (shift); } return $return; } sub options { my $self = (shift); my $return = $self->{options}; if (@_) { $self->{options} = (shift); #Reinitialize object $self->_serializer_obj($self->{serializer}, 1); } return $return; } sub compress { my $self = (shift); my $return = $self->{compress}; if (@_) { $self->{compress} = (shift); } return $return; } sub raw { my $self = (shift); my $return = $self->{raw}; if (@_) { $self->{raw} = (shift); } return $return; } sub serializer_token { my $self = (shift); my $return = $self->{serializer_token}; if (@_) { $self->{serializer_token} = (shift); } return $return; } sub _module_loader { my $self = (shift); my $module_name = (shift); unless (defined $module_name) { confess "Something wrong - module not defined! $! $@\n"; } return if (exists $_MODULES{$module_name}); if (@_) { $module_name = (shift) . "::$module_name"; } my $package = $module_name; $package =~ s|::|/|g; $package .= ".pm"; eval { require $package }; if ($@) { carp "Data::Serializer error: " . "Please make sure $package is a properly installed package.\n"; return undef; } $_MODULES{$module_name} = 1; } sub _serialize { my $self = (shift); my @input = @{(shift)};#original @_ my $method = (shift); $self->_module_loader($method,"Data::Serializer"); #load in serializer module if necessary my $serializer_obj = $self->_serializer_obj($method); return $serializer_obj->serialize(@input); } sub _compress { my $self = (shift); $self->_module_loader($self->compressor); if ($self->compressor eq 'Compress::Zlib') { return Compress::Zlib::compress((shift)); } elsif ($self->compressor eq 'Compress::PPMd') { my $compressor = Compress::PPMd::Encoder->new(); return $compressor->encode((shift)); } } sub _decompress { my $self = (shift); $self->_module_loader($self->compressor); if ($self->compressor eq 'Compress::Zlib') { return Compress::Zlib::uncompress((shift)); } elsif ($self->compressor eq 'Compress::PPMd') { my $compressor = Compress::PPMd::Decoder->new(); return $compressor->decode((shift)); } } sub _create_token { my $self = (shift); return '^' . join('|', @_) . '^'; } sub _get_token { my $self = (shift); my $line = (shift); #Should be anchored to beginning #my ($token) = $line =~ /\^([^\^]+?)\^/; my ($token) = $line =~ /^\^([^\^]{1,120}?)\^/; return $token; } sub _extract_token { my $self = (shift); my $token = (shift); return split('\|',$token); } sub _remove_token { my $self = (shift); my $line = (shift); $line =~ s/^\^[^\^]{1,120}?\^//; return $line; } sub _deserialize { my $self = (shift); my $input = (shift); my $method = (shift); $self->_module_loader($method,"Data::Serializer"); #load in serializer module if necessary my $serializer_obj = $self->_serializer_obj($method); $serializer_obj->deserialize($input); } sub _encrypt { my $self = (shift); my $value = (shift); my $cipher = (shift); my $digester = (shift); my $secret = $self->secret; croak "Cannot encrypt: No secret provided!" unless defined $secret; $self->_module_loader('Crypt::CBC'); my $digest = $self->_endigest($value,$digester); my $cipher_obj = Crypt::CBC->new($secret,$cipher); return $cipher_obj->encrypt($digest); } sub _decrypt { my $self = (shift); my $input = (shift); my $cipher = (shift); my $digester = (shift); my $secret = $self->secret; croak "Cannot encrypt: No secret provided!" unless defined $secret; $self->_module_loader('Crypt::CBC'); my $cipher_obj = Crypt::CBC->new($secret,$cipher); my $digest = $cipher_obj->decrypt($input); return $self->_dedigest($digest,$digester); } sub _endigest { my $self = (shift); my $input = (shift); my $digester = (shift); $self->_module_loader('Digest'); my $digest = $self->_get_digest($input,$digester); return "$digest=$input"; } sub _dedigest { my $self = (shift); my $input = (shift); my $digester = (shift); $self->_module_loader('Digest'); #my ($old_digest) = $input =~ /^([^=]+?)=/; $input =~ s/^([^=]+?)=//; my $old_digest = $1; return undef unless (defined $old_digest); my $new_digest = $self->_get_digest($input,$digester); return undef unless ($new_digest eq $old_digest); return $input; } sub _get_digest { my $self = (shift); my $input = (shift); my $digester = (shift); my $ctx = Digest->new($digester); $ctx->add($input); return $ctx->hexdigest; } sub _enhex { my $self = (shift); return join('',unpack 'H*',(shift)); } sub _dehex { my $self = (shift); return (pack'H*',(shift)); } sub _enb64 { my $self = (shift); $self->_module_loader('MIME::Base64'); my $b64 = MIME::Base64::encode_base64( (shift), '' ); return $b64; } sub _deb64 { my $self = (shift); $self->_module_loader('MIME::Base64'); return MIME::Base64::decode_base64( (shift) ); } # do all 3 stages sub freeze { (shift)->serialize(@_); } sub thaw { (shift)->deserialize(@_); } 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 $serializer = $self->serializer; my $value = $self->_serialize(\@_,$serializer); if ($self->compress) { $compressor = $self->compressor; $value = $self->_compress($value); } if (defined $self->secret) { #define digester for token $digester = $self->digester; #define cipher for token $cipher = $self->cipher; $value = $self->_encrypt($value,$cipher,$digester); } if ($self->portable) { $encoding = $self->encoding; $value = $self->_encode($value); } if ($self->serializer_token) { my $token = $self->_create_token($serializer,$cipher, $digester,$encoding,$compressor); $value = $token . $value; } return $value; } sub store { my $self = (shift); my $persistent = $self->_persistent_obj(); $persistent->_store(@_); } sub retrieve { my $self = (shift); my $persistent = $self->_persistent_obj(); $persistent->_retrieve(@_); } sub raw_serialize { my $self = (shift); my $serializer = $self->serializer; return $self->_serialize(\@_,$serializer); } sub _encode { my $self = (shift); my $value = (shift); my $encoding = $self->encoding; if ($encoding eq 'hex') { return $self->_enhex($value); } elsif ($encoding eq 'b64') { return $self->_enb64($value); } else { croak "Unknown encoding method $encoding\n"; } } sub _decode { my $self = (shift); my $value = (shift); my $encoding = (shift); if ($encoding eq 'hex') { return $self->_dehex($value); } elsif ($encoding eq 'b64') { return $self->_deb64($value); } elsif ($encoding !~ /\S/) { #quietly ignore empty encoding return $value; } else { croak "Unknown encoding method $encoding\n"; } } sub raw_deserialize { my $self = (shift); my $serializer = $self->serializer; return $self->_deserialize((shift),$serializer); } 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); my $compress = $self->compress; if (defined $token) { ($serializer,$cipher, $digester,$encoding, $compressor) = $self->_extract_token($token); #if compressor is defined and has a value then we must decompress it $compress = 1 if ($compressor); $value = $self->_remove_token($value); } else { $serializer = $self->serializer; $cipher = $self->cipher; $digester = $self->digester; $compressor = $self->compressor; if ($self->portable) { $encoding = $self->encoding; } } if (defined $encoding) { $value = $self->_decode($value,$encoding); } if (defined $self->secret) { $value = $self->_decrypt($value,$cipher,$digester); } if ($compress) { $value = $self->_decompress($value); } #we always deserialize no matter what. my @return = $self->_deserialize($value,$serializer); return wantarray ? @return : $return[0]; } 1; __END__ #Documentation follows =pod =head1 NAME Data::Serializer:: - Modules that serialize data structures =head1 SYNOPSIS use Data::Serializer; $obj = Data::Serializer->new(); $obj = Data::Serializer->new( serializer => 'Storable', digester => 'MD5', cipher => 'DES', secret => 'my secret', compress => 1, ); $serialized = $obj->serialize({a => [1,2,3],b => 5}); $deserialized = $obj->deserialize($serialized); print "$deserialized->{b}\n"; =head1 DESCRIPTION Provides a unified interface to the various serializing modules currently available. Adds the functionality of both compression and encryption. By default L adds minor metadata and encodes serialized data structures in it's own format. If you are looking for a simple unified pass through interface to the underlying serializers then look into L that comes bundled with L. =head1 EXAMPLES =over 4 =item Please see L =back =head1 METHODS =over 4 =item B - constructor $obj = Data::Serializer->new(); $obj = Data::Serializer->new( serializer => 'Data::Dumper', digester => 'SHA-256', cipher => 'Blowfish', secret => undef, portable => '1', compress => '0', serializer_token => '1', options => {}, ); B is the constructor object for L objects. =over 4 =item The default I is C =item The default I is C =item The default I is C =item The default I is C =item The default I is C<1> =item The default I is C =item The default I is C<0> =item The default I is C =item The default I is C<1> =item The default I is C<{}> (pass nothing on to serializer) =back =item B - serialize reference $serialized = $obj->serialize({a => [1,2,3],b => 5}); Serializes the reference specified. Will compress if compress is a true value. Will encrypt if secret is defined. =item B - deserialize reference $deserialized = $obj->deserialize($serialized); Reverses the process of serialization and returns a copy of the original serialized reference. =item B - synonym for serialize $serialized = $obj->freeze({a => [1,2,3],b => 5}); =item B - synonym for deserialize $deserialized = $obj->thaw($serialized); =item B - serialize reference in raw form $serialized = $obj->raw_serialize({a => [1,2,3],b => 5}); This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) If you desire this functionality you should look at L instead, it is faster and leaner. =item B - deserialize reference in raw form $deserialized = $obj->raw_deserialize($serialized); This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) If you desire this functionality you should look at L instead, it is faster and leaner. =item B - specify secret for use with encryption $obj->secret('mysecret'); Changes setting of secret for the L object. Can also be set in the constructor. If specified than the object will utilize encryption. =item B - encodes/decodes serialized data Uses B method to ascii armor serialized data Aids in the portability of serialized data. =item B - compression of data Compresses serialized data. Default is not to use it. Will compress if set to a true value $obj->compress(1); =item B - 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. If you desire this functionality you should look at L instead, it is faster and leaner. =item B - change the serializer Currently supports the following serializers: =over 4 =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =back Default is to use Data::Dumper. Each serializer has its own caveat's about usage especially when dealing with cyclical data structures or CODE references. Please see the appropriate documentation in those modules for further information. =item B - change the cipher method Utilizes L and can support any cipher method that it supports. =item B - change digesting method Uses L so can support any digesting method that it supports. Digesting function is used internally by the encryption routine as part of data verification. =item B - changes compresing module Currently L and L are the only options =item B - change encoding method Encodes data structure in ascii friendly manner. Currently the only valid options are hex, or b64. The b64 option uses Base64 encoding provided by L, but strips out newlines. =item B - add usage hint to data L prepends a token that identifies what was used to process its data. This is used internally to allow runtime determination of how to extract serialized data. Disabling this feature is not recommended. (Use L instead). =item B - pass options through to underlying serializer Currently is only supported by L, and L. my $obj = Data::Serializer->new(serializer => 'Config::General', options => { -LowerCaseNames => 1, -UseApacheInclude => 1, -MergeDuplicateBlocks => 1, -AutoTrue => 1, -InterPolateVars => 1 }, ) or die "$!\n"; or my $obj = Data::Serializer->new(serializer => 'XML::Dumper', options => { dtd => 1, } ) or die "$!\n"; =item B - serialize data and write it to a file (or file handle) $obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]); or $obj->store({a => [1,2,3],b => 5},$fh); Serializes the reference specified using the B method and writes it out to the specified file or filehandle. If a file path is specified you may specify an optional mode and permission as the next two arguments. See L for examples. Trips an exception if it is unable to write to the specified file. =item B - read data from file (or file handle) and return it after deserialization my $ref = $obj->retrieve($file); or my $ref = $obj->retrieve($fh); Reads first line of supplied file or filehandle and returns it deserialized. =back =head1 AUTHOR Neil Neely >. Feature requests are certainly welcome. http://neil-neely.blogspot.com/ =head1 BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer =head1 TODO Extend the persistent framework. Perhaps L framework would be useful to explore further. Volunteers for putting this together would be welcome. =head1 COPYRIGHT AND LICENSE Copyright (c) 2001-2011 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 your option, any later version of Perl 5 you may have available. See http://www.perl.com/language/misc/Artistic.html =head1 ACKNOWLEDGEMENTS Gurusamy Sarathy and Raphael Manfredi for writing L, the module which inspired the creation of L. And thanks to all of you who have provided the feedback that has improved this module over the years. In particular I'd like to thank Florian Helmberger, for the numerous suggestions and bug fixes. =head1 DEDICATION This module is dedicated to my beautiful wife Erica. =head1 SEE ALSO =over 4 =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L - adds supports for L =back =cut Serializer000755000764000764 012205015356 17140 5ustar00neilneil000000000000Data-Serializer-0.60/lib/DataStorable.pm000444000764000764 262012205015356 21406 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::Storable; BEGIN { @Data::Serializer::Storable::ISA = qw(Data::Serializer) } use warnings; use strict; use Storable; use vars qw($VERSION @ISA); $VERSION = '0.03'; # # Serialize a reference to supplied value # sub serialize { my $self = $_[0]; my $ret; $ret = Storable::nfreeze($_[1]); #using network byte order makes sense to always do, under all circumstances to make it platform neutral #if ($self->{portable}) { # $ret = Storable::nfreeze($_[1]); #} else { # $ret = Storable::freeze($_[1]); #} defined($ret) ? $ret : undef; } # # Deserialize and de-reference # sub deserialize { my $ret = Storable::thaw($_[1]); # Does not care whether portable defined($ret) ? $ret : undef; } 1; __END__ # =head1 NAME Data::Serializer::Storable - Creates bridge between Data::Serializer and Storable =head1 SYNOPSIS use Data::Serializer::Storable; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2001 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), Data::Dumper(3). =cut YAML.pm000444000764000764 166612205015356 20406 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::YAML; BEGIN { @Data::Serializer::YAML::ISA = qw(Data::Serializer) } use warnings; use strict; use YAML; use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { return Dump($_[1]); } sub deserialize { return Load($_[1]); } 1; __END__ # =head1 NAME Data::Serializer::YAML - Creates bridge between Data::Serializer and YAML =head1 SYNOPSIS use Data::Serializer::YAML; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Florian Helmberger =head1 COPYRIGHT Copyright 2002 by Florian Helmberger. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), Data::Serializer(3), YAML(3). =cut JSON.pm000444000764000764 222112205015356 20401 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::JSON; BEGIN { @Data::Serializer::JSON::ISA = qw(Data::Serializer) } use warnings; use strict; use JSON; use vars qw($VERSION @ISA); $VERSION = '0.04'; sub serialize { return JSON->VERSION < 2 ? JSON->new->objToJson($_[1]) : JSON->new->utf8->encode($_[1]); } sub deserialize { #return JSON->VERSION < 2 ? JSON->new->jsonToObj($_[1]) : JSON->new->decode($_[1]); $_[1] and return JSON->VERSION < 2 ? JSON->new->jsonToObj($_[1]) : JSON->new->utf8->decode($_[1]); } 1; __END__ =head1 NAME Data::Serializer::JSON - Creates bridge between Data::Serializer and JSON =head1 SYNOPSIS use Data::Serializer::JSON; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Naoya Ito Patch to JSON 2 by Makamaka =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), Data::Serializer(3), JSON(3). =cut Cookbook.pm000555000764000764 1073612205015356 21433 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::Cookbook; use warnings; use strict; use vars ('$VERSION'); $VERSION = '0.05'; 1; __END__; #Documentation follows =pod =head1 NAME Cookbook - Examples of how to use Data::Serializer =head1 DESCRIPTION B is a collection of solutions for using B. =head1 CONVENTIONS Unless otherwise specified, all examples can be assumed to begin with: use Data::Serializer; my $serializer = Data::Serializer->new(); Some examples will show different arguments to the B method, where specified simply use that line instead of the simple form above. =head1 CONVENTIONS for Raw Access Fort hose who want a straight pass through to the underlying serializer, where nothing else is done (no encoding, encryption, compression, etc) there is L. These begin like this: use Data::Serializer::Raw; my $raw_serializer = Data::Serializer::Raw->new(); =head1 Encrypting your data You wish to encrypt your data structure, so that it can only be decoded by someone who shares the same key. =head2 Solution $serializer->secret('mysecret'); my $encrypted_hashref = $serializer->serializer($hash); ... (in other program) ... $serializer->secret('mysecret'); my $clear_hash = $serializer->deserializer($encrypted_hash); Note: You will have to have the Crypt::CBC module installed for this to work. =head1 Compressing your data You wish to compress your data structure to cut down on how much disk space it will take up. =head2 Solution $serializer->compress(1); my $compressed_hashref = $serializer->serializer($hash); ... (in other program) ... my $clear_hash = $serializer->deserializer($compressed_hash); Note: You will have to have the Compress::Zlib module installed for this to work. Your mileage will vary dramatically depending on what serializer you use. Some serializers are already fairly compact. =head1 You want to read in data serialized outside of Data::Serializer You need to write a program that can read in data serialized in a format other than Data::Serializer. For example you need to be able to be able to process data serialized by XML::Dumper. =head2 Solution use Data::Serializer::Raw; my $xml_raw_serializer = Data::Serializer::Raw->(serializer => 'XML::Dumper'); my $hash_ref = $xml_raw_serializer->deserialize($xml_data); =head1 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 than Data::Serializer. Or said more generically you need to write out data in the format native to the underlying serializer. For our example we will be exporting data using XML::Dumper format. =head2 Solution ues Data::Serializer::Raw; my $xml_raw_serializer = Data::Serializer::Raw->(serializer => 'XML::Dumper'); my $xml_data = $xml_raw_serializer->serialize($hash_ref); =head1 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. =head2 Solution use Data::Serializer::Raw; my $xml_raw_serializer = Data::Serializer::Raw->(serializer => 'XML::Dumper'); my $php_raw_serializer = Data::Serializer::Raw->(serializer => 'PHP::Serialization'); my $hash_ref = $php_raw_serializer->deserialize($php_data); my $xml_data = $xml_raw_serializer->serialize($hash_ref); =head1 Keeping data persistent between executions of a program. You have a program that you run every 10 minutes, it uses SNMP to pull some counters from one of your routers. You want your program to keep the counters from the last run so that it can see how much traffic has passed over a link since it last ran. =head2 Solution # path to store our serialized data # be paranoid, use full paths my $last_run_datafile = '/full/path/to/file/lastrun.data'; #We keep our data as a hash reference my $last_data = $serializer->retrieve($last_run_datafile); #Pull in our new data through 'pull_data()'; my $new_data = query_router($router); #run comparison code run_comparison($last_data,$new_data); $serializer->store($new_data); =head1 AUTHOR Neil Neely >. =head1 COPYRIGHT Copyright (c) 2001-2011 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. =head1 SEE ALSO =over 4 =item L =item L =back =cut Persistent.pm000444000764000764 445212205015356 22000 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::Persistent; use warnings; use strict; use vars qw($VERSION @ISA); use IO::File; use Carp; $VERSION = '0.01'; sub _store { my $self = (shift); my $data = (shift); my $file_or_fh = (shift); if (ref($file_or_fh)) { #it is a file handle so print straight to it print $file_or_fh $self->{parent}->serialize($data), "\n"; #We didn't open the filehandle, so we shouldn't close it. } else { #it is a file, so open it my ($mode,$perm) = @_; unless (defined $mode) { $mode = O_CREAT|O_WRONLY; } unless (defined $perm) { $perm = 0600; } my $fh = new IO::File; $fh->open($file_or_fh, $mode,$perm) || croak "Cannot write to $file_or_fh: $!"; print $fh $self->{parent}->serialize($data), "\n"; $fh->close(); } } sub _retrieve { my $self = (shift); my $file_or_fh = (shift); if (ref($file_or_fh)) { #it is a file handle so read straight from it my $input = join('', <$file_or_fh>); chomp($input); return $self->{parent}->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 = join('', <$fh>); chomp($input); $fh->close; return $self->{parent}->deserialize($input); } } 1; __END__ =pod =head1 NAME Data::Serializer::Persistent - Provide means of persistently storing serialized data in a file =head1 SYNOPSIS use Data::Serializer::Persistent =head1 DESCRIPTION Used internally to L, does not currently have any public methods =head1 EXAMPLES =over 4 =item Please see L =back =head1 METHODS =head1 AUTHOR Neil Neely >. http://neil-neely.blogspot.com/ =head1 BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer =head1 COPYRIGHT AND LICENSE Copyright (c) 2011 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 your option, any later version of Perl 5 you may have available. See http://www.perl.com/language/misc/Artistic.html =head1 SEE ALSO perl(1), Data::Serializer(3), IO::File(3). =cut Bencode.pm000444000764000764 231512205015356 21173 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::Bencode; BEGIN { @Data::Serializer::Bencode::ISA = qw(Data::Serializer) } use warnings; use strict; use Bencode; use vars qw($VERSION @ISA); $VERSION = '0.03'; sub serialize { return Bencode::bencode($_[1]); } sub deserialize { return Bencode::bdecode($_[1]); } 1; __END__ =head1 NAME Data::Serializer::Bencode - Creates bridge between Data::Serializer and Bencode =head1 SYNOPSIS use Data::Serializer::Bencode; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely >. http://neil-neely.blogspot.com/ =head1 BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer =head1 COPYRIGHT AND LICENSE Copyright (c) 2011 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 your option, any later version of Perl 5 you may have available. =head1 SEE ALSO perl(1), Data::Serializer(3), Bencode(3). =cut FreezeThaw.pm000444000764000764 177612205015356 21712 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::FreezeThaw; BEGIN { @Data::Serializer::FreezeThaw::ISA = qw(Data::Serializer) } use warnings; use strict; use FreezeThaw; use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { return FreezeThaw::freeze($_[1]); } sub deserialize { my ($obj) = FreezeThaw::thaw($_[1]); return $obj; } 1; __END__ # =head1 NAME Data::Serializer::FreezeThaw - Creates bridge between Data::Serializer and FreezeThaw =head1 SYNOPSIS use Data::Serializer::FreezeThaw; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2001 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), FreezeThaw(3). =cut Raw.pm000444000764000764 1774012205015356 20415 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializerpackage Data::Serializer::Raw; use warnings; use strict; use vars qw($VERSION); use Carp; $VERSION = '0.02'; #Global cache of modules we've loaded my %_MODULES; my %_fields = ( serializer => 'Data::Dumper', options => {}, ); sub new { my ($class, %args) = @_; my $dataref = {%_fields}; foreach my $field (keys %_fields) { $dataref->{$field} = $args{$field} if exists $args{$field}; } my $self = $dataref; bless $self, $class; #initialize serializer $self->_serializer_obj(); return $self; } sub serializer { my $self = (shift); my $return = $self->{serializer}; if (@_) { $self->{serializer} = (shift); #reinitialize serializer object $self->_serializer_obj(1); } return $return; } sub options { my $self = (shift); my $return = $self->{options}; if (@_) { $self->{options} = (shift); #reinitialize serializer object $self->_serializer_obj(1); } return $return; } sub _persistent_obj { my $self = (shift); return $self->{persistent_obj} if (exists $self->{persistent_obj}); $self->_module_loader('Data::Serializer::Persistent'); my $persistent_obj = { parent => $self }; bless $persistent_obj, "Data::Serializer::Persistent"; $self->{persistent_obj} = $persistent_obj; return $persistent_obj; } sub store { my $self = (shift); my $persistent = $self->_persistent_obj(); $persistent->_store(@_); } sub retrieve { my $self = (shift); my $persistent = $self->_persistent_obj(); $persistent->_retrieve(@_); } sub _module_loader { my $self = (shift); my $module_name = (shift); return if (exists $_MODULES{$module_name}); if (@_) { $module_name = (shift) . "::$module_name"; } my $package = $module_name; $package =~ s|::|/|g; $package .= ".pm"; eval { require $package }; if ($@) { carp "Data::Serializer error: " . "Please make sure $package is a properly installed package.\n"; return undef; } $_MODULES{$module_name} = 1; } sub _serializer_obj { my $self = (shift); #if anything is passed in remove previous obj so we will regenerate it if (@_) { delete $self->{serializer_obj}; } #Return cached serializer object if it exists return $self->{serializer_obj} if (exists $self->{serializer_obj}); my $method = $self->{serializer}; $self->_module_loader($method,"Data::Serializer"); #load in serializer module if necessary $self->{serializer_obj}->{options} = $self->{options}; bless $self->{serializer_obj}, "Data::Serializer::$method"; } sub serialize { my $self = (shift); my @input = @_; return $self->_serializer_obj->serialize(@input); } sub deserialize { my $self = (shift); my $input = (shift); return $self->_serializer_obj->deserialize($input); } 1; __END__ =pod =head1 NAME Data::Serializer::Raw - Provides unified raw interface to perl serializers =head1 SYNOPSIS use Data::Serializer::Raw; $obj = Data::Serializer::Raw->new(); $obj = Data::Serializer::Raw->new(serializer => 'Storable'); $serialized = $obj->serialize({a => [1,2,3],b => 5}); $deserialized = $obj->deserialize($serialized); print "$deserialized->{b}\n"; =head1 DESCRIPTION Provides a unified interface to the various serializing modules currently available. This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) =head1 EXAMPLES =over 4 =item Please see L =back =head1 METHODS =over 4 =item B - constructor $obj = Data::Serializer::Raw->new(); $obj = Data::Serializer::Raw->new( serializer => 'Data::Dumper', options => {}, ); B is the constructor object for Data::Serializer::Raw objects. =over 4 =item The default I is C =item The default I is C<{}> (pass nothing on to serializer) =back =item B - serialize reference $serialized = $obj->serialize({a => [1,2,3],b => 5}); This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) =item B - deserialize reference $deserialized = $obj->deserialize($serialized); This is a straight pass through to the underlying serializer, nothing else is done. (no encoding, encryption, compression, etc) =item B - change the serializer Currently supports the following serializers: =over 4 =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =back Default is to use Data::Dumper. Each serializer has its own caveat's about usage especially when dealing with cyclical data structures or CODE references. Please see the appropriate documentation in those modules for further information. =item B - pass options through to underlying serializer Currently is only supported by L, and L. my $obj = Data::Serializer::Raw->new(serializer => 'Config::General', options => { -LowerCaseNames => 1, -UseApacheInclude => 1, -MergeDuplicateBlocks => 1, -AutoTrue => 1, -InterPolateVars => 1 }, ) or die "$!\n"; or my $obj = Data::Serializer::Raw->new(serializer => 'XML::Dumper', options => { dtd => 1, } ) or die "$!\n"; =item B - serialize data and write it to a file (or file handle) $obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]); or $obj->store({a => [1,2,3],b => 5},$fh); Serializes the reference specified using the B method and writes it out to the specified file or filehandle. If a file path is specified you may specify an optional mode and permission as the next two arguments. See L for examples. Trips an exception if it is unable to write to the specified file. =item B - read data from file (or file handle) and return it after deserialization my $ref = $obj->retrieve($file); or my $ref = $obj->retrieve($fh); Reads first line of supplied file or filehandle and returns it deserialized. =back =head1 AUTHOR Neil Neely >. http://neil-neely.blogspot.com/ =head1 BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer =head1 COPYRIGHT AND LICENSE Copyright (c) 2011 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 your option, any later version of Perl 5 you may have available. See http://www.perl.com/language/misc/Artistic.html =head1 ACKNOWLEDGEMENTS Peter Makholm took the time to profile L and pointed out the value of having a very lean implementation that minimized overhead and just used the raw underlying serializers. =head1 SEE ALSO perl(1), Data::Serializer(3). =cut Config000755000764000764 012205015356 20345 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerGeneral.pm000444000764000764 270312205015356 22417 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/Configpackage Data::Serializer::Config::General; BEGIN { @Data::Serializer::Config::General::ISA = qw(Data::Serializer) } use warnings; use strict; use Config::General; use vars qw($VERSION @ISA); $VERSION = '0.02'; sub options { return (shift)->{options}; } sub serialize { my $self = (shift); my $ref = (shift); return (new Config::General(%{$self->options()}, -ConfigHash => $ref))->save_string(); } sub deserialize { my $self = (shift); my $ref = (shift); my %hash = (new Config::General(%{$self->options()}, -String => $ref))->getall(); return \%hash; } 1; __END__ =head1 NAME Data::Serializer::Config::General - Creates bridge between Data::Serializer and Config::General =head1 SYNOPSIS use Data::Serializer::Config::General; =head1 DESCRIPTION Module is used internally to Data::Serializer =head1 METHODS =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =item B - Pass options through to underlying serializer =back =head1 CAVEAT Base data structure to serialize must be a hash reference =head1 AUTHOR Thomas Linden =head1 COPYRIGHT Copyright 2002 by Thomas Linden. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), Data::Serializer(3), Config::General(3) =cut PHP000755000764000764 012205015356 17567 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerSerialization.pm000444000764000764 211112205015356 23072 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/PHPpackage Data::Serializer::PHP::Serialization; BEGIN { @Data::Serializer::PHP::Serialization::ISA = qw(Data::Serializer) } use warnings; use strict; use PHP::Serialization qw(); use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { return PHP::Serialization::serialize($_[1]); } sub deserialize { return PHP::Serialization::unserialize($_[1]); } 1; __END__ # =head1 NAME Data::Serializer::PHP::Serialization - Creates bridge between Data::Serializer and PHP::Serialization =head1 SYNOPSIS use Data::Serializer::PHP::Serialization; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2004 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), PHP::Serialization(3). =cut XML000755000764000764 012205015356 17600 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerDumper.pm000444000764000764 250412205015356 21530 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/XMLpackage Data::Serializer::XML::Dumper; BEGIN { @Data::Serializer::XML::Dumper::ISA = qw(Data::Serializer) } use warnings; use strict; use XML::Dumper qw(); use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { my $self = (shift); my $xml = new XML::Dumper; if (defined $self->{options} && $self->{options}->{dtd}) { $xml->dtd; } return $xml->pl2xml( (shift) ); } sub deserialize { my $xml = new XML::Dumper; return $xml->xml2pl($_[1]); } 1; __END__ # =head1 NAME Data::Serializer::XML::Dumper - Creates bridge between Data::Serializer and XML::Dumper =head1 SYNOPSIS use Data::Serializer::XML::Dumper; =head1 DESCRIPTION Module is used internally to Data::Serializer The only option currently supported is B. This just calls the dtd method of XML::Dumper prior to serializing the data. See XML::Dumper(3) for details. =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2004 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), XML::Dumper(3). =cut Simple.pm000444000764000764 262312205015356 21527 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/XMLpackage Data::Serializer::XML::Simple; BEGIN { @Data::Serializer::XML::Simple::ISA = qw(Data::Serializer) } use warnings; use strict; use XML::Simple qw(); use vars qw($VERSION @ISA); $VERSION = '0.03'; sub serialize { my $self = (shift); my %options = ref $self->{options} eq 'HASH' ? %{$self->{options}}: (); my $xml = XML::Simple->new(keyattr => [ 'name'], %options); return $xml->XMLout( (shift) ); } sub deserialize { my $self = (shift); my %options = ref $self->{options} eq 'HASH' ? %{$self->{options}}: (); my $xml = XML::Simple->new(keyattr => [ 'name'], %options); return $xml->XMLin( (shift) ); } 1; __END__ # =head1 NAME Data::Serializer::XML::Simple - Creates bridge between Data::Serializer and XML::Simple =head1 SYNOPSIS use Data::Serializer::XML::Simple; =head1 DESCRIPTION Module is used internally to Data::Serializer Any options are passed through to XML::Simple. See XML::Simple(3) for details. =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2004 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), XML::Simple(3). =cut Convert000755000764000764 012205015356 20560 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerBencode.pm000444000764000764 243612205015356 22617 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/Convertpackage Data::Serializer::Convert::Bencode; BEGIN { @Data::Serializer::Convert::Bencode::ISA = qw(Data::Serializer) } use warnings; use strict; use Convert::Bencode; use vars qw($VERSION @ISA); $VERSION = '0.03'; sub serialize { return Convert::Bencode::bencode($_[1]); } sub deserialize { return Convert::Bencode::bdecode($_[1]); } 1; __END__ =head1 NAME Data::Serializer::Convert::Bencode - Creates bridge between Data::Serializer and Convert::Bencode =head1 SYNOPSIS use Data::Serializer::Convert::Bencode; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely >. http://neil-neely.blogspot.com/ =head1 BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer =head1 COPYRIGHT AND LICENSE Copyright (c) 2011 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 your option, any later version of Perl 5 you may have available. =head1 SEE ALSO perl(1), Data::Serializer(3), Convert::Bencode(3). =cut Bencode_XS.pm000444000764000764 247112205015356 23230 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/Convertpackage Data::Serializer::Convert::Bencode_XS; BEGIN { @Data::Serializer::Convert::Bencode_XS::ISA = qw(Data::Serializer) } use warnings; use strict; use Convert::Bencode_XS; use vars qw($VERSION @ISA); $VERSION = '0.03'; sub serialize { return Convert::Bencode_XS::bencode($_[1]); } sub deserialize { return Convert::Bencode_XS::bdecode($_[1]); } 1; __END__ =head1 NAME Data::Serializer::Convert::Bencode_XS - Creates bridge between Data::Serializer and Convert::Bencode_XS =head1 SYNOPSIS use Data::Serializer::Convert::Bencode_XS; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely >. http://neil-neely.blogspot.com/ =head1 BUGS Please report all bugs here: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer =head1 COPYRIGHT AND LICENSE Copyright (c) 2011 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 your option, any later version of Perl 5 you may have available. =head1 SEE ALSO perl(1), Data::Serializer(3), Convert::Bencode_XS(3). =cut JSON000755000764000764 012205015356 17711 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerSyck.pm000444000764000764 166312205015356 21323 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/JSONpackage Data::Serializer::JSON::Syck; BEGIN { @Data::Serializer::JSON::Syck::ISA = qw(Data::Serializer) } use warnings; use strict; use JSON::Syck; use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { return JSON::Syck::Dump($_[1]); } sub deserialize { return JSON::Syck::Load($_[1]); } 1; __END__ =head1 NAME Data::Serializer::JSON::Syck - Creates bridge between Data::Serializer and JSON::Syck =head1 SYNOPSIS use Data::Serializer::JSON::Syck; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Naoya Ito =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), Data::Serializer(3), JSON::Syck(3). =cut Data000755000764000764 012205015356 20011 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerDumper.pm000444000764000764 354212205015356 21744 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/Datapackage Data::Serializer::Data::Dumper; BEGIN { @Data::Serializer::Data::Dumper::ISA = qw(Data::Serializer) } use warnings; use strict; use Carp; use Data::Dumper; use vars qw($VERSION @ISA); $VERSION = '0.05'; # # Create a Data::Dumper serializer object. # sub serialize { my $self = shift; my ($val) = @_; return undef unless defined $val; local $Data::Dumper::Indent = 0; local $Data::Dumper::Purity = 1; local $Data::Dumper::Terse = 1; #return Data::Dumper::Dumper($val); #Eval'ing this statement will leave $M defined return Data::Dumper->Dump([$val],['M']); } # # # Shamelessly copied from Data::Dumper::Serializer::Data::Dumper # With apologies to relevant parties for not getting the # self-referencing right the first time # sub deserialize { my $self = shift; my ($val) = @_; return undef unless defined $val; my $M = ""; # Disambiguate hashref (perl may treat it as a block) my $N = eval($val =~ /^\{/ ? '+'.$val : $val); return $M ? $M : $N unless $@; carp "Data::Serializer error: $@\twhile evaluating:\n $val"; } # avoid used only once warnings { local $Data::Dumper::Terse; } 1; __END__ # =head1 NAME Data::Serializer::Data::Dumper - Creates bridge between Data::Serializer and Data::Dumper =head1 SYNOPSIS use Data::Serializer::Data::Dumper; =head1 DESCRIPTION Module is used internally to Data::Serializer =head1 METHODS =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2001 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), Data::Dumper(3). =cut Denter.pm000444000764000764 235112205015356 21726 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/Datapackage Data::Serializer::Data::Denter; BEGIN { @Data::Serializer::Data::Denter::ISA = qw(Data::Serializer) } use warnings; use strict; use Carp; use Data::Denter; use vars qw($VERSION @ISA); $VERSION = '0.02'; # # Create a Data::Denter serializer object. # sub serialize { my $self = shift; my ($val) = @_; return undef unless defined $val; return $val unless ref($val); return Data::Denter::Indent($val); } sub deserialize { my $self = shift; my ($val) = @_; return undef unless defined $val; return Data::Denter::Undent($val); } 1; __END__ # =head1 NAME Data::Serializer::Data::Denter - Creates bridge between Data::Serializer and Data::Denter =head1 SYNOPSIS use Data::Serializer::Data::Denter; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2002 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), Data::Denter(3). =cut Taxi.pm000444000764000764 177712205015356 21425 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/Datapackage Data::Serializer::Data::Taxi; BEGIN { @Data::Serializer::Data::Taxi::ISA = qw(Data::Serializer) } use warnings; use strict; use Data::Taxi; use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { return Data::Taxi::freeze($_[1]); } sub deserialize { my ($obj) = Data::Taxi::thaw($_[1]); return $obj; } 1; __END__ # =head1 NAME Data::Serializer::Data::Taxi - Creates bridge between Data::Serializer and Data::Taxi =head1 SYNOPSIS use Data::Serializer::Data::Taxi; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely =head1 COPYRIGHT Copyright 2001 by 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. =head1 SEE ALSO perl(1), Data::Serializer(3), Data::Taxi(3). =cut YAML000755000764000764 012205015356 17702 5ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/SerializerSyck.pm000444000764000764 166312205015356 21314 0ustar00neilneil000000000000Data-Serializer-0.60/lib/Data/Serializer/YAMLpackage Data::Serializer::YAML::Syck; BEGIN { @Data::Serializer::YAML::Syck::ISA = qw(Data::Serializer) } use warnings; use strict; use YAML::Syck; use vars qw($VERSION @ISA); $VERSION = '0.02'; sub serialize { return YAML::Syck::Dump($_[1]); } sub deserialize { return YAML::Syck::Load($_[1]); } 1; __END__ =head1 NAME Data::Serializer::YAML::Syck - Creates bridge between Data::Serializer and YAML::Syck =head1 SYNOPSIS use Data::Serializer::YAML::Syck; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B - Wrapper to normalize serializer method name =item B - Wrapper to normalize deserializer method name =back =head1 AUTHOR Naoya Ito =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), Data::Serializer(3), YAML::Syck(3). =cut t000755000764000764 012205015356 13653 5ustar00neilneil000000000000Data-Serializer-0.6001-11-YAML-Syck.t000444000764000764 236212205015355 16305 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(YAML::Syck)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: YAML::Syck not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-15-Convert-Bencode.t000444000764000764 237612205015356 17623 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Convert::Bencode)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Convert::Bencode not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 04-02-Compress-PPMd.t000444000764000764 357112205015356 17234 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(compressppmd); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-13-JSON-Syck.t000444000764000764 236212205015356 16317 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(JSON::Syck)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: JSON::Syck not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-12-JSON.t000444000764000764 234612205015356 15411 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(JSON)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: JSON not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-08-PHP-Serialization.t000444000764000764 240212205015356 20100 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(PHP::Serialization)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: PHP::Serialization not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 02-02-Fast-Raw.t000444000764000764 357112205015356 16265 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer::Raw; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(objraw); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-02-Data-Denter.t000444000764000764 235712205015356 16731 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Data::Denter)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Data::Denter not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 07-01-MD5-Digest.t000444000764000764 356012205015356 16445 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(md5); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-05-Config-General.t000444000764000764 240212205015356 17413 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Config::General)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Config::General not installed'); exit; } my @types = qw(basic cgopt); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-01-Data-Dumper.t000444000764000764 235712205015356 16743 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Data::Dumper)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Data::Dumper not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 03-Non-Portable.t000444000764000764 357112205015356 16723 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(non-portable); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-06-YAML.t000444000764000764 234612205015356 15405 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(YAML)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: YAML not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 07-03-SHA-256-Digest.t000444000764000764 356412205015355 17012 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(sha-256); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-03-Storable.t000444000764000764 235612205015356 16414 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Storable)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Storable not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 08-Store-Retrieve.t000444000764000764 363012205015355 17302 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(fh-storage storage rawstorage1 rawstorage2); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 04-01-Compress-Zlib.t000444000764000764 357112205015356 17333 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(compresszlib); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 07-02-SHA1-Digest.t000444000764000764 356112205015355 16555 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(sha1); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 09-Feature-Combos.t000444000764000764 702012205015356 17235 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(raw basic non-portable encoding encryption compresszlib compressppmd storage); find_features($T,@types); my @feature_combos; push(@feature_combos, "non-portable encryption") if ($found_type{'encryption'}); push(@feature_combos, "non-portable compresszlib") if ($found_type{'compresszlib'}); push(@feature_combos, "non-portable compressppmd") if ($found_type{'compressppmd'}); if ($found_type{'compresszlib'} && $found_type{'encryption'}) { push(@feature_combos, "encryption compresszlib"); push(@feature_combos, "non-portable encryption compresszlib"); } if ($found_type{'compressppmd'} && $found_type{'encryption'}) { push(@feature_combos, "encryption compressppmd"); push(@feature_combos, "non-portable encryption compressppmd"); } push(@feature_combos, "encoding compresszlib") if ($found_type{'compresszlib'} && $found_type{'encoding'}); push(@feature_combos, "encoding compressppmd") if ($found_type{'compressppmd'} && $found_type{'encoding'}); push(@feature_combos, "encoding encryption compresszlib") if ($found_type{'compresszlib'} && $found_type{'encryption'} && $found_type{'encoding'}); push(@feature_combos, "encoding encryption compressppmd") if ($found_type{'compressppmd'} && $found_type{'encryption'} && $found_type{'encoding'}); push(@feature_combos, "encoding encryption compresszlib storage") if ($found_type{'compresszlib'} && $found_type{'encryption'} && $found_type{'encoding'} && $found_type{'storage'}); push(@feature_combos, "encoding encryption compressppmd storage") if ($found_type{'compressppmd'} && $found_type{'encryption'} && $found_type{'encoding'} && $found_type{'storage'}); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@feature_combos) { $testcount += $value; } } } unless ($testcount) { #We trim the types that are always present out of @types #to keep the display helpful my @trim = grep {!/raw|basic|non-portable/} @types; $T->begin("0 # Skipped: @trim not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@feature_combos) { run_test($T,$serializer,$test,$type); } } } 01-09-XML-Simple.t000444000764000764 346412205015356 16537 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(XML::Simple)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } unless (@serializers) { $T->begin('0 # Skipped: XML::Simple not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-14-Bencode.t000444000764000764 235412205015356 16200 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Bencode)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Bencode not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 02-01-Orig-Raw.t000444000764000764 357112205015356 16267 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(raw newraw); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 06-B64-Encoding.t000444000764000764 356512205015356 16510 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(encoding); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-04-FreezeThaw.t000444000764000764 236212205015356 16703 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(FreezeThaw)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: FreezeThaw not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-07-XML-Dumper.t000444000764000764 240012205015355 16524 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(XML::Dumper)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: XML::Dumper not installed'); exit; } my @types = qw(basic xmldumpopt); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 01-10-Data-Taxi.t000444000764000764 235312205015356 16410 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Data::Taxi)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Data::Taxi not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } serializer-testlib000444000764000764 6304112205015356 17574 0ustar00neilneil000000000000Data-Serializer-0.60/tpackage My::TestObj; #use utf8; #Need to play nice on different Filesystems! use File::Spec; my $file_path = File::Spec->catfile('t', 'datastore.txt'); sub new { my $class = (shift); my $self = {}; $self->{monkey} = [qw(a b c d e f g h)]; bless $self, $class; return $self; } sub data_test { my $self = (shift); return $self->{monkey}->[4]; } sub package_test { return ref( (shift) ); } package main; use IO::File; $object_package = 'My::TestObj'; %counts = ( simpleobject => 2, simplescalar => 1, trickyscalar => 1, simplescalarref => 1, simplearray => 1, complexarray => 2, selfrefarray => 1, simplehash => 1, utf8hash => 2, complexhash => 3, selfrefhash => 1, ); %testrefs = ( simpleobject => My::TestObj->new(), trickyscalar => '{foo=>"bar"}', simplescalar => 'pointless', simplescalarref => \'pointless', simplehash => { alpha => 1, beta => 2 }, simplearray => [qw ( one two three ) ], complexarray => ['one', {alpha => 1, beta => 2},['bob','dole']], selfrefarray => ['one', {alpha => 1, beta => 2},['bob','dole']], complexhash => { apple => [qw ( one two three ) ], orange => { alpha => 1, beta => 2 }, pear => { chain => { hippie => 'smelly', donkey => 'worship', }, monkey => 3, }, }, selfrefhash => { apple => [qw ( one two three ) ], }, ); { $testrefs{utf8hash} = { alpha => q|“water” and “road”|, beta => q|mañana| }; } $testrefs{selfrefhash}->{pear} = $testrefs{selfrefhash}->{apple}; $testrefs{selfrefarray}->[3] = $testrefs{selfrefarray}->[1]; %serializers = ( 'Data::Dumper' => { simpleobject => $counts{simpleobject}, simplescalar => $counts{simplescalar}, simplescalarref => $counts{simplescalarref}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Data::Taxi' => { simpleobject => $counts{simpleobject}, # simplescalar => $counts{simplescalar}, #doesn't support this simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Data::Denter' => { simpleobject => $counts{simpleobject}, simplescalar => $counts{simplescalar}, simplescalarref => $counts{simplescalarref}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Storable' => { simpleobject => $counts{simpleobject}, simplescalar => 0, #Storable cannot serialize scalars trickyscalar => 0, #Storable cannot serialize scalars simplescalarref => $counts{simplescalarref}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'FreezeThaw' => { simpleobject => $counts{simpleobject}, simplescalar => $counts{simplescalar}, simplescalarref => $counts{simplescalarref}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Config::General' => { simpleobject => 0, simplescalar => 0, simplearray => 0, complexarray => 0, selfrefarray => 0, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'YAML' => { simpleobject => $counts{simpleobject}, simplescalar => $counts{simplescalar}, simplescalarref => $counts{simplescalarref}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'YAML::Syck' => { simpleobject => $counts{simpleobject}, simplescalar => $counts{simplescalar}, simplescalarref => $counts{simplescalarref}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'JSON' => { simpleobject => 0, #JSON doesn't do objects simplescalar => 0, #JSON doesn't do scalars simplescalarref => 0, #JSON doesn't do scalars trickyscalar => 0, #JSON doesn't do scalars simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'JSON::Syck' => { simpleobject => 0, #JSON doesn't do objects simplescalar => 0, #JSON doesn't do scalars simplescalarref => 0, #JSON doesn't do scalars trickyscalar => 0, #JSON doesn't do scalars simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, #selfrefarray => $counts{selfrefarray}, #selfrefhash => $counts{selfrefhash}, selfrefarray => 0, #JSON no longer supports "circular references" selfrefhash => 0, #JSON no longer supports "circular references" }, 'XML::Dumper' => { simpleobject => $counts{simpleobject}, simplescalar => $counts{simplescalar}, simplescalarref => $counts{simplescalarref}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => 0, #Chokes on UTF8 complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'XML::Simple' => { simpleobject => 0, simplescalar => 0, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => 0, #Chokes on UTF8 sometimes complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'PHP::Serialization' => { simpleobject => 0, simplescalar => 0, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Bencode' => { simpleobject => 0, #Bencode does not support serializing objects simplescalarref => 0, #Bencode does not support serializing saclar references simplescalar => $counts{simplescalar}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Convert::Bencode' => { simpleobject => 0, #Convert::Bencode does not support serializing objects simplescalarref => 0, #Convert::Bencode does not support serializing saclar references simplescalar => $counts{simplescalar}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, 'Convert::Bencode_XS' => { simpleobject => 0, #Convert::Bencode_XS does not support serializing objects simplescalarref => 0, #Convert::Bencode_XS does not support serializing saclar references simplescalar => $counts{simplescalar}, trickyscalar => $counts{trickyscalar}, simplearray => $counts{simplearray}, complexarray => $counts{complexarray}, selfrefarray => $counts{selfrefarray}, simplehash => $counts{simplehash}, utf8hash => $counts{utf8hash}, complexhash => $counts{complexhash}, selfrefhash => $counts{selfrefhash}, }, ); %features = ( 'objraw' => [], 'raw' => [], 'rawnew' => [], 'non-portable' => [], 'basic' => [], 'cgopt' => [], 'xmldumpopt' => [], 'encryption' => [qw (Crypt::CBC Crypt::Blowfish)], 'compresszlib' => [qw (Compress::Zlib)], 'compressppmd' => [qw (Compress::PPMd)], 'encoding' => [qw (MIME::Base64)], 'md5' => [qw (Crypt::CBC Crypt::Blowfish Digest::MD5)], 'sha1' => [qw (Crypt::CBC Crypt::Blowfish Digest::SHA1)], 'sha-256' => [qw (Crypt::CBC Crypt::Blowfish Digest::SHA)], ); sub run_test { my ($T,$serializer,$test,$features) = @_; $T->msg("Test $serializer $test $features"); # message for the log my $obj; my @features = (split(" ", $features)); if (grep {/^objraw$/} @features) { $obj = Data::Serializer::Raw->new(serializer=>$serializer); } else { $obj = Data::Serializer->new(serializer=>$serializer); } foreach my $feature (@features) { if ($feature eq 'basic') { #do nothing special } elsif ($feature eq 'non-portable') { #make sure we work without ascii armoring $obj->portable(0); } elsif ($feature eq 'encryption') { #setup a secret so we use encryption on this run $obj->secret('test'); } elsif ($feature eq 'md5') { #only relevant if we have a secret $obj->secret('test'); $obj->digester('MD5'); } elsif ($feature eq 'sha1') { #only relevant if we have a secret $obj->secret('test'); $obj->digester('SHA-256'); } elsif ($feature eq 'sha-256') { #only relevant if we have a secret $obj->secret('test'); $obj->digester('SHA-256'); } elsif ($feature eq 'compresszlib') { # use compression $obj->compress(1); $obj->compressor("Compress::Zlib"); } elsif ($feature eq 'compressppmd') { # use compression $obj->compress(1); $obj->compressor("Compress::PPMd"); } elsif ($feature eq 'encoding') { # test alternate encoding $obj->encoding('b64'); } elsif ($feature eq 'cgopt') { # test options for Config::General $obj->options( { -LowerCaseNames => 1, -UseApacheInclude => 1, -MergeDuplicateBlocks => 1, -AutoTrue => 1, -InterPolateVars => 1 }); } elsif ($feature eq 'xmldumpopt') { # test options for XML::Dumper $obj->options( { dtd => 1, }); } } my ($frozen,$thawed); if (grep {/^objraw$/} @features) { $frozen = $obj->serialize($testrefs{$test}); $thawed = $obj->deserialize($frozen); }elsif (grep {/^raw$/} @features) { $frozen = $obj->raw_serialize($testrefs{$test}); $thawed = $obj->raw_deserialize($frozen); } elsif (grep {/^rawnew$/} @features) { my $newobj = Data::Serializer->new( serializer=>$serializer, raw => 1, #portable=>undef, #serializer_token=>undef, ); $frozen = $obj->serialize($testrefs{$test}); $thawed = $obj->deserialize($frozen); } elsif (grep {/fh-storage/} @features) { my $fh = IO::File->new($file_path, O_CREAT|O_WRONLY, 0600); $obj->store($testrefs{$test},$fh); $fh->close(); $fh = IO::File->new($file_path, O_RDONLY); $thawed = $obj->retrieve($fh); $fh->close(); unlink($file_path); } elsif (grep {/storage/} @features) { $obj->store($testrefs{$test},$file_path); $thawed = $obj->retrieve($file_path); unlink($file_path); } elsif (grep {/rawstorage1/} @features) { my $newobj = Data::Serializer->new( serializer=>$serializer, raw => 1, ); $newobj->store($testrefs{$test},$file_path); $thawed = $newobj->retrieve($file_path); unlink($file_path); } elsif (grep {/rawstorage2/} @features) { my $newobj = Data::Serializer::Raw->new( serializer=>$serializer, ); $newobj->store($testrefs{$test},$file_path); $thawed = $newobj->retrieve($file_path); unlink($file_path); } else { $frozen = $obj->serialize($testrefs{$test}); $thawed = $obj->deserialize($frozen); } if ($test eq 'simplescalar') { $T->ok_eq($testrefs{$test}, $thawed,'scalar'); }elsif ($test eq 'trickyscalar') { $T->ok_eq($testrefs{$test}, $thawed,'tricky scalar'); }elsif ($test eq 'simplescalarref') { $T->ok_eq(${$testrefs{$test}}, ${$thawed},'simple scalar ref'); }elsif ($test eq 'simpleobject') { $T->ok_eq($testrefs{$test}->package_test(), $thawed->package_test,'object namespace'); $T->ok_eq($testrefs{$test}->data_test(), $thawed->data_test,'object data'); }elsif ($test eq 'simplearray') { $T->ok_eq($testrefs{$test}->[0], $thawed->[0],'array'); } elsif ($test eq 'complexarray') { $T->ok_eq($testrefs{$test}->[2]->[0], $thawed->[2]->[0],'array of arrays'); $T->ok_eqnum($testrefs{$test}->[1]->{alpha}, $thawed->[1]->{alpha},'array of hashes'); } elsif ($test eq 'simplehash') { $T->ok_eqnum($testrefs{$test}->{alpha}, $thawed->{alpha},'hash'); } elsif ($test eq 'utf8hash') { $T->ok_eq($testrefs{$test}->{alpha}, $thawed->{alpha},'utf8 hash'); $T->ok_eq($testrefs{$test}->{beta}, $thawed->{beta},'utf8 hash 2'); } elsif ($test eq 'complexhash') { $T->ok_eq($testrefs{$test}->{apple}->[1], $thawed->{apple}->[1],'hash of arrays'); $T->ok_eqnum($testrefs{$test}->{orange}->{alpha}, $thawed->{orange}->{alpha},'hash of hashes'); $T->ok_eq($testrefs{$test}->{pear}->{chain}->{hippie}, $thawed->{pear}->{chain}->{hippie},'hash of hash of hashes'); } elsif ($test eq 'selfrefhash') { $T->ok_eq($testrefs{$test}->{apple}->[1], $thawed->{pear}->[1],'hash self ref to internal array'); } elsif ($test eq 'selfrefarray') { $T->ok_eq($testrefs{$test}->[1]->{alpha}, $thawed->[3]->{alpha},'array self ref to internal array'); } } sub test_feature { my ($feature) = @_; foreach my $module (@{$features{$feature}}) { return 0 unless (eval "require $module"); } return 1; } sub test_serializer { my ($serializer) = @_; return 1 if (eval "require $serializer"); return 0; } sub find_features { my $T = (shift); foreach my $type (@_) { if (test_feature($type)) { $found_type{$type} = 1; $T->msg("Found feature $type"); } } } 01-16-Convert-Bencode_XS.t000444000764000764 240412205015356 20226 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (qw(Convert::Bencode_XS)) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } else { $T->msg("Serializer $serializer not found") unless (@serializers); } } unless (@serializers) { $T->begin('0 # Skipped: Convert::Bencode_XS not installed'); exit; } my @types = qw(basic); find_features($T,@types); my %tests; my $testcount; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } 05-Encryption.t000444000764000764 357012205015356 16556 0ustar00neilneil000000000000Data-Serializer-0.60/tuse lib "./t"; # to pick up a ExtUtils::TBone require "./t/serializer-testlib"; use Data::Serializer; use ExtUtils::TBone; my $T = typical ExtUtils::TBone; # standard log my @serializers; foreach my $serializer (keys %serializers) { if (eval "require $serializer") { $T->msg("Found serializer $serializer"); push(@serializers, $serializer); } } # # XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those # too, and if we don't find them, act like XML::Simple is not installed # if (grep {/^XML::Simple$/} @serializers) { if (eval "require XML::SAX") { $T->msg("Found XML::SAX to support XML::Simple"); } elsif (eval "require XML::Parser") { $T->msg("Found XML::Parser to support XML::Simple"); } else { $T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers); @serializers = grep {!/^XML::Simple$/} @serializers; } } $T->msg("No serializers found!!") unless (@serializers); my @types = qw(encryption); find_features($T,@types); my $testcount = 0; foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; $testcount += $value; } } } unless ($testcount) { $T->begin("0 # Skipped: @types not installed"); exit; } $T->begin($testcount); $T->msg("Begin Testing for @types"); # message for the log foreach my $serializer (@serializers) { while (my ($test,$value) = each %{$serializers{$serializer}}) { next unless $value; foreach my $type (@types) { next unless $found_type{$type}; run_test($T,$serializer,$test,$type); } } } ExtUtils000755000764000764 012205015355 15433 5ustar00neilneil000000000000Data-Serializer-0.60/tTBone.pm000444000764000764 3044412205015355 17162 0ustar00neilneil000000000000Data-Serializer-0.60/t/ExtUtilspackage ExtUtils::TBone; =head1 NAME ExtUtils::TBone - a "skeleton" for writing "t/*.t" test files. =head1 SYNOPSIS Include a copy of this module in your t directory (as t/ExtUtils/TBone.pm), and then write your t/*.t files like this: use lib "./t"; # to pick up a ExtUtils::TBone use ExtUtils::TBone; # Make a tester... here are 3 different alternatives: my $T = typical ExtUtils::TBone; # standard log my $T = new ExtUtils::TBone; # no log my $T = new ExtUtils::TBone "testout/Foo.tlog"; # explicit log # Begin testing, and expect 3 tests in all: $T->begin(3); # expect 3 tests $T->msg("Something for the log file"); # message for the log # Run some tests: $T->ok($this); # test 1: no real info logged $T->ok($that, # test 2: logs a comment "Is that ok, or isn't it?"); $T->ok(($this eq $that), # test 3: logs comment + vars "Do they match?", This => $this, That => $that); # That last one could have also been written... $T->ok_eq($this, $that); # does 'eq' and logs operands $T->ok_eqnum($this, $that); # does '==' and logs operands # End testing: $T->end; =head1 DESCRIPTION This module is intended for folks who release CPAN modules with "t/*.t" tests. It makes it easy for you to output syntactically correct test-output while at the same time logging all test activity to a log file. Hopefully, bug reports which include the contents of this file will be easier for you to investigate. =head1 OUTPUT =head2 Standard output Pretty much as described by C, with a special "# END" comment placed at the very end: 1..3 ok 1 not ok 2 ok 3 # END =head1 Log file A typical log file output by this module looks like this: 1..3 ** A message logged with msg(). ** Another one. 1: My first test, using test(): how'd I do? 1: ok 1 ** Yet another message. 2: My second test, using test_eq()... 2: A: The first string 2: B: The second string 2: not ok 2 3: My third test. 3: ok 3 # END Each test() is logged with the test name and results, and the test-number prefixes each line. This allows you to scan a large file easily with "grep" (or, ahem, "perl"). A blank line follows each test's record, for clarity. =head1 PUBLIC INTERFACE =cut # Globals: use strict; use vars qw($VERSION); use FileHandle; use File::Basename; # The package version, both in 1.23 style *and* usable by MakeMaker: $VERSION = substr q$Revision: 1.124 $, 10; #------------------------------ =head2 Construction =over 4 =cut #------------------------------ =item new [ARGS...] I Create a new tester. Any arguments are sent to log_open(). =cut sub new { my $self = bless { OUT =>\*STDOUT, Begin=>0, End =>0, Count=>0, }, shift; $self->log_open(@_) if @_; $self; } #------------------------------ =item typical I Create a typical tester. Use this instead of new() for most applicaitons. The directory "testout" is created for you automatically, to hold the output log file, and log_warnings() is invoked. =cut sub typical { my $class = shift; my ($tfile) = basename $0; unless (-d "testout") { mkdir "testout", 0755 or die "Couldn't create a 'testout' subdirectory: $!\n"; ### warn "$class: created 'testout' directory\n"; } my $self = $class->new($class->catfile('.', 'testout', "${tfile}log")); $self->log_warnings; $self; } #------------------------------ # DESTROY #------------------------------ # Class method, destructor. # Automatically closes the log. # sub DESTROY { $_[0]->log_close; } #------------------------------ =back =head2 Doing tests =over 4 =cut #------------------------------ =item begin NUMTESTS I Start testing. This outputs the 1..NUMTESTS line to the standard output. =cut sub begin { my ($self, $n) = @_; return if $self->{Begin}++; $self->l_print("1..$n\n\n"); print {$self->{OUT}} "1..$n\n"; } #------------------------------ =item end I Indicate the end of testing. This outputs a "# END" line to the standard output. =cut sub end { my ($self) = @_; return if $self->{End}++; $self->l_print("# END\n"); print {$self->{OUT}} "# END\n"; } #------------------------------ =item ok BOOL, [TESTNAME], [PARAMHASH...] I Do a test, and log some information connected with it. This outputs the test result lines to the standard output: ok 12 not ok 13 Use it like this: $T->ok(-e $dotforward); Or better yet, like this: $T->ok((-e $dotforward), "Does the user have a .forward file?"); Or even better, like this: $T->ok((-e $dotforward), "Does the user have a .forward file?", User => $ENV{USER}, Path => $dotforward, Fwd => $ENV{FWD}); That last one, if it were test #3, would be logged as: 3: Does the user have a .forward file? 3: User: "alice" 3: Path: "/home/alice/.forward" 3: Fwd: undef 3: ok You get the idea. Note that defined quantities are logged with delimiters and with all nongraphical characters suitably escaped, so you can see evidence of unexpected whitespace and other badnasties. Had "Fwd" been the string "this\nand\nthat", you'd have seen: 3: Fwd: "this\nand\nthat" And unblessed array refs like ["this", "and", "that"] are treated as multiple values: 3: Fwd: "this" 3: Fwd: "and" 3: Fwd: "that" =cut sub ok { my ($self, $ok, $test, @ps) = @_; ++($self->{Count}); # next test # Report to harness: my $status = ($ok ? "ok " : "not ok ") . $self->{Count}; print {$self->{OUT}} $status, "\n"; # Log: $self->ln_print($test, "\n") if $test; while (@ps) { my ($k, $v) = (shift @ps, shift @ps); my @vs = ((ref($v) and (ref($v) eq 'ARRAY'))? @$v : ($v)); foreach (@vs) { if (!defined($_)) { # value not defined: output keyword $self->ln_print(qq{ $k: undef\n}); } else { # value defined: output quoted, encoded form s{([\n\t\x00-\x1F\x7F-\xFF\\\"])} {'\\'.sprintf("%02X",ord($1)) }exg; s{\\0A}{\\n}g; $self->ln_print(qq{ $k: "$_"\n}); } } } $self->ln_print($status, "\n"); $self->l_print("\n"); 1; } #------------------------------ =item ok_eq ASTRING, BSTRING, [TESTNAME], [PARAMHASH...] I Convenience front end to ok(): test whether C, and logs the operands as 'A' and 'B'. =cut sub ok_eq { my ($self, $this, $that, $test, @ps) = @_; $self->ok(($this eq $that), ($test || "(Is 'A' string-equal to 'B'?)"), A => $this, B => $that, @ps); } #------------------------------ =item ok_eqnum ANUM, BNUM, [TESTNAME], [PARAMHASH...] I Convenience front end to ok(): test whether C, and logs the operands as 'A' and 'B'. =cut sub ok_eqnum { my ($self, $this, $that, $test, @ps) = @_; $self->ok(($this == $that), ($test || "(Is 'A' numerically-equal to 'B'?)"), A => $this, B => $that, @ps); } #------------------------------ =back =head2 Logging messages =over 4 =cut #------------------------------ =item log_open PATH I Open a log file for messages to be output to. This is invoked for you automatically by C and C. =cut sub log_open { my ($self, $path) = @_; $self->{LogPath} = $path; $self->{LOG} = FileHandle->new(">$path") || die "open $path: $!"; $self; } #------------------------------ =item log_close I Close the log file and stop logging. You shouldn't need to invoke this directly; the destructor does it. =cut sub log_close { my $self = shift; close(delete $self->{LOG}) if $self->{LOG}; } #------------------------------ =item log_warnings I Invoking this redefines $SIG{__WARN__} to log to STDERR and to the tester's log. This is automatically invoked when using the C constructor. =cut sub log_warnings { my ($self) = @_; $SIG{__WARN__} = sub { print STDERR $_[0]; $self->log("warning: ", $_[0]); }; } #------------------------------ =item log MESSAGE... I Log a message to the log file. No alterations are made on the text of the message. See msg() for an alternative. =cut sub log { my $self = shift; print {$self->{LOG}} @_ if $self->{LOG}; } #------------------------------ =item msg MESSAGE... I Log a message to the log file. Lines are prefixed with "** " for clarity, and a terminating newline is forced. =cut sub msg { my $self = shift; my $text = join '', @_; chomp $text; $text =~ s{^}{** }gm; $self->l_print($text, "\n"); } #------------------------------ # # l_print MESSAGE... # # Instance method, private. # Print to the log file if there is one. # sub l_print { my $self = shift; print { $self->{LOG} } @_ if $self->{LOG}; } #------------------------------ # # ln_print MESSAGE... # # Instance method, private. # Print to the log file, prefixed by message number. # sub ln_print { my $self = shift; foreach (split /\n/, join('', @_)) { $self->l_print("$self->{Count}: $_\n"); } } #------------------------------ =back =head2 Utilities =over 4 =cut #------------------------------ =item catdir DIR, ..., DIR I Concatenate several directories into a path ending in a directory. Lightweight version of the one in C; this method dates back to a more-innocent time when File::Spec was younger and less ubiquitous. Paths are assumed to be absolute. To signify a relative path, the first DIR must be ".", which is processed specially. On Mac, the path I end in a ':'. On Unix, the path I end in a '/'. =cut sub catdir { my $self = shift; my $relative = shift @_ if ($_[0] eq '.'); if ($^O eq 'Mac') { return ($relative ? ':' : '') . (join ':', @_) . ':'; } else { return ($relative ? './' : '/') . join '/', @_; } } #------------------------------ =item catfile DIR, ..., DIR, FILE I Like catdir(), but last element is assumed to be a file. Note that, at a minimum, you must supply at least a single DIR. =cut sub catfile { my $self = shift; my $file = pop; if ($^O eq 'Mac') { return $self->catdir(@_) . $file; } else { return $self->catdir(@_) . "/$file"; } } #------------------------------ =back =head1 VERSION $Id: TBone.pm,v 1.124 2001/08/20 20:30:07 eryq Exp $ =head1 CHANGE LOG =over 4 =item Version 1.124 (2001/08/20) The terms-of-use have been placed in the distribution file "COPYING". Also, small documentation tweaks were made. =item Version 1.122 (2001/08/20) Changed output of C<"END"> to C<"# END">; apparently, "END" is not a directive. Maybe it never was. I The storyteller need not say "the end" aloud; Silence is enough. Automatically invoke C when constructing via C. =item Version 1.120 (2001/08/17) Added log_warnings() to support the logging of SIG{__WARN__} messages to the log file (if any). =item Version 1.116 (2000/03/23) Cosmetic improvements only. =item Version 1.112 (1999/05/12) Added lightweight catdir() and catfile() (a la File::Spec) to enhance portability to Mac environment. =item Version 1.111 (1999/04/18) Now uses File::Basename to create "typical" logfile name, for portability. =item Version 1.110 (1999/04/17) Fixed bug in constructor that surfaced if no log was being used. =back Created: Friday-the-13th of February, 1998. =head1 AUTHOR Eryq (F). President, ZeeGee Software Inc. (F). Go to F for the latest downloads and on-line documentation for this module. Enjoy. Yell if it breaks. =cut #------------------------------ 1; __END__ my $T = new ExtUtils::TBone "testout/foo.tlog"; $T->begin(3); $T->msg("before 1\nor 2"); $T->ok(1, "one"); $T->ok(2, "Two"); $T->ok(3, "Three", Roman=>'III', Arabic=>[3, '03'], Misc=>"3\nor 3"); $T->end; 1; examples000755000764000764 012205015356 15226 5ustar00neilneil000000000000Data-Serializer-0.60README000444000764000764 1061012205015356 16261 0ustar00neilneil000000000000Data-Serializer-0.60/examplesNAME Cookbook - Examples of how to use Data::Serializer DESCRIPTION Data::Serializer::Cookbook is a collection of solutions for using Data::Serializer. CONVENTIONS Unless otherwise specified, all examples can be assumed to begin with: use Data::Serializer; my $serializer = Data::Serializer->new(); Some examples will show different arguments to the new method, where specified simply use that line instead of the simple form above. CONVENTIONS for Raw Access Fort hose who want a straight pass through to the underlying serializer, where nothing else is done (no encoding, encryption, compression, etc) there is Data::Serializer::Raw(3). These begin like this: use Data::Serializer::Raw; my $raw_serializer = Data::Serializer::Raw->new(); Encrypting your data You wish to encrypt your data structure, so that it can only be decoded by someone who shares the same key. Solution $serializer->secret('mysecret'); my $encrypted_hashref = $serializer->serializer($hash); ... (in other program) ... $serializer->secret('mysecret'); my $clear_hash = $serializer->deserializer($encrypted_hash); Note: You will have to have the Crypt::CBC module installed for this to work. Compressing your data You wish to compress your data structure to cut down on how much disk space it will take up. Solution $serializer->compress(1); my $compressed_hashref = $serializer->serializer($hash); ... (in other program) ... my $clear_hash = $serializer->deserializer($compressed_hash); Note: You will have to have the Compress::Zlib module installed for this to work. Your mileage will vary dramatically depending on what serializer you use. Some serializers are already fairly compact. You want to read in data serialized outside of Data::Serializer You need to write a program that can read in data serialized in a format other than Data::Serializer. For example you need to be able to be able to process data serialized by XML::Dumper. Solution use Data::Serializer::Raw; my $xml_raw_serializer = Data::Serializer::Raw->(serializer => 'XML::Dumper'); my $hash_ref = $xml_raw_serializer->deserialize($xml_data); 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 than Data::Serializer. Or said more generically you need to write out data in the format native to the underlying serializer. For our example we will be exporting data using XML::Dumper format. Solution ues Data::Serializer::Raw; my $xml_raw_serializer = Data::Serializer::Raw->(serializer => 'XML::Dumper'); my $xml_data = $xml_raw_serializer->serialize($hash_ref); 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 use Data::Serializer::Raw; my $xml_raw_serializer = Data::Serializer::Raw->(serializer => 'XML::Dumper'); my $php_raw_serializer = Data::Serializer::Raw->(serializer => 'PHP::Serialization'); my $hash_ref = $php_raw_serializer->deserialize($php_data); my $xml_data = $xml_raw_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 some counters from one of your routers. You want your program to keep the counters from the last run so that it can see how much traffic has passed over a link since it last ran. Solution # path to store our serialized data # be paranoid, use full paths my $last_run_datafile = '/full/path/to/file/lastrun.data'; #We keep our data as a hash reference my $last_data = $serializer->retrieve($last_run_datafile); #Pull in our new data through 'pull_data()'; my $new_data = query_router($router); #run comparison code run_comparison($last_data,$new_data); $serializer->store($new_data); AUTHOR Neil Neely . COPYRIGHT Copyright (c) 2001-2011 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. SEE ALSO Data::Serializer(3) Data::Serializer::Raw(3)