diff options
author | Tom Feist <shabble@metavore.org> | 2011-02-21 03:42:44 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-02-21 03:42:44 +0000 |
commit | 3916b2945123f211c40ccc19d876474ed3478950 (patch) | |
tree | cac14219236f87cbe19ffe372fe2431eb6b333dc /testing/lib/Test/Irssi.pm | |
parent | start of makign this a proper module (diff) | |
download | irssi-scripts-3916b2945123f211c40ccc19d876474ed3478950.tar.gz irssi-scripts-3916b2945123f211c40ccc19d876474ed3478950.zip |
moving a whole bunch of code around into a modular sort of thing. Still a big WIP
Diffstat (limited to 'testing/lib/Test/Irssi.pm')
-rw-r--r-- | testing/lib/Test/Irssi.pm | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/testing/lib/Test/Irssi.pm b/testing/lib/Test/Irssi.pm index cb350ee..f4acb71 100644 --- a/testing/lib/Test/Irssi.pm +++ b/testing/lib/Test/Irssi.pm @@ -1,5 +1,5 @@ use strictures 1; -use MooseX::Declare +use MooseX::Declare; our $VERSION = 0.01; @@ -10,6 +10,12 @@ class Test::Irssi { use feature qw/say switch/; use Data::Dump; use IO::File; + use Test::Irssi::Driver; + + # requires the latest pre-release POE from + # https://github.com/rcaputo/poe until a new release is...released. + use POE; + has 'irssi_binary' => ( @@ -41,6 +47,15 @@ class Test::Irssi { default => 24, ); + has 'vt' + => ( + is => 'ro', + isa => 'Term::VT102', + required => 1, + lazy => 1, + builder => '_build_vt102', + ); + has 'logfile' => ( is => 'ro', @@ -58,9 +73,46 @@ class Test::Irssi { builder => '_build_logfile_fh', ); + has '_driver' + => ( + is => 'ro', + isa => 'Test::Irssi::Driver', + required => 1, + lazy => 1, + builder => '_build_driver', + ); + + method _build_driver { + my $drv = Test::Irssi::Driver->new(parent => $self); + return $drv; + } + + method _build_vt102 { + my $rows = $self->terminal_height; + my $cols = $self->terminal_width; + + my $vt = Term::VT102->new($cols, $rows); + + # options + $vt->option_set(LINEWRAP => 1); + $vt->option_set(LFTOCRLF => 1); + + # callbacks + $vt->callback_set(OUTPUT => \&vt_output, undef); + $vt->callback_set(ROWCHANGE => \&vt_rowchange, undef); + $vt->callback_set(CLEAR => \&vt_clear, undef); + $vt->callback_set(SCROLL_DOWN => \&vt_scr_dn, undef); + $vt->callback_set(SCROLL_UP => \&vt_scr_up, undef); + $vt->callback_set(GOTO => \&vt_goto, undef); + + return $vt; + } method _build_logfile_fh { - my $fh = IO::File->new($self->logfile, 'w'); + + my $logfile = $self->logfile; + + my $fh = IO::File->new($logfile, 'w'); die "Couldn't open $logfile for writing: $!" unless defined $fh; $fh->autoflush(1); @@ -68,22 +120,25 @@ class Test::Irssi { } + method log (Str $msg) { + $self->_logfile_fh->say($msg); + } + method run { - method log (Str $msg) { - say $self->_logfile_fh $msg; + ### Start a session to encapsulate the previous features. + $poe_kernel->run(); } } -__END__ -=head1 NAME -Test::Irssi -=head1 ABSTRACT +__END__ + +=head1 NAME -Abstract goes here +Test::Irssi - A cunning testing system for Irssi scripts =head1 SYNOPSIS |