From: Stevan Little Date: Thu, 10 Jan 2008 18:31:17 +0000 (+0000) Subject: 0.11 X-Git-Tag: 0.14~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cfee09ad9535c50ee223c90fb34afd9667866bcb;p=gitmo%2FMooseX-Storage.git 0.11 --- diff --git a/Changes b/Changes index 3d68ede..23c436e 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,20 @@ Revision history for MooseX-Storage -0.10 +0.11 Thurs. Jan. 10, 2008 + + - upped the Test::JSON dependency + so that we use the version that + supports JSON::Any + - upped the JSON::Any requirement + - minor test cleanups to handle + optional dependencies better + + * MooseX::Storage::Engine + - the numbers now have to numify (+0) in the + expand/collapse so that certain JSON engines + will not choke on them + +0.10 Thurs. Jan. 10, 2008 ~~ updated copyright information ~~ * MooseX::Storage::Deferred diff --git a/Makefile.PL b/Makefile.PL index 6f56619..3cba704 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -12,8 +12,8 @@ requires 'Moose' => '0.20'; # serialization format feature 'JSON', -default => 1, - 'JSON::Any' => '0.1', - 'Test::JSON' => '0'; + 'JSON::Any' => '1.15', + 'Test::JSON' => '0.06'; feature 'YAML', -default => 1, @@ -30,7 +30,8 @@ feature 'File', -default => 1, 'IO::File' => '0.1'; -build_requires 'Test::More' => '0.42'; +build_requires 'Test::More' => '0.42'; +build_requires 'Test::Exception' => '0'; no_index 'directory' => 'ex'; diff --git a/lib/MooseX/Storage.pm b/lib/MooseX/Storage.pm index f64ac68..7e7d30d 100644 --- a/lib/MooseX/Storage.pm +++ b/lib/MooseX/Storage.pm @@ -4,7 +4,7 @@ use Moose qw(confess); use MooseX::Storage::Meta::Attribute::DoNotSerialize; -our $VERSION = '0.10'; +our $VERSION = '0.11'; our $AUTHORITY = 'cpan:STEVAN'; sub import { diff --git a/lib/MooseX/Storage/Engine.pm b/lib/MooseX/Storage/Engine.pm index a49cd07..e0c9b1e 100644 --- a/lib/MooseX/Storage/Engine.pm +++ b/lib/MooseX/Storage/Engine.pm @@ -2,7 +2,7 @@ package MooseX::Storage::Engine; use Moose; -our $VERSION = '0.03'; +our $VERSION = '0.04'; our $AUTHORITY = 'cpan:STEVAN'; # the class marker when @@ -203,9 +203,13 @@ my %OBJECT_HANDLERS = ( my %TYPES = ( - # These are boring ones, so they use the identity function ... - 'Int' => { expand => sub { shift }, collapse => sub { shift } }, - 'Num' => { expand => sub { shift }, collapse => sub { shift } }, + # NOTE: + # we need to make sure that we properly numify the numbers + # before and after them being futzed with, because some of + # the JSON engines are stupid/annoying/frustrating + 'Int' => { expand => sub { $_[0] + 0 }, collapse => sub { $_[0] + 0 } }, + 'Num' => { expand => sub { $_[0] + 0 }, collapse => sub { $_[0] + 0 } }, + # These are boring ones, so they use the identity function ... 'Str' => { expand => sub { shift }, collapse => sub { shift } }, 'Bool' => { expand => sub { shift }, collapse => sub { shift } }, # These are the trickier ones, (see notes) diff --git a/lib/MooseX/Storage/Format/JSON.pm b/lib/MooseX/Storage/Format/JSON.pm index 654cb3b..01ddc56 100644 --- a/lib/MooseX/Storage/Format/JSON.pm +++ b/lib/MooseX/Storage/Format/JSON.pm @@ -15,14 +15,12 @@ requires 'unpack'; sub thaw { my ( $class, $json, @args ) = @_; - local $JSON::UnMapping = 1; utf8::encode($json) if utf8::is_utf8($json); $class->unpack( JSON::Any->jsonToObj($json), @args ); } sub freeze { my ( $self, @args ) = @_; - local $JSON::UnMapping = 1; my $json = JSON::Any->objToJson( $self->pack(@args) ); utf8::decode($json) if !utf8::is_utf8($json) and utf8::valid($json); # if it's valid utf8 mark it as such return $json; diff --git a/t/002_basic_io.t b/t/002_basic_io.t index f5acac8..4474eb6 100644 --- a/t/002_basic_io.t +++ b/t/002_basic_io.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More no_plan => 1; +use Test::More tests => 9; { package Foo; diff --git a/t/010_basic_json.t b/t/010_basic_json.t index 30b3327..b589ece 100644 --- a/t/010_basic_json.t +++ b/t/010_basic_json.t @@ -5,15 +5,9 @@ use warnings; use Test::More; -BEGIN { +BEGIN { eval "use Test::JSON"; - plan skip_all => "Test::JSON is required for this test" if $@; - # NOTE: - # this idiocy is cause Test::JSON - # uses JSON.pm and that can be - # very picky about the JSON output - # - SL - BEGIN { $ENV{JSON_ANY_ORDER} = qw(JSON) } + plan skip_all => "Test::JSON is required for this test" if $@; plan tests => 12; use_ok('MooseX::Storage'); } @@ -49,11 +43,13 @@ BEGIN { is_valid_json($json, '.. this is valid JSON'); + is_json( $json, '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}', '... got the right JSON' ); + } { diff --git a/t/060_basic_deferred.t b/t/060_basic_deferred.t index 75c36a9..cec3ab3 100644 --- a/t/060_basic_deferred.t +++ b/t/060_basic_deferred.t @@ -3,13 +3,13 @@ $|++; use strict; use warnings; -use Test::More tests => 33; +use Test::More; use Storable; -use Test::JSON; -use Test::YAML::Valid; BEGIN { - $ENV{JSON_ANY_ORDER} = qw(JSON); + eval "use Test::JSON; use Test::YAML::Valid;"; + plan skip_all => "Test::JSON and Test::YAML::Valid are required for this test" if $@; + plan tests => 33; use_ok('MooseX::Storage'); } diff --git a/t/061_basic_deferred_w_io.t b/t/061_basic_deferred_w_io.t index 38722b1..3cc66af 100644 --- a/t/061_basic_deferred_w_io.t +++ b/t/061_basic_deferred_w_io.t @@ -3,9 +3,12 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More; BEGIN { + eval "use IO::AtomicFile"; + plan skip_all => "IO::AtomicFile is required for this test" if $@; + plan tests => 21; use_ok('MooseX::Storage'); } diff --git a/t/105_io_atomic_w_utf8.t b/t/105_io_atomic_w_utf8.t index 8b5678c..8c19f5d 100644 --- a/t/105_io_atomic_w_utf8.t +++ b/t/105_io_atomic_w_utf8.t @@ -6,6 +6,8 @@ use warnings; use Test::More; BEGIN { + eval "use IO::AtomicFile"; + plan skip_all => "IO::AtomicFile is required for this test" if $@; # NOTE: # this is because JSON::XS is # the only one which really gets