From: Sartak Date: Tue, 6 May 2008 08:15:11 +0000 (+0000) Subject: Add a Nopaste plugin. #nopaste will publish your current session using App::Nopaste X-Git-Tag: v1.003015~118 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24cc824faa918e5ac9f61b122d7e22b1fc47219d;p=p5sagit%2FDevel-REPL.git Add a Nopaste plugin. #nopaste will publish your current session using App::Nopaste git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4344 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/Makefile.PL b/Makefile.PL index fa92208..57b70ca 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -21,6 +21,7 @@ requires 'PPI'; requires 'Term::ANSIColor'; requires 'B::Keywords'; requires 'Task::Weaken'; +requires 'App::Nopaste'; auto_install; WriteAll; diff --git a/lib/Devel/REPL/Plugin/Nopaste.pm b/lib/Devel/REPL/Plugin/Nopaste.pm new file mode 100644 index 0000000..19e30ae --- /dev/null +++ b/lib/Devel/REPL/Plugin/Nopaste.pm @@ -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; +