From: Karen Etheridge Date: Wed, 17 Jul 2013 02:47:39 +0000 (-0700) Subject: make EOL tests pass X-Git-Tag: v0.36-TRIAL~1^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b2ba857269b040d3a0f11f3d95e2c5b9af44415;p=gitmo%2FMooseX-Storage.git make EOL tests pass --- diff --git a/lib/MooseX/Storage/Engine.pm b/lib/MooseX/Storage/Engine.pm index bcc87ae..9969d5a 100644 --- a/lib/MooseX/Storage/Engine.pm +++ b/lib/MooseX/Storage/Engine.pm @@ -26,13 +26,13 @@ has 'class' => (is => 'rw', isa => 'Str'); sub collapse_object { my ( $self, %options ) = @_; - # NOTE: - # mark the root object as seen ... - $self->seen->{refaddr $self->object} = undef; - + # NOTE: + # mark the root object as seen ... + $self->seen->{refaddr $self->object} = undef; + $self->map_attributes('collapse_attribute', \%options); $self->storage->{$CLASS_MARKER} = $self->object->meta->identifier; - return $self->storage; + return $self->storage; } sub expand_object { @@ -41,12 +41,12 @@ sub expand_object { $options{check_version} = 1 unless exists $options{check_version}; $options{check_authority} = 1 unless exists $options{check_authority}; - # NOTE: - # mark the root object as seen ... - $self->seen->{refaddr $data} = undef; + # NOTE: + # mark the root object as seen ... + $self->seen->{refaddr $data} = undef; $self->map_attributes('expand_attribute', $data, \%options); - return $self->storage; + return $self->storage; } ## this is the internal API ... @@ -67,13 +67,13 @@ sub expand_attribute { sub collapse_attribute_value { my ($self, $attr, $options) = @_; # Faster, but breaks attributes without readers, do we care? - #my $value = $attr->get_read_method_ref->($self->object); - my $value = $attr->get_value($self->object); + #my $value = $attr->get_read_method_ref->($self->object); + my $value = $attr->get_value($self->object); - # NOTE: - # this might not be enough, we might - # need to make it possible for the - # cycle checker to return the value + # NOTE: + # this might not be enough, we might + # need to make it possible for the + # cycle checker to return the value $self->check_for_cycle_in_collapse($attr, $value) if ref $value; @@ -83,14 +83,14 @@ sub collapse_attribute_value { || confess "Cannot convert " . $attr->type_constraint->name; $value = $type_converter->{collapse}->($value, $options); } - return $value; + return $value; } sub expand_attribute_value { my ($self, $attr, $value, $options) = @_; - # NOTE: - # (see comment in method above ^^) + # NOTE: + # (see comment in method above ^^) if( ref $value and not( $options->{disable_cycle_check} or $self->class->does('MooseX::Storage::Traits::DisableCycleDetection') @@ -102,7 +102,7 @@ sub expand_attribute_value { my $type_converter = $self->find_type_handler($attr->type_constraint, $value); $value = $type_converter->{expand}->($value, $options); } - return $value; + return $value; } # NOTE: diff --git a/lib/MooseX/Storage/Engine/IO/AtomicFile.pm b/lib/MooseX/Storage/Engine/IO/AtomicFile.pm index 68e60e8..e93e179 100644 --- a/lib/MooseX/Storage/Engine/IO/AtomicFile.pm +++ b/lib/MooseX/Storage/Engine/IO/AtomicFile.pm @@ -7,13 +7,13 @@ use IO::AtomicFile; extends 'MooseX::Storage::Engine::IO::File'; sub store { - my ($self, $data) = @_; - my $fh = IO::AtomicFile->new($self->file, 'w') - || confess "Unable to open file (" . $self->file . ") for storing : $!"; - $fh->binmode(':utf8') if utf8::is_utf8($data); - print $fh $data; - $fh->close() - || confess "Could not write atomic file (" . $self->file . ") because: $!"; + my ($self, $data) = @_; + my $fh = IO::AtomicFile->new($self->file, 'w') + || confess "Unable to open file (" . $self->file . ") for storing : $!"; + $fh->binmode(':utf8') if utf8::is_utf8($data); + print $fh $data; + $fh->close() + || confess "Could not write atomic file (" . $self->file . ") because: $!"; } 1; @@ -52,7 +52,7 @@ This provides the actual means to store data to a file atomically. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/lib/MooseX/Storage/Engine/IO/File.pm b/lib/MooseX/Storage/Engine/IO/File.pm index 83c7a8d..4d69f89 100644 --- a/lib/MooseX/Storage/Engine/IO/File.pm +++ b/lib/MooseX/Storage/Engine/IO/File.pm @@ -5,24 +5,24 @@ use utf8 (); use IO::File; has 'file' => ( - is => 'ro', - isa => 'Str', - required => 1, + is => 'ro', + isa => 'Str', + required => 1, ); -sub load { - my ($self) = @_; - my $fh = IO::File->new($self->file, 'r') - || confess "Unable to open file (" . $self->file . ") for loading : $!"; - return do { local $/; <$fh>; }; +sub load { + my ($self) = @_; + my $fh = IO::File->new($self->file, 'r') + || confess "Unable to open file (" . $self->file . ") for loading : $!"; + return do { local $/; <$fh>; }; } sub store { - my ($self, $data) = @_; - my $fh = IO::File->new($self->file, 'w') - || confess "Unable to open file (" . $self->file . ") for storing : $!"; - $fh->binmode(':utf8') if utf8::is_utf8($data); - print $fh $data; + my ($self, $data) = @_; + my $fh = IO::File->new($self->file, 'w') + || confess "Unable to open file (" . $self->file . ") for storing : $!"; + $fh->binmode(':utf8') if utf8::is_utf8($data); + print $fh $data; } 1; @@ -61,7 +61,7 @@ This provides the actual means to store data to a file. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm b/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm index a6539f0..befe62d 100644 --- a/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm +++ b/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm @@ -24,24 +24,25 @@ MooseX::Storage::Meta::Attribute::DoNotSerialize - A custom meta-attribute to by package Point; use Moose; use MooseX::Storage; - + with Storage('format' => 'JSON', 'io' => 'File'); - + has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); - + has 'foo' => ( metaclass => 'DoNotSerialize', is => 'rw', isa => 'CodeRef', ); - + 1; =head1 DESCRIPTION -Sometimes you don't want a particular attribute to be part of the -serialization, in this case, you want to make sure that attribute + +Sometimes you don't want a particular attribute to be part of the +serialization, in this case, you want to make sure that attribute uses this custom meta-attribute. See the SYNOPSIS for a nice example that can be easily cargo-culted. @@ -57,7 +58,7 @@ that can be easily cargo-culted. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm b/lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm index 84259d7..834fdae 100644 --- a/lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm +++ b/lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm @@ -22,25 +22,25 @@ MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize - A custom meta-attribut package Point; use Moose; use MooseX::Storage; - + with Storage('format' => 'JSON', 'io' => 'File'); - + has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); - + has 'foo' => ( traits => [ 'DoNotSerialize' ], is => 'rw', isa => 'CodeRef', ); - + 1; =head1 DESCRIPTION -Sometimes you don't want a particular attribute to be part of the -serialization, in this case, you want to make sure that attribute -uses this custom meta-attribute-trait. See the SYNOPSIS for a nice +Sometimes you don't want a particular attribute to be part of the +serialization, in this case, you want to make sure that attribute +uses this custom meta-attribute-trait. See the SYNOPSIS for a nice example that can be easily cargo-culted. =head1 METHODS @@ -55,7 +55,7 @@ example that can be easily cargo-culted. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/t/002_basic_io.t b/t/002_basic_io.t index bef8ba4..3fe1289 100644 --- a/t/002_basic_io.t +++ b/t/002_basic_io.t @@ -33,7 +33,7 @@ BEGIN { has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir, 'temp.json'); @@ -45,7 +45,7 @@ my $file = catfile($dir, 'temp.json'); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); diff --git a/t/061_basic_deferred_w_io.t b/t/061_basic_deferred_w_io.t index 8629743..95539ae 100644 --- a/t/061_basic_deferred_w_io.t +++ b/t/061_basic_deferred_w_io.t @@ -30,7 +30,7 @@ BEGIN { has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir, 'temp.json'); @@ -42,7 +42,7 @@ my $file = catfile($dir, 'temp.json'); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); @@ -73,7 +73,7 @@ ok(!(-e $file), '... the file has been deleted'); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); diff --git a/t/100_io.t b/t/100_io.t index 9c91a88..e2ae450 100644 --- a/t/100_io.t +++ b/t/100_io.t @@ -28,7 +28,7 @@ BEGIN { has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile( $dir, 'temp.json' ); @@ -40,7 +40,7 @@ my $file = catfile( $dir, 'temp.json' ); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); diff --git a/t/101_io_atomic.t b/t/101_io_atomic.t index c14522b..cdc9320 100644 --- a/t/101_io_atomic.t +++ b/t/101_io_atomic.t @@ -29,7 +29,7 @@ BEGIN { has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir,'temp.json'); @@ -41,7 +41,7 @@ my $file = catfile($dir,'temp.json'); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); diff --git a/t/102_io_storable_file.t b/t/102_io_storable_file.t index feb0175..9a9851c 100644 --- a/t/102_io_storable_file.t +++ b/t/102_io_storable_file.t @@ -23,7 +23,7 @@ BEGIN { has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir,'temp.storable'); @@ -35,7 +35,7 @@ my $file = catfile($dir,'temp.storable'); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); diff --git a/t/103_io_storable_file_custom.t b/t/103_io_storable_file_custom.t index 88093b8..ed991d4 100644 --- a/t/103_io_storable_file_custom.t +++ b/t/103_io_storable_file_custom.t @@ -24,10 +24,10 @@ BEGIN { has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); - - ## add some custom freeze/thaw hooks here ... - + has 'object' => (is => 'ro', isa => 'Object'); + + ## add some custom freeze/thaw hooks here ... + sub thaw { my ( $class, $data ) = @_; my $self = $class->unpack( $data ); @@ -53,7 +53,7 @@ my $file = catfile($dir,'temp.storable'); float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, - object => Foo->new( number => 2 ), + object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo');