+ [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.
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
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;
namespace::clean - Keep imports and functions out of your namespace
VERSION
- 0.06
+ 0.07
SYNOPSIS
package Foo;
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
use "undef" instead.
SEE ALSO
- Filter::EOF
+ Scope::Guard
AUTHOR AND COPYRIGHT
Robert 'phaylon' Sedlacek "<rs@474.at>", with many thanks to Matt S
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
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<namespace::clean> together with L<Moose> you want to keep
+the installed C<meta> method. So your classes should look like:
+
+ package Foo;
+ use Moose;
+ use namespace::clean -except => 'meta';
+ ...
+
+Same goes for L<Moose::Role>.
+
=head1 METHODS
You shouldn't need to call any of these. Just C<use> the package at the
=head2 import
-Makes a snapshot of the current defined functions and registers a
-L<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
+L<Scope::Guard> in the current scope to invoke the cleanups.
=cut
# 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} }) {
=head1 SEE ALSO
-L<Filter::EOF>
+L<Scope::Guard>
=head1 AUTHOR AND COPYRIGHT
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' );
}