summaryrefslogtreecommitdiffstats
path: root/lib/App/REPL/Plugin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-05-30 04:41:11 -0500
committerJesse Luehrs <doy@tozt.net>2013-05-30 04:41:11 -0500
commitd8a90a03e9c5e8e2732374a10e0e79289ffb793c (patch)
tree98b6385d26dad2a14687c2c51d402c5b6ebdc837 /lib/App/REPL/Plugin
parent69e4ff7c28debe5cae5bd505d5df12bd12bdd11a (diff)
downloadreply-d8a90a03e9c5e8e2732374a10e0e79289ffb793c.tar.gz
reply-d8a90a03e9c5e8e2732374a10e0e79289ffb793c.zip
App::REPL -> Reply
Diffstat (limited to 'lib/App/REPL/Plugin')
-rw-r--r--lib/App/REPL/Plugin/Colors.pm66
-rw-r--r--lib/App/REPL/Plugin/DataDump.pm15
-rw-r--r--lib/App/REPL/Plugin/DataDumper.pm15
-rw-r--r--lib/App/REPL/Plugin/Defaults.pm64
-rw-r--r--lib/App/REPL/Plugin/FancyPrompt.pm20
-rw-r--r--lib/App/REPL/Plugin/Hints.pm55
-rw-r--r--lib/App/REPL/Plugin/Interrupt.pm23
-rw-r--r--lib/App/REPL/Plugin/LexicalPersistence.pm31
-rw-r--r--lib/App/REPL/Plugin/LoadClass.pm28
-rw-r--r--lib/App/REPL/Plugin/Packages.pm39
-rw-r--r--lib/App/REPL/Plugin/ReadLine.pm25
11 files changed, 0 insertions, 381 deletions
diff --git a/lib/App/REPL/Plugin/Colors.pm b/lib/App/REPL/Plugin/Colors.pm
deleted file mode 100644
index dc00cfd..0000000
--- a/lib/App/REPL/Plugin/Colors.pm
+++ /dev/null
@@ -1,66 +0,0 @@
-package App::REPL::Plugin::Colors;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Term::ANSIColor;
-
-sub new {
- my $class = shift;
-
- my $self = $class->SUPER::new(@_);
- $self->{error} = 'red';
- $self->{warning} = 'yellow';
- $self->{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');
-}
-
-sub print_result {
- my $self = shift;
- my ($next, @result) = @_;
-
- print color($self->{result});
- $next->(@result);
- local $| = 1;
- print color('reset');
-}
-
-sub print_warn {
- my $self = shift;
- my ($warning) = @_;
-
- print color($self->{warning});
- print $warning;
- local $| = 1;
- print color('reset');
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/DataDump.pm b/lib/App/REPL/Plugin/DataDump.pm
deleted file mode 100644
index 7d2934d..0000000
--- a/lib/App/REPL/Plugin/DataDump.pm
+++ /dev/null
@@ -1,15 +0,0 @@
-package App::REPL::Plugin::DataDump;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Data::Dump 'pp';
-
-sub mangle_result {
- my $self = shift;
- my (@result) = @_;
- return @result ? pp(@result) : ();
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/DataDumper.pm b/lib/App/REPL/Plugin/DataDumper.pm
deleted file mode 100644
index 34e520d..0000000
--- a/lib/App/REPL/Plugin/DataDumper.pm
+++ /dev/null
@@ -1,15 +0,0 @@
-package App::REPL::Plugin::DataDumper;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Data::Dumper;
-
-sub mangle_result {
- my $self = shift;
- my (@result) = @_;
- return Dumper(@result);
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/Defaults.pm b/lib/App/REPL/Plugin/Defaults.pm
deleted file mode 100644
index ab533b4..0000000
--- a/lib/App/REPL/Plugin/Defaults.pm
+++ /dev/null
@@ -1,64 +0,0 @@
-package App::REPL::Plugin::Defaults;
-
-# XXX Eval::Closure imposes its own hints on things that are eval'ed at the
-# moment, but this may be fixed in the future
-BEGIN {
- our $default_hints = $^H;
- our $default_hinthash = { %^H };
- our $default_warning_bits = ${^WARNING_BITS};
-}
-
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Eval::Closure;
-
-sub prompt { "> " }
-
-sub read_line {
- my $self = shift;
- my ($next, $prompt) = @_;
-
- print $prompt;
- return scalar <>;
-}
-
-my $PREFIX = "package main; BEGIN { \$^H = \$" . __PACKAGE__ . "::default_hints; \%^H = \%\$" . __PACKAGE__ . "::default_hinthash; \${^WARNING_BITS} = \$" . __PACKAGE__ . "::default_warning_bits }";
-
-sub compile {
- my $self = shift;
- my ($next, $line, %args) = @_;
-
- return eval_closure(
- source => "sub { $PREFIX; $line }",
- terse_error => 1,
- %args,
- );
-}
-
-sub execute {
- my $self = shift;
- my ($next, $code) = @_;
-
- return $code->();
-}
-
-sub print_error {
- my $self = shift;
- my ($next, $error) = @_;
-
- print $error
- if defined $error;
-}
-
-sub print_result {
- my $self = shift;
- my ($next, @result) = @_;
-
- print @result, "\n"
- if @result;
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/FancyPrompt.pm b/lib/App/REPL/Plugin/FancyPrompt.pm
deleted file mode 100644
index 90e8627..0000000
--- a/lib/App/REPL/Plugin/FancyPrompt.pm
+++ /dev/null
@@ -1,20 +0,0 @@
-package App::REPL::Plugin::FancyPrompt;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-sub new {
- my $class = shift;
- my $self = $class->SUPER::new(@_);
- $self->{counter} = 0;
- return $self;
-}
-
-sub prompt {
- my $self = shift;
- my ($next) = @_;
- return $self->{counter}++ . $next->();
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/Hints.pm b/lib/App/REPL/Plugin/Hints.pm
deleted file mode 100644
index a09f117..0000000
--- a/lib/App/REPL/Plugin/Hints.pm
+++ /dev/null
@@ -1,55 +0,0 @@
-package App::REPL::Plugin::Hints;
-
-my $default_hints;
-my $default_hinthash;
-my $default_warning_bits;
-BEGIN {
- $default_hints = $^H;
- $default_hinthash = \%^H;
- $default_warning_bits = ${^WARNING_BITS};
-}
-
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-sub new {
- my $class = shift;
-
- my $self = $class->SUPER::new(@_);
- $self->{hints} = $default_hints;
- $self->{hinthash} = $default_hinthash;
- $self->{warning_bits} = $default_warning_bits;
-
- return $self;
-}
-
-sub mangle_line {
- my $self = shift;
- my ($line) = @_;
-
- return "BEGIN { \$^H = \$" . __PACKAGE__ . "::hints; \%^H = \%\$" . __PACKAGE__ . "::hinthash; \${^WARNING_BITS} = \$" . __PACKAGE__ . "::warning_bits } $line; BEGIN { \$" . __PACKAGE__ . "::hints = \$^H; \$" . __PACKAGE__ . "::hinthash = \\\%^H; \$" . __PACKAGE__ . "::warning_bits = \${^WARNING_BITS} }";
-}
-
-sub compile {
- my $self = shift;
- my ($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
- our $hints = $self->{hints};
- our $hinthash = $self->{hinthash};
- our $warning_bits = $self->{warning_bits};
-
- my @result = $next->($line, %args);
-
- $self->{hints} = $hints;
- $self->{hinthash} = $hinthash;
- $self->{warning_bits} = $warning_bits;
-
- return @result;
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/Interrupt.pm b/lib/App/REPL/Plugin/Interrupt.pm
deleted file mode 100644
index d993a15..0000000
--- a/lib/App/REPL/Plugin/Interrupt.pm
+++ /dev/null
@@ -1,23 +0,0 @@
-package App::REPL::Plugin::Interrupt;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-sub compile {
- my $self = shift;
- my ($next, @args) = @_;
-
- local $SIG{INT} = sub { die "Interrupted" };
- $next->(@args);
-}
-
-sub execute {
- my $self = shift;
- my ($next, @args) = @_;
-
- local $SIG{INT} = sub { die "Interrupted" };
- $next->(@args);
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/LexicalPersistence.pm b/lib/App/REPL/Plugin/LexicalPersistence.pm
deleted file mode 100644
index 986fa03..0000000
--- a/lib/App/REPL/Plugin/LexicalPersistence.pm
+++ /dev/null
@@ -1,31 +0,0 @@
-package App::REPL::Plugin::LexicalPersistence;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Lexical::Persistence;
-
-sub new {
- my $class = shift;
- my $self = $class->SUPER::new(@_);
- $self->{env} = Lexical::Persistence->new;
- return $self;
-}
-
-sub compile {
- my $self = shift;
- my ($next, $line, %args) = @_;
-
- my %c = %{ $self->{env}->get_context('_') };
-
- $args{environment} ||= {};
- $args{environment} = {
- %{ $args{environment} },
- (map { $_ => ref($c{$_}) ? $c{$_} : \$c{$_} } keys %c),
- };
- my ($code) = $next->($line, %args);
- return $self->{env}->wrap($code);
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/LoadClass.pm b/lib/App/REPL/Plugin/LoadClass.pm
deleted file mode 100644
index 9a48b22..0000000
--- a/lib/App/REPL/Plugin/LoadClass.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package App::REPL::Plugin::LoadClass;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Module::Runtime 'use_package_optimistically';
-use Try::Tiny;
-
-sub execute {
- my $self = shift;
- my ($next, @args) = @_;
-
- try {
- $next->(@args);
- }
- catch {
- if (/^Can't locate object method "[^"]*" via package "([^"]*)"/) {
- use_package_optimistically($1);
- $next->(@args);
- }
- else {
- die $_;
- }
- }
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/Packages.pm b/lib/App/REPL/Plugin/Packages.pm
deleted file mode 100644
index c1c02d0..0000000
--- a/lib/App/REPL/Plugin/Packages.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-package App::REPL::Plugin::Packages;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-sub new {
- my $class = shift;
-
- my $self = $class->SUPER::new(@_);
- $self->{package} = 'main';
-
- return $self;
-}
-
-sub mangle_line {
- my $self = shift;
- my ($line) = @_;
-
- return "package $self->{package}; $line; BEGIN { \$" . __PACKAGE__ . "::package = __PACKAGE__ }";
-}
-
-sub compile {
- my $self = shift;
- my ($next, @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
- our $package = $self->{package};
-
- my @result = $next->(@args);
-
- $self->{package} = $package;
-
- return @result;
-}
-
-1;
diff --git a/lib/App/REPL/Plugin/ReadLine.pm b/lib/App/REPL/Plugin/ReadLine.pm
deleted file mode 100644
index f2fe847..0000000
--- a/lib/App/REPL/Plugin/ReadLine.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-package App::REPL::Plugin::ReadLine;
-use strict;
-use warnings;
-
-use base 'App::REPL::Plugin';
-
-use Term::ReadLine;
-
-sub new {
- my $class = shift;
-
- my $self = $class->SUPER::new(@_);
- $self->{term} = Term::ReadLine->new('App::REPL');
-
- return $self;
-}
-
-sub read_line {
- my $self = shift;
- my ($next, $prompt) = @_;
-
- return $self->{term}->readline($prompt);
-}
-
-1;