From: matthewt Date: Sun, 22 Apr 2007 14:32:44 +0000 (+0000) Subject: rejig to provide $REPL instead of $self, fix namespace::clean usage to not nuke meta X-Git-Tag: v1.003015~171 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=commitdiff_plain;h=48ddfeae8a9840b39113a97c4889bfe210509cdd rejig to provide $REPL instead of $self, fix namespace::clean usage to not nuke meta git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@3205 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL.pm b/lib/Devel/REPL.pm index ff461f5..c52f0bf 100644 --- a/lib/Devel/REPL.pm +++ b/lib/Devel/REPL.pm @@ -2,7 +2,7 @@ package Devel::REPL; use Term::ReadLine; use Moose; -use namespace::clean; +use namespace::clean -except => [ 'meta' ]; with 'MooseX::Object::Pluggable'; @@ -51,9 +51,9 @@ sub eval { } sub compile { - my ($self, $line) = @_; - my $compiled = eval $self->wrap_as_sub($line); - return (undef, $self->error_return("Compile error", $@)) if $@; + my $REPL = shift; + my $compiled = eval $REPL->wrap_as_sub($_[0]); + return (undef, $REPL->error_return("Compile error", $@)) if $@; return $compiled; } @@ -68,9 +68,9 @@ sub mangle_line { } sub execute { - my $REPL = shift; - my @ret = eval { shift->(@_) }; - return $REPL->error_return("Runtime error", $@) if $@; + my ($self, $to_exec, @args) = @_; + my @ret = eval { $to_exec->(@args) }; + return $self->error_return("Runtime error", $@) if $@; return @ret; } diff --git a/lib/Devel/REPL/Plugin/History.pm b/lib/Devel/REPL/Plugin/History.pm index 1c51efb..d95ff07 100644 --- a/lib/Devel/REPL/Plugin/History.pm +++ b/lib/Devel/REPL/Plugin/History.pm @@ -1,6 +1,7 @@ package Devel::REPL::Plugin::History; use Moose::Role; +use namespace::clean -except => [ 'meta' ]; has 'history' => ( isa => 'ArrayRef', is => 'rw', required => 1, lazy => 1, diff --git a/lib/Devel/REPL/Plugin/NewlineHack.pm b/lib/Devel/REPL/Plugin/NewlineHack.pm index 96a464f..076b8ac 100644 --- a/lib/Devel/REPL/Plugin/NewlineHack.pm +++ b/lib/Devel/REPL/Plugin/NewlineHack.pm @@ -5,8 +5,7 @@ package Devel::REPL::Plugin::NewlineHack; use Moose::Role; - -use Data::Dumper; +use namespace::clean -except => [ 'meta' ]; after 'print' => sub { # not fussed about args diff --git a/lib/Devel/REPL/Plugin/ShowClass.pm b/lib/Devel/REPL/Plugin/ShowClass.pm index dd90fd5..0697291 100644 --- a/lib/Devel/REPL/Plugin/ShowClass.pm +++ b/lib/Devel/REPL/Plugin/ShowClass.pm @@ -1,5 +1,6 @@ package Devel::REPL::Plugin::ShowClass; use Moose::Role; +use namespace::clean -except => [ 'meta' ]; has 'metaclass_cache' => ( is => 'ro', diff --git a/lib/Devel/REPL/Plugin/Turtles.pm b/lib/Devel/REPL/Plugin/Turtles.pm index dbc7322..5faafc6 100644 --- a/lib/Devel/REPL/Plugin/Turtles.pm +++ b/lib/Devel/REPL/Plugin/Turtles.pm @@ -1,11 +1,12 @@ package Devel::REPL::Plugin::Turtles; use Moose::Role; +use namespace::clean -except => [ 'meta' ]; around 'eval' => sub { my $next = shift; my ($self, $line) = @_; if ($line =~ /^#(.*)/) { - return $next->($self, ('$self->' . $1 . '; return();')); + return $next->($self, ('$REPL->' . $1 . '; return();')); } else { return $next->($self, $line); @@ -13,4 +14,4 @@ around 'eval' => sub { }; -1; \ No newline at end of file +1;