From: Florian Ragwitz Date: Sat, 8 Mar 2008 23:00:00 +0000 (+0100) Subject: Import namespace-clean-0.07.tar.gz. X-Git-Tag: 0.07^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1a1be5dc205173c95164e59932ef58652a223975;p=p5sagit%2Fnamespace-clean.git Import namespace-clean-0.07.tar.gz. --- diff --git a/Changes b/Changes index 9914807..f7e3fba 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,8 @@ + [0.07] Sun Mar 9 20:13:33 CET 2008 + - Switched from Filter::EOF to a much saner implementation via + %^H and Scope::Guard. (mst & autobox)++ for this. + [0.06] Wed Feb 20 15:09:00 CET 2008 - Fixed 'uninitialized value in ref-to-glob cast' error if unimport was used before. diff --git a/META.yml b/META.yml index ded02a6..2edf41b 100644 --- a/META.yml +++ b/META.yml @@ -18,9 +18,9 @@ no_index: provides: namespace::clean: file: lib/namespace/clean.pm - version: 0.06 + version: 0.07 requires: - Filter::EOF: 0.02 + Scope::Guard: 0.02 Symbol: 0 tests: t/*.t t_author/*.t -version: 0.06 +version: 0.07 diff --git a/Makefile.PL b/Makefile.PL index 4e7f748..07f8f62 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -12,7 +12,7 @@ all_from q{lib/namespace/clean.pm}; build_requires q{Test::More}, '0.62'; build_requires q{FindBin}, 0; -requires q{Filter::EOF}, '0.02'; +requires q{Scope::Guard}, '0.02'; requires q{Symbol}, 0; auto_provides; diff --git a/README b/README index 53a90ff..0548c31 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME namespace::clean - Keep imports and functions out of your namespace VERSION - 0.06 + 0.07 SYNOPSIS package Foo; @@ -59,14 +59,24 @@ DESCRIPTION If you just want to "-except" a single sub, you can pass it directly. For more than one value you have to use an array reference. + Moose + When using "namespace::clean" together with Moose you want to keep the + installed "meta" method. So your classes should look like: + + package Foo; + use Moose; + use namespace::clean -except => 'meta'; + ... + + Same goes for Moose::Role. + METHODS You shouldn't need to call any of these. Just "use" the package at the appropriate place. import - Makes a snapshot of the current defined functions and registers a - Filter::EOF cleanup routine to remove those symbols at the end of the - compile-time. + Makes a snapshot of the current defined functions and installs a + Scope::Guard in the current scope to invoke the cleanups. unimport This method will be called when you do a @@ -101,7 +111,7 @@ IMPLEMENTATION DETAILS use "undef" instead. SEE ALSO - Filter::EOF + Scope::Guard AUTHOR AND COPYRIGHT Robert 'phaylon' Sedlacek "", with many thanks to Matt S diff --git a/lib/namespace/clean.pm b/lib/namespace/clean.pm index d11a7c4..9aaa51a 100644 --- a/lib/namespace/clean.pm +++ b/lib/namespace/clean.pm @@ -9,18 +9,19 @@ namespace::clean - Keep imports and functions out of your namespace use warnings; use strict; -use vars qw( $VERSION $STORAGE_VAR ); -use Symbol qw( qualify_to_ref ); -use Filter::EOF; +use vars qw( $VERSION $STORAGE_VAR $SCOPE_HOOK_KEY ); +use Symbol qw( qualify_to_ref ); +use Scope::Guard; =head1 VERSION -0.06 +0.07 =cut -$VERSION = 0.06; -$STORAGE_VAR = '__NAMESPACE_CLEAN_STORAGE'; +$VERSION = 0.07; +$STORAGE_VAR = '__NAMESPACE_CLEAN_STORAGE'; +$SCOPE_HOOK_KEY = 'namespace_clean_SCOPING'; =head1 SYNOPSIS @@ -79,6 +80,18 @@ be a module exporting an C method along with some functions: If you just want to C<-except> a single sub, you can pass it directly. For more than one value you have to use an array reference. +=head2 Moose + +When using C together with L you want to keep +the installed C method. So your classes should look like: + + package Foo; + use Moose; + use namespace::clean -except => 'meta'; + ... + +Same goes for L. + =head1 METHODS You shouldn't need to call any of these. Just C the package at the @@ -88,9 +101,8 @@ appropriate place. =head2 import -Makes a snapshot of the current defined functions and registers a -L cleanup routine to remove those symbols at the end -of the compile-time. +Makes a snapshot of the current defined functions and installs a +L in the current scope to invoke the cleanups. =cut @@ -119,7 +131,8 @@ sub import { # register EOF handler on first call to import unless ($store->{handler_is_installed}) { - Filter::EOF->on_eof_call(sub { + $^H |= 0x120000; + $^H{ $SCOPE_HOOK_KEY } = Scope::Guard->new(sub { SYMBOL: for my $f (keys %{ $store->{remove} }) { @@ -227,7 +240,7 @@ use C instead. =head1 SEE ALSO -L +L =head1 AUTHOR AND COPYRIGHT diff --git a/t/00-basic.t b/t/00-basic.t index e64a7fa..fc59562 100644 --- a/t/00-basic.t +++ b/t/00-basic.t @@ -10,7 +10,7 @@ use ExporterTest qw( foo bar ); BEGIN { ok( main->can('foo'), 'methods are there before cleanup' ); - eval { use namespace::clean }; + eval { require namespace::clean ;; namespace::clean->import }; ok( !$@, 'module use ok' ); }