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/Packages.pm | 54 ++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'lib/Reply/Plugin/Packages.pm') diff --git a/lib/Reply/Plugin/Packages.pm b/lib/Reply/Plugin/Packages.pm index 75b459e..d2896d4 100644 --- a/lib/Reply/Plugin/Packages.pm +++ b/lib/Reply/Plugin/Packages.pm @@ -1,9 +1,9 @@ -package Reply::Plugin::Packages; +package main; use strict; use warnings; # ABSTRACT: persist the current package between lines -use base 'Reply::Plugin'; +use mop; =head1 SYNOPSIS @@ -20,47 +20,37 @@ initial package to use when Reply starts up. =cut -sub new { - my $class = shift; - my %opts = @_; +class Reply::Plugin::Packages extends Reply::Plugin { + has $package = 'main'; - my $self = $class->SUPER::new(@_); - $self->{package} = $opts{default_package} || 'main'; + submethod BUILD ($args) { + $package = $args->{default_package} + if defined $args->{default_package}; + } - return $self; -} - -sub mangle_line { - my $self = shift; - my ($line) = @_; - - my $package = __PACKAGE__; - return <($line, %args); + method compile ($next, $line, %args) { + my @result = $next->($line, %args); - # XXX it'd be nice to avoid using globals here, but we can't use - # eval_closure's environment parameter since we need to access the - # information in a BEGIN block - $self->{package} = our $package; + # XXX it'd be nice to avoid using globals here, but we can't use + # eval_closure's environment parameter since we need to access the + # information in a BEGIN block + $package = our $PACKAGE; - return @result; -} + return @result; + } -sub package { - my $self = shift; - return $self->{package}; + method package { $package } } 1; -- cgit v1.2.3-54-g00ecf