From: rkinyon Date: Tue, 7 Mar 2006 03:19:24 +0000 (+0000) Subject: Tagged 0.981_02 X-Git-Tag: 0-981_02^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ca6a098305924347092a96d80cc77a31c81606c;p=dbsrgits%2FDBM-Deep.git Tagged 0.981_02 --- diff --git a/Changes b/Changes index 3086f6b..1c4295a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ Revision history for DBM::Deep. -0.981_01 Mar 06 11:00:00 2006 Pacific +0.981_02 Mar 06 19:00:00 2006 Pacific + - Added support for blessed objects in the auditlog + +0.981_01 Mar 06 14:00:00 2006 Pacific - Added experimental auditlog support. This will only be released as a developer released in the 0.x line because of the hackish nature of the change. diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index c51fe40..f8b5248 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -36,7 +36,7 @@ use Digest::MD5 (); use Scalar::Util (); use vars qw( $VERSION ); -$VERSION = q(0.981_01); +$VERSION = q(0.981_02); ## # Set to 4 and 'N' for 32-bit offset tags (default). Theoretical limit of 4 GB per file. @@ -1368,6 +1368,10 @@ sub STORE { $rhs = "'$_[2]'"; } + if ( my $c = Scalar::Util::blessed( $_[2] ) ) { + $rhs = "bless $rhs, '$c'"; + } + flock( $afh, LOCK_EX ); print( $afh "$lhs = $rhs; # " . localtime(time) . "\n" ); flock( $afh, LOCK_UN ); diff --git a/t/50_audit_trail.t b/t/50_audit_trail.t index 230b5d2..baea6c4 100644 --- a/t/50_audit_trail.t +++ b/t/50_audit_trail.t @@ -38,7 +38,7 @@ $|=1; sub STORESIZE {} } -use Test::More tests => 20; +use Test::More tests => 24; use_ok( 'DBM::Deep' ); @@ -168,4 +168,32 @@ undef $db; is_deeply( $export2, $export, "And recovery works" ); } +{ + $db = DBM::Deep->new({ + file => 't/test.db', + audit_file => $audit_file, + }); + + $db->{blessed} = bless { a => 5, b => 3 }, 'Floober'; + like( $audit[15], qr{\$db->{blessed} = bless {}, 'Floober';}, + "Assignment of a blessed reference works" ); + like( $audit[16], qr{\$db->{blessed}{a} = '5';}, "... child 1" ); + like( $audit[17], qr{\$db->{blessed}{b} = '3';}, "... child 2" ); + $export = $db->export; +} + +{ + unlink 't/test2.db'; + my $db = DBM::Deep->new({ + file => 't/test2.db', + }); + + for ( @audit ) { + eval "$_"; + } + + my $export2 = $db->export; + + is_deeply( $export2, $export, "And recovery works" ); +}