From: sukria Date: Fri, 24 Aug 2007 12:45:34 +0000 (+0000) Subject: new plugin for refreshing loaded modules that changes during the session X-Git-Tag: v1.003015~160 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=13e18b1bb05bc06da163f0077f135e34bf4b2c39;p=p5sagit%2FDevel-REPL.git new plugin for refreshing loaded modules that changes during the session git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@3708 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/Refresh.pm b/lib/Devel/REPL/Plugin/Refresh.pm new file mode 100644 index 0000000..adcfae8 --- /dev/null +++ b/lib/Devel/REPL/Plugin/Refresh.pm @@ -0,0 +1,20 @@ +package Devel::REPL::Plugin::Refresh; + +use Moose::Role; +use namespace::clean -except => [ 'meta' ]; +use Module::Refresh; + +# before evaluating the code, ask Module::Refresh to refresh +# the modules that have changed +around 'eval' => sub { + my $orig = shift; + my ($self, $line) = @_; + + # first refresh the changed modules + Module::Refresh->refresh; + + # the eval the code + return $self->$orig($line); +}; + +1; diff --git a/lib/Devel/REPL/Profile/Default.pm b/lib/Devel/REPL/Profile/Default.pm index 672f367..d22e6de 100644 --- a/lib/Devel/REPL/Profile/Default.pm +++ b/lib/Devel/REPL/Profile/Default.pm @@ -6,7 +6,7 @@ use namespace::clean -except => [ 'meta' ]; with 'Devel::REPL::Profile'; sub plugins { - qw(History LexEnv DDS Packages Commands); + qw(History LexEnv DDS Packages Commands Refresh); } sub apply_profile {