[Bast-commits] r4344 - in trunk/Devel-REPL: . lib/Devel/REPL/Plugin
Sartak at dev.catalyst.perl.org
Sartak at dev.catalyst.perl.org
Tue May 6 09:15:11 BST 2008
Author: Sartak
Date: 2008-05-06 09:15:11 +0100 (Tue, 06 May 2008)
New Revision: 4344
Added:
trunk/Devel-REPL/lib/Devel/REPL/Plugin/Nopaste.pm
Modified:
trunk/Devel-REPL/Makefile.PL
Log:
Add a Nopaste plugin. #nopaste will publish your current session using App::Nopaste
Modified: trunk/Devel-REPL/Makefile.PL
===================================================================
--- trunk/Devel-REPL/Makefile.PL 2008-05-06 08:05:54 UTC (rev 4343)
+++ trunk/Devel-REPL/Makefile.PL 2008-05-06 08:15:11 UTC (rev 4344)
@@ -21,6 +21,7 @@
requires 'Term::ANSIColor';
requires 'B::Keywords';
requires 'Task::Weaken';
+requires 'App::Nopaste';
auto_install;
WriteAll;
Added: trunk/Devel-REPL/lib/Devel/REPL/Plugin/Nopaste.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/Nopaste.pm (rev 0)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/Nopaste.pm 2008-05-06 08:15:11 UTC (rev 4344)
@@ -0,0 +1,50 @@
+package Devel::REPL::Plugin::Nopaste;
+
+use Moose::Role;
+use MooseX::AttributeHelpers;
+use namespace::clean -except => [ 'meta' ];
+
+with 'Devel::REPL::Plugin::Turtles';
+
+has complete_session => (
+ metaclass => 'String',
+ is => 'rw',
+ isa => 'Str',
+ default => '',
+ provides => {
+ append => 'add_to_session',
+ },
+);
+
+around eval => sub {
+ my $orig = shift;
+ my $self = shift;
+ my $line = shift;
+
+ my @ret = $orig->($self, $line, @_);
+
+ # prepend each line with #
+ $line =~ s/^/# /mg;
+
+ my $step = $line . "\n"
+ . join("\n", @ret)
+ . "\n\n";
+
+ $self->add_to_session($step);
+
+ return @ret;
+};
+
+sub command_nopaste {
+ my $self = shift;
+
+ require App::Nopaste;
+ return App::Nopaste->nopaste(
+ text => $self->complete_session,
+ desc => "Devel::REPL session",
+ lang => "perl",
+ );
+}
+
+1;
+
More information about the Bast-commits
mailing list