Browse files

Import namespace-clean-0.07.tar.gz.

  • Loading branch information...
1 parent 99d2e6b commit 1a1be5dc205173c95164e59932ef58652a223975 @rafl committed Mar 8, 2008
Showing with 48 additions and 21 deletions.
  1. +4 −0 Changes
  2. +3 −3 META.yml
  3. +1 −1 Makefile.PL
  4. +15 −5 README
  5. +24 −11 lib/namespace/clean.pm
  6. +1 −1 t/00-basic.t
View
4 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.
View
6 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
View
2 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;
View
20 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 "<rs@474.at>", with many thanks to Matt S
View
35 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<import> 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<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
@@ -88,9 +101,8 @@ appropriate place.
=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
@@ -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<undef> instead.
=head1 SEE ALSO
-L<Filter::EOF>
+L<Scope::Guard>
=head1 AUTHOR AND COPYRIGHT
View
2 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' );
}

0 comments on commit 1a1be5d

Please sign in to comment.