new plugin for refreshing loaded modules that changes during the session
sukria [Fri, 24 Aug 2007 12:45:34 +0000 (12:45 +0000)]
git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@3708 bd8105ee-0ff8-0310-8827-fb3f25b6796d

lib/Devel/REPL/Plugin/Refresh.pm [new file with mode: 0644]
lib/Devel/REPL/Profile/Default.pm

diff --git a/lib/Devel/REPL/Plugin/Refresh.pm b/lib/Devel/REPL/Plugin/Refresh.pm
new file mode 100644 (file)
index 0000000..adcfae8
--- /dev/null
@@ -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;
index 672f367..d22e6de 100644 (file)
@@ -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 {