Permalink
Browse files

Tidied.

  • Loading branch information...
1 parent d1bcf26 commit b0b7e4c4846d79e3635dc08aa377baeefeec133e @AndyA committed Mar 11, 2012
Showing with 64 additions and 61 deletions.
  1. +39 −39 lib/Devel/Unplug.pm
  2. +6 −6 lib/Devel/Unplug/OO.pm
  3. +2 −2 t/000-load.t
  4. +9 −7 t/commandline.t
  5. +4 −4 t/nest.t
  6. +3 −2 t/pod-coverage.t
  7. +1 −1 t/wildcard.t
View
@@ -35,25 +35,25 @@ C<use>) and intercept attempts to load modules.
=cut
sub _get_module {
- my $file = shift;
- $file =~ s{/}{::}g;
- $file =~ s/[.]pm$//;
- return $file;
+ my $file = shift;
+ $file =~ s{/}{::}g;
+ $file =~ s/[.]pm$//;
+ return $file;
}
my %unplugged;
sub _is_unplugged {
- my $module = shift;
+ my $module = shift;
- for my $unp ( unplugged() ) {
- return 1
- if ( 'Regexp' eq ref $unp )
- ? $module =~ $unp
- : $module eq $unp;
- }
+ for my $unp ( unplugged() ) {
+ return 1
+ if ( 'Regexp' eq ref $unp )
+ ? $module =~ $unp
+ : $module eq $unp;
+ }
- return;
+ return;
}
=head1 INTERFACE
@@ -74,11 +74,11 @@ Regular expressions may be used:
=cut
sub unplug {
- for my $unp ( @_ ) {
- exists $unplugged{$unp} and $unplugged{$unp}->[1]++
- or $unplugged{$unp} = [ $unp, 1 ];
- }
- return;
+ for my $unp ( @_ ) {
+ exists $unplugged{$unp} and $unplugged{$unp}->[1]++
+ or $unplugged{$unp} = [ $unp, 1 ];
+ }
+ return;
}
=head2 C<< insert >>
@@ -93,28 +93,28 @@ was called to make it available again.
=cut
sub insert {
- for my $mod ( @_ ) {
- delete $unplugged{$mod}
- if exists $unplugged{$mod} && 0 == --$unplugged{$mod}->[1];
- }
- return;
+ for my $mod ( @_ ) {
+ delete $unplugged{$mod}
+ if exists $unplugged{$mod} && 0 == --$unplugged{$mod}->[1];
+ }
+ return;
}
BEGIN {
- use Devel::TraceLoad::Hook qw( register_require_hook );
- register_require_hook(
- sub {
- my ( $when, $depth, $arg, $p, $f, $l, $rc, $err ) = @_;
-
- return unless $when eq 'before';
- my $module = _get_module( $arg );
- return unless _is_unplugged( $module );
-
- # Ain't gonna let you load it
- die "Can't locate $arg in \@INC (unplugged by "
- . __PACKAGE__ . ")";
- }
- );
+ use Devel::TraceLoad::Hook qw( register_require_hook );
+ register_require_hook(
+ sub {
+ my ( $when, $depth, $arg, $p, $f, $l, $rc, $err ) = @_;
+
+ return unless $when eq 'before';
+ my $module = _get_module( $arg );
+ return unless _is_unplugged( $module );
+
+ # Ain't gonna let you load it
+ die "Can't locate $arg in \@INC (unplugged by "
+ . __PACKAGE__ . ")";
+ }
+ );
}
=head2 C<< unplugged >>
@@ -125,12 +125,12 @@ contain a mixture of regular expressions and plain strings.
=cut
sub unplugged {
- map { $_->[0] } values %unplugged;
+ map { $_->[0] } values %unplugged;
}
sub import {
- my $class = shift;
- unplug( @_ );
+ my $class = shift;
+ unplug( @_ );
}
1;
View
@@ -54,15 +54,15 @@ be re-inserted.
=cut
sub new {
- my $class = shift;
- my $self = bless [@_], $class;
- Devel::Unplug::unplug( @$self );
- return $self;
+ my $class = shift;
+ my $self = bless [@_], $class;
+ Devel::Unplug::unplug( @$self );
+ return $self;
}
sub DESTROY {
- my $self = shift;
- Devel::Unplug::insert( @$self );
+ my $self = shift;
+ Devel::Unplug::insert( @$self );
}
1;
View
@@ -1,8 +1,8 @@
use Test::More tests => 2;
BEGIN {
- use_ok( 'Devel::Unplug' );
- use_ok( 'Devel::Unplug::OO' );
+ use_ok( 'Devel::Unplug' );
+ use_ok( 'Devel::Unplug::OO' );
}
diag( "Testing Devel::Unplug $Devel::Unplug::VERSION" );
View
@@ -9,14 +9,16 @@ my @nop = ( '-e', '0' );
like tryit( @cmd, '-MSome::Module', @nop ), qr{^\s*$}, "no error";
-like tryit( @cmd, '-Ilib', '-MDevel::Unplug=Some::Module', '-MSome::Module', @nop ),
- qr{Can't\s+locate\s+Some/Module.pm}, "error message";
+like tryit( @cmd, '-Ilib', '-MDevel::Unplug=Some::Module',
+ '-MSome::Module', @nop ),
+ qr{Can't\s+locate\s+Some/Module.pm}, "error message";
-like tryit( @cmd, '-Ilib', '-MDevel::Unplug=Some::Module', '-MSome::Other::Module', @nop ),
- qr{^\s*$}, "no crosstalk";
+like tryit( @cmd, '-Ilib', '-MDevel::Unplug=Some::Module',
+ '-MSome::Other::Module', @nop ),
+ qr{^\s*$}, "no crosstalk";
sub tryit {
- my @cmd = @_;
- run \@cmd, \my $in, \my $out, \my $err, timeout( 10 );
- return $err;
+ my @cmd = @_;
+ run \@cmd, \my $in, \my $out, \my $err, timeout( 10 );
+ return $err;
}
View
@@ -6,10 +6,10 @@ use Devel::Unplug;
use lib 't/lib';
sub is_unplugged($;$) {
- my ( $list, $desc ) = @_;
- $desc ||= join( ', ', @$list );
- my @unp = Devel::Unplug::unplugged();
- is_deeply [ sort @unp ], [ sort @$list ], $desc;
+ my ( $list, $desc ) = @_;
+ $desc ||= join( ', ', @$list );
+ my @unp = Devel::Unplug::unplugged();
+ is_deeply [ sort @unp ], [ sort @$list ], $desc;
}
Devel::Unplug::unplug( 'Some::Module', qr{^Other::} ) for 1 .. 2;
View
@@ -2,6 +2,7 @@
use Test::More;
eval "use Test::Pod::Coverage 1.04";
-plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage"
- if $@;
+plan skip_all =>
+ "Test::Pod::Coverage 1.04 required for testing POD coverage"
+ if $@;
all_pod_coverage_ok( { private => [ qr{^import|DESTROY$}, qr{^_} ] } );
View
@@ -16,7 +16,7 @@ eval "use Some::Other::Module";
like $@, qr{Can't\s+locate\s+Some/Other/Module.pm}, "error message";
my @unp = Devel::Unplug::unplugged();
-is_deeply \@unp, [ $match ], "unplugged OK";
+is_deeply \@unp, [$match], "unplugged OK";
Devel::Unplug::insert( $match );
eval "use Some::Module";

0 comments on commit b0b7e4c

Please sign in to comment.