From: Stevan Little Date: Sat, 10 May 2008 18:14:58 +0000 (+0000) Subject: 0.44 releaase soon X-Git-Tag: 0_55~184 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a0c064a1846f62a6124ab36bf8d47ee925e1192;p=gitmo%2FMoose.git 0.44 releaase soon --- diff --git a/Changes b/Changes index d34bdc4..452a081 100644 --- a/Changes +++ b/Changes @@ -1,15 +1,30 @@ Revision history for Perl extension Moose +0.44 Sat. May 10, 2008 * Moose - - made make_immutable warning cluck to show where the error is - -0.44 + - made make_immutable warning cluck to + show where the error is + + * Moose::Object + - BUILDALL and DEMOLISHALL now call + ->body when looping through the + methods, to avoid the overloaded + method call. + * Moose::Cookbook::Recipe7 - - added new recipe for immutable functionality (Dave Rolsky) + - added new recipe for immutable + functionality (thanks Dave Rolsky) + * Moose::Cookbook::Recipe9 - - added new recipe for builder and lazy_build (Dave Rolsky) + - added new recipe for builder and + lazy_build (thanks Dave Rolsky) + * Moose::Cookbook::Recipe1 - - added new recipe for method aliasing and exclusion with Roles (Dave Rolsky) + - added new recipe for method aliasing + and exclusion with Roles (thanks Dave Rolsky) + + * t/ + - fixed Win32 test failure 0.43 Wed. April, 30, 2008 * NOTE TO SELF: diff --git a/MANIFEST b/MANIFEST index 874cff1..e1d5ce1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,11 +1,14 @@ Build.PL Changes doap.rdf +inc/Module/AutoInstall.pm inc/Module/Install.pm +inc/Module/Install/AutoInstall.pm inc/Module/Install/Base.pm inc/Module/Install/Build.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm +inc/Module/Install/Include.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm @@ -180,6 +183,7 @@ t/100_bugs/008_new_w_undef.t t/100_bugs/009_augment_recursion_bug.t t/100_bugs/010_immutable_n_default_x2.t t/100_bugs/011_DEMOLISH_eats_exceptions.t +t/100_bugs/012_DEMOLISH_eats_mini.t t/200_examples/001_example.t t/200_examples/002_example_Moose_POOP.t t/200_examples/003_example.t diff --git a/README b/README index 873b2f6..a8f5ab2 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Moose version 0.41 +Moose version 0.44 =========================== See the individual module documentation for more information diff --git a/lib/Moose.pm b/lib/Moose.pm index 26e62eb..9d97667 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -4,7 +4,7 @@ package Moose; use strict; use warnings; -our $VERSION = '0.43'; +our $VERSION = '0.44'; our $AUTHORITY = 'cpan:STEVAN'; use Scalar::Util 'blessed', 'reftype'; @@ -318,7 +318,7 @@ Moose is an extension of the Perl 5 object system. =head2 Another object system!?!? Yes, I know there has been an explosion recently of new ways to -build object's in Perl 5, most of them based on inside-out objects +build objects in Perl 5, most of them based on inside-out objects and other such things. Moose is different because it is not a new object system for Perl 5, but instead an extension of the existing object system. diff --git a/lib/Moose/Cookbook/Snack/ArrayRef.pod b/lib/Moose/Cookbook/Snack/ArrayRef.pod index 9f986c7..8219ef8 100644 --- a/lib/Moose/Cookbook/Snack/ArrayRef.pod +++ b/lib/Moose/Cookbook/Snack/ArrayRef.pod @@ -1,11 +1,9 @@ -#!/usr/bin/env perl + =pod =head1 NAME -Moose::Cookbook::Snack::ArrayRef - (Ab)using the ArrayRef type constraint -provided by the L and/or -L classes. +Moose::Cookbook::Snack::ArrayRef - Using the ArrayRef type constraint =head1 SYNOPSIS @@ -76,8 +74,8 @@ object shown in the SYNOPSIS: sub show_inventory { my $self = shift; foreach my $item ( @{$self->fruit_aisle} ) { - # access each Fruit object - } # foreach my $item ( @{$self->fruit_aisle} ) + # ... access each Fruit object + } } =head2 Assigning arrays to an ArrayRef will overwrite existing arrays @@ -110,8 +108,8 @@ And here's an example of deleting an object stored in an ArrayRef: for my $fruit_obj ( @fruit_aisle_copy ) { if ( $fruit_obj->name ne 'tomato' ) { push(@reworked_fruit_aisle, $fruit_obj); - } # if ( $fruit_obj->name ne 'tomato' ) - } # for my $fruit_obj ( @fruit_aisle_copy ) + } + } $store->fruit_aisle( \@reworked_fruit_aisle ); Putting the above code into their own object methods would make appending to or deleting from an C a trivial operation. @@ -140,6 +138,7 @@ class hierarchy Type Constraints =item L - Type constraints that Moose can use +and the tools to extend them or create your own. =item L - Autoboxed wrappers for Native Perl datatypes @@ -153,9 +152,11 @@ Brian Manning =head1 COPYRIGHT AND LICENSE -Copyright (c)2008 by Infinity Interactive, Inc., Brian Manning +Copyright 2006-2008 by Infinity Interactive, Inc. + +L -This documentation is free software; you can redistribute it and/or modify +This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Cookbook/Snack/HashRef.pod b/lib/Moose/Cookbook/Snack/HashRef.pod index 94494c0..0bc89bd 100644 --- a/lib/Moose/Cookbook/Snack/HashRef.pod +++ b/lib/Moose/Cookbook/Snack/HashRef.pod @@ -1,11 +1,9 @@ -#!/usr/bin/env perl + =pod =head1 NAME -Moose::Cookbook::Snack::HashRef - (Ab)using the HashRef type constraint -provided by the L and/or -L classes. +Moose::Cookbook::Snack::HashRef - Using the HashRef type constraint =head1 SYNOPSIS @@ -38,7 +36,7 @@ variable as an attribute of a Moose object. The code in this document will work on Moose as advertised, but the developers strongly recommend using something like L or -L when working with array references in order to +L when working with hash references in order to help keep your Moose objects nice and encapsulated. =head2 Assigning hashes to a HashRef attribute @@ -75,7 +73,7 @@ de-reference the C, and then enumerate over it's keys. my $fruit = $self->{fruit_aisle}{$item}; print "Item: $item, type: " . $fruit->meta->name . " species: " . $fruit->species . "\n"; - } # foreach my $item + } If the above de-referencing of the C C is a little too noisy, you could create a copy of it, and then enumerate over that copy: @@ -83,7 +81,8 @@ noisy, you could create a copy of it, and then enumerate over that copy: my %fruit_aisle_copy = %{$self->fruit_aisle}; foreach my $item ( keys(%fruit_aisle_copy) ) { my $fruit = $fruit_aisle_copy{$item}; - # 'print' statement from above example goes here + print "Item: $item, type: " . $fruit->meta->name + . " species: " . $fruit->species . "\n"; } =head2 Assigning to a HashRef attribute will overwrite @@ -139,7 +138,12 @@ clear out that attribute yet still satisfy the type constraint. =item L - Snippets of code for using Types and Type Constraints -=item L - Type constraints system for Moose +=item L - Type constraints that Moose can use +and the tools to extend them or create your own. + +=item L - Autoboxed wrappers for Native Perl datatypes + +=item L - Extends attribute interfaces =back @@ -149,9 +153,11 @@ Brian Manning =head1 COPYRIGHT AND LICENSE -Copyright (c)2008 by Infinity Interactive, Inc., Brian Manning +Copyright 2006-2008 by Infinity Interactive, Inc. + +L -This documentation is free software; you can redistribute it and/or modify +This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod b/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod index d884be6..56dbd19 100644 --- a/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod +++ b/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod @@ -49,21 +49,25 @@ Let's take a look and find out... # verify that the user passed in the 'script_name' attribute if ( exists $args{script_name} ) { $self->script_name($args{script_name}); - } else { + } + else { die "ERROR: can't create object without 'script_name' "; - } # if ( exists $args{script_name} ) + } # return the object reference back to the caller return $self; - } # sub new + } sub script_name { my $self = shift; - # check for arguments; use the argument if passed in, otherwise - # return the existing value (if any) - if (@_) { $self->{script_name} = shift } + # check for arguments; use the argument + # if passed in, otherwise return the + # existing value (if any) + if (@_) { + $self->{script_name} = shift; + } return $self->{script_name}; - } # sub script_name + } package main; use strict; @@ -159,6 +163,7 @@ want to use objects in the first place, right? =item L - The 'Point' object example =item L - Type constraints that Moose can use +and the tools to extend them or create your own. =item L - For when things go wrong with Moose @@ -170,9 +175,11 @@ Brian Manning =head1 COPYRIGHT AND LICENSE -Copyright (c)2008 by Infinity Interactive, Inc., Brian Manning +Copyright 2006-2008 by Infinity Interactive, Inc. -This documentation is free software; you can redistribute it and/or modify +L + +This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index d018d27..05ff2c3 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -9,7 +9,7 @@ use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class'; use Carp 'confess'; -our $VERSION = '0.12'; +our $VERSION = '0.13'; our $AUTHORITY = 'cpan:STEVAN'; sub new { @@ -42,21 +42,29 @@ sub BUILDALL { } sub DEMOLISHALL { + my $self = shift; + foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) { + $method->{code}->body->($self); + } +} + +sub DESTROY { # NOTE: we ask Perl if we even # need to do this first, to avoid # extra meta level calls - return unless $_[0]->can('DEMOLISH'); - my $self = shift; - { - local $@; - foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) { - $method->{code}->body->($self); - } - } + return unless $_[0]->can('DEMOLISH'); + # if we have an exception here ... + if (my $e = $@) { + # run DEMOLISHALL ourselves, ... + (shift)->DEMOLISHALL; + # then restore the exception ... + $@ = $e; + # and return ... + return; + } + goto &DEMOLISHALL } -sub DESTROY { goto &DEMOLISHALL } - # new does() methods will be created # as approiate see Moose::Meta::Role sub does { diff --git a/t/100_bugs/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t new file mode 100644 index 0000000..81eac60 --- /dev/null +++ b/t/100_bugs/012_DEMOLISH_eats_mini.t @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More no_plan => 1; +use Test::Exception; + +BEGIN { + use_ok('Moose'); + use_ok('Moose::Util::TypeConstraints'); +} + +{ + package Foo; + use Moose; + + has 'bar' => ( + is => 'ro', + required => 1, + ); + + # Defining this causes the FIRST call to Baz->new w/o param to fail, + # if no call to ANY Moose::Object->new was done before. + sub DEMOLISH { + my ( $self ) = @_; + } +} + +my $obj = eval { Foo->new; }; +::like( $@, qr/is required/, "... Foo plain" ); +::is( $obj, undef, "... the object is undef" ); + +1; +