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
# 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,
-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';
use MooseX::Storage::Meta::Attribute::DoNotSerialize;
-our $VERSION = '0.10';
+our $VERSION = '0.11';
our $AUTHORITY = 'cpan:STEVAN';
sub import {
package MooseX::Storage::Engine;
use Moose;
-our $VERSION = '0.03';
+our $VERSION = '0.04';
our $AUTHORITY = 'cpan:STEVAN';
# the class marker when
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)
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;
use strict;
use warnings;
-use Test::More no_plan => 1;
+use Test::More tests => 9;
{
package Foo;
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');
}
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'
);
+
}
{
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');
}
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');
}
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