increment $VERSION after 1.003029 release
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Colors.pm
index 898437d..4452e14 100644 (file)
@@ -1,8 +1,13 @@
+use strict;
+use warnings;
 package Devel::REPL::Plugin::Colors;
+# ABSTRACT: Add color to return values, warnings, and errors
 
-use Moose::Role;
+our $VERSION = '1.003030';
+
+use Devel::REPL::Plugin;
 use Term::ANSIColor;
-use namespace::clean -except => [ 'meta' ];
+use namespace::autoclean;
 
 has normal_color => (
   is => 'rw', lazy => 1,
@@ -14,7 +19,7 @@ has error_color => (
   default => 'bold red',
 );
 
-around error_return => sub {
+around format_error => sub {
   my $orig = shift;
   my $self = shift;
   return color($self->error_color)
@@ -23,12 +28,15 @@ around error_return => sub {
 };
 
 # we can't just munge @_ because that screws up DDS
-around print => sub {
+around format_result => sub {
   my $orig = shift;
   my $self = shift;
-  print {$self->out_fh} color($self->normal_color);
-  $orig->($self, @_);
-  print {$self->out_fh} color('reset');
+  no warnings 'uninitialized';
+  return join "", (
+    color($self->normal_color),
+    $orig->($self, @_),
+    color('reset'),
+  );
 };
 
 # make arbitrary warns colored -- somewhat difficult because warn doesn't
@@ -58,15 +66,10 @@ around execute => \&_wrap_warn;
 
 __END__
 
-=head1 NAME
-
-Devel::REPL::Plugin::Colors - add color to return values, warnings, and errors
+=pod
 
 =head1 SYNOPSIS
 
-    #!/usr/bin/perl 
-
-    use lib './lib';
     use Devel::REPL;
 
     my $repl = Devel::REPL->new;