diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-08-07 22:28:04 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-09-03 16:50:15 -0400 |
commit | 3e19fb26f62ce9fa02e417c015f6668989d1eaad (patch) | |
tree | 411f3292cf712606ad177b5229314eb739db4b7b /lib/Reply/Plugin/Packages.pm | |
parent | 7df1338f58d10c01cf8f742832b57b2736dbf301 (diff) | |
download | reply-3e19fb26f62ce9fa02e417c015f6668989d1eaad.tar.gz reply-3e19fb26f62ce9fa02e417c015f6668989d1eaad.zip |
convert all of the plugins
Diffstat (limited to 'lib/Reply/Plugin/Packages.pm')
-rw-r--r-- | lib/Reply/Plugin/Packages.pm | 54 |
1 files changed, 22 insertions, 32 deletions
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; + method mangle_line ($line) { + my $package = __PACKAGE__; + return <<LINE; $line ; BEGIN { - \$${package}::package = __PACKAGE__; + \$${package}::PACKAGE = __PACKAGE__; } LINE -} - -sub compile { - my $self = shift; - my ($next, $line, %args) = @_; + } - my @result = $next->($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; |