From: Stevan Little Date: Wed, 12 Jul 2006 13:15:51 +0000 (+0000) Subject: 0.11 X-Git-Tag: 0_11~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=31f8ec7238071a10c5a413a01b0bdc02b26a8bbb;p=gitmo%2FMoose.git 0.11 --- diff --git a/Build.PL b/Build.PL index 52c63d1..b4a6f44 100644 --- a/Build.PL +++ b/Build.PL @@ -12,7 +12,8 @@ my $build = Module::Build->new( 'Sub::Name' => '0.02', 'UNIVERSAL::require' => '0.10', 'Sub::Exporter' => '0.954', - 'Sub::Install' => '0.92', + 'Sub::Install' => '0.92', + 'B' => '0', }, optional => { }, diff --git a/Changes b/Changes index 4af3fe6..00740c1 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,14 @@ Revision history for Perl extension Moose +0.11 + * Moose + - added an &unimport method to remove all the keywords + that Moose will import + + * t/ + - fixed some test failures caused by a forgotten test + dependency. + 0.10 Thurs. July 6, 2006 * Moose - improved error message when loading modules so diff --git a/MANIFEST b/MANIFEST index 0254f93..94cea66 100644 --- a/MANIFEST +++ b/MANIFEST @@ -37,6 +37,7 @@ t/014_override_augment_inner_super.t t/015_override_and_foreign_classes.t t/016_always_strict_warnings.t t/017_wrapped_method_context_propagation.t +t/018_import_unimport.t t/020_foreign_inheritence.t t/021_moose_w_metaclass.t t/022_moose_respects_base.t diff --git a/README b/README index d55c76c..7a0144f 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Moose version 0.10 +Moose version 0.11 =========================== See the individual module documentation for more information @@ -22,6 +22,7 @@ This module requires these other modules and libraries: Sub::Name UNIVERSAL::require Sub::Exporter + B COPYRIGHT AND LICENCE diff --git a/lib/Moose.pm b/lib/Moose.pm index 16b6785..363a6a8 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -4,11 +4,12 @@ package Moose; use strict; use warnings; -our $VERSION = '0.10'; +our $VERSION = '0.11'; use Scalar::Util 'blessed', 'reftype'; use Carp 'confess'; use Sub::Name 'subname'; +use B 'svref_2object'; use UNIVERSAL::require; use Sub::Exporter; @@ -166,6 +167,27 @@ use Moose::Util::TypeConstraints; goto $exporter; } + + sub unimport { + no strict 'refs'; + my $class = caller(); + # loop through the exports ... + foreach my $name (keys %exports) { + + # if we find one ... + if (defined &{$class . '::' . $name}) { + my $keyword = \&{$class . '::' . $name}; + + # make sure it is from Moose + my $pkg_name = eval { svref_2object($keyword)->GV->STASH->NAME }; + next if $@; + next if $pkg_name ne 'Moose'; + + # and if it is from Moose then undef the slot + delete ${$class . '::'}{$name}; + } + } + } } ## Utility functions @@ -200,7 +222,7 @@ __END__ =head1 NAME -Moose - Moose, it's the new Camel +Moose - A complete modern object system for Perl 5 =head1 SYNOPSIS @@ -442,6 +464,27 @@ C anywhere you need to test for an object's class name. =back +=head1 UNEXPORTING FUNCTIONS + +=head2 B + +Moose offers a way of removing the keywords it exports though the C +method. You simply have to say C at the bottom of your code for this +to work. Here is an example: + + package Person; + use Moose; + + has 'first_name' => (is => 'rw', isa => 'Str'); + has 'last_name' => (is => 'rw', isa => 'Str'); + + sub full_name { + my $self = shift; + $self->first_name . ' ' . $self->last_name + } + + no Moose; # keywords are removed from the Person package + =head1 FUTURE PLANS Here is just a sampling of the plans we have in store for Moose: diff --git a/t/000_load.t b/t/000_load.t index 298e89c..0c59d05 100644 --- a/t/000_load.t +++ b/t/000_load.t @@ -7,4 +7,4 @@ use Test::More tests => 1; BEGIN { use_ok('Moose'); -} \ No newline at end of file +} diff --git a/t/018_import_unimport.t b/t/018_import_unimport.t new file mode 100644 index 0000000..6618398 --- /dev/null +++ b/t/018_import_unimport.t @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 23; + +BEGIN { + use_ok('Moose'); +} + +my @moose_exports = qw( + extends with + has + before after around + override super + augment inner +); + +{ + package Foo; +} + +eval q{ + package Foo; + use Moose; +}; +ok(!$@, '... Moose succesfully exported into Foo'); + +can_ok('Foo', $_) for @moose_exports; + +eval q{ + package Foo; + no Moose; +}; +ok(!$@, '... Moose succesfully un-exported from Foo'); + +ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports; \ No newline at end of file diff --git a/t/202_example_Moose_POOP.t b/t/202_example_Moose_POOP.t index d8b4c0b..4c6e3cc 100644 --- a/t/202_example_Moose_POOP.t +++ b/t/202_example_Moose_POOP.t @@ -6,8 +6,8 @@ use warnings; use Test::More; BEGIN { - eval "use DBM::Deep;"; - plan skip_all => "DBM::Deep required for this test" if $@; + eval "use DBM::Deep 0.983; use DateTime::Format::MySQL;"; + plan skip_all => "DBM::Deep and DateTime::Format::MySQL required for this test" if $@; plan tests => 89; }