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/Colors.pm | 91 ++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 56 deletions(-) (limited to 'lib/Reply/Plugin/Colors.pm') diff --git a/lib/Reply/Plugin/Colors.pm b/lib/Reply/Plugin/Colors.pm index aa7e1ef..56c145d 100644 --- a/lib/Reply/Plugin/Colors.pm +++ b/lib/Reply/Plugin/Colors.pm @@ -1,9 +1,9 @@ -package Reply::Plugin::Colors; +package main; use strict; use warnings; # ABSTRACT: colorize output -use base 'Reply::Plugin'; +use mop; use Term::ANSIColor; BEGIN { @@ -17,9 +17,9 @@ BEGIN { ; .replyrc [Colors] - error = bright red - warning = bright yellow - result = bright green + error_color = bright red + warning_color = bright yellow + result_color = bright green =head1 DESCRIPTION @@ -32,62 +32,41 @@ C options. =cut -sub new { - my $class = shift; - my %opts = @_; +class Reply::Plugin::Colors extends Reply::Plugin { + has $error_color = 'red'; + has $warning_color = 'yellow'; + has $result_color = 'green'; - my $self = $class->SUPER::new(@_); - $self->{error} = $opts{error} || 'red'; - $self->{warning} = $opts{warning} || 'yellow'; - $self->{result} = $opts{result} || 'green'; - - return $self; -} - -sub compile { - my $self = shift; - my ($next, @args) = @_; - - local $SIG{__WARN__} = sub { $self->print_warn(@_) }; - $next->(@args); -} - -sub execute { - my $self = shift; - my ($next, @args) = @_; - - local $SIG{__WARN__} = sub { $self->print_warn(@_) }; - $next->(@args); -} - -sub print_error { - my $self = shift; - my ($next, $error) = @_; - - print color($self->{error}); - $next->($error); - local $| = 1; - print color('reset'); -} + method compile ($next, @args) { + local $SIG{__WARN__} = sub { $self->print_warn(@_) }; + $next->(@args); + } -sub print_result { - my $self = shift; - my ($next, @result) = @_; + method execute ($next, @args) { + local $SIG{__WARN__} = sub { $self->print_warn(@_) }; + $next->(@args); + } - print color($self->{result}); - $next->(@result); - local $| = 1; - print color('reset'); -} + method print_error ($next, $error) { + print color($error_color); + $next->($error); + local $| = 1; + print color('reset'); + } -sub print_warn { - my $self = shift; - my ($warning) = @_; + method print_result ($next, @result) { + print color($result_color); + $next->(@result); + local $| = 1; + print color('reset'); + } - print color($self->{warning}); - print $warning; - local $| = 1; - print color('reset'); + method print_warn ($warning) { + print color($warning_color); + print $warning; + local $| = 1; + print color('reset'); + } } =for Pod::Coverage -- cgit v1.2.3-54-g00ecf