From 3e19fb26f62ce9fa02e417c015f6668989d1eaad Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 7 Aug 2013 22:28:04 -0400 Subject: convert all of the plugins --- lib/Reply/Plugin/CollapseStack.pm | 69 +++++++++++++++------------------------ 1 file changed, 27 insertions(+), 42 deletions(-) (limited to 'lib/Reply/Plugin/CollapseStack.pm') diff --git a/lib/Reply/Plugin/CollapseStack.pm b/lib/Reply/Plugin/CollapseStack.pm index e60c0f5..51cd4fc 100644 --- a/lib/Reply/Plugin/CollapseStack.pm +++ b/lib/Reply/Plugin/CollapseStack.pm @@ -1,9 +1,9 @@ -package Reply::Plugin::CollapseStack; +package main; use strict; use warnings; # ABSTRACT: display error stack traces only on demand -use base 'Reply::Plugin'; +use mop; { local @SIG{qw(__DIE__ __WARN__)}; @@ -26,54 +26,39 @@ the C option. =cut -sub new { - my $class = shift; - my %opts = @_; +class Reply::Plugin::CollapseStack extends Reply::Plugin { + has $num_lines = 1; - my $self = $class->SUPER::new(@_); - $self->{num_lines} = $opts{num_lines} || 1; + has $full_error; - return $self; -} - -sub compile { - my $self = shift; - my ($next, @args) = @_; - - local $SIG{__DIE__} = \&Carp::Always::_die; - $next->(@args); -} - -sub execute { - my $self = shift; - my ($next, @args) = @_; - - local $SIG{__DIE__} = \&Carp::Always::_die; - $next->(@args); -} - -sub mangle_error { - my $self = shift; - my $error = shift; - - $self->{full_error} = $error; + method compile ($next, @args) { + local $SIG{__DIE__} = \&Carp::Always::_die; + $next->(@args); + } - my @lines = split /\n/, $error; - if (@lines > $self->{num_lines}) { - splice @lines, $self->{num_lines}; - $error = join "\n", @lines, " (Run #stack to see the full trace)\n"; + method execute ($next, @args) { + local $SIG{__DIE__} = \&Carp::Always::_die; + $next->(@args); } - return $error; -} + method mangle_error ($error) { + $full_error = $error; -sub command_stack { - my $self = shift; + my @lines = split /\n/, $error; + if (@lines > $num_lines) { + splice @lines, $num_lines; + $error = join "\n", @lines, + " (Run #stack to see the full trace)\n"; + } - # XXX should use print_error here - print($self->{full_error} || "No stack to display.\n"); + return $error; + } - return ''; + method command_stack { + # XXX should use print_error here + print($self->{full_error} || "No stack to display.\n"); + return ''; + } } =for Pod::Coverage -- cgit v1.2.3-54-g00ecf