Author: dylan
Date: 2004-12-28 02:58:52 -0500 (Tue, 28 Dec 2004)
New Revision: 435
Added:
trunk/main/core/lib/Haver/Protocol/Filter.pm
Removed:
trunk/main/core/lib/Haver.pm
trunk/main/core/t/merge_struct.t
trunk/main/core/t/protocol-filter.t
Modified:
trunk/main/core/lib/POE/Filter/Haver.pm
Log:
POE::Filter::Haver is deprecated in favor of Haver::Protocol::Filter.
The former still works, for now.
I removed tests that no longer work. The protocol-filter tests
were removed because they only tested the ->get() method of the filter,
which is commented out, because get_one is better.
Added: trunk/main/core/lib/Haver/Protocol/Filter.pm
===================================================================
--- trunk/main/core/lib/Haver/Protocol/Filter.pm 2004-12-28 07:49:53 UTC
(rev 434)
+++ trunk/main/core/lib/Haver/Protocol/Filter.pm 2004-12-28 07:58:52 UTC
(rev 435)
@@ -0,0 +1,159 @@
+# vim: set ft=perl ts=4 sw=4 sta si ai tw=100 expandtab:
+# POE::Filter::Haver
+# This is a POE filter for the Haver protocol.
+# It subclasses POE::Filter::Line.
+#
+# Copyright (C) 2003-2004 Bryan Donlan
+# Modifications and docs Copyright (C) 2004 Dylan William Hardison
+#
+# This module is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This module is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this module; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+package Haver::Protocol::Filter;
+use warnings;
+use strict;
+use POE;
+use base qw(POE::Filter::Line);
+use Haver::Protocol qw( $CRLF %Escape %Unescape );
+
+our $VERSION = "0.02";
+
+sub new {
+ my ($this) = @_;
+
+ return $this->SUPER::new(
+ OutputLiteral => $CRLF,
+ InputRegexp => qr/\r?\n/,
+ );
+}
+
+# This is not needed any more, so let's not use it.
+#sub get {
+# my ( $self, $arg) = @_;
+# my $lines = $self->SUPER::get($arg);
+#
+# foreach my $line (@{$lines}) {
+# my @f = split("\t", $line);
+#
+# foreach my $item (@f) {
+# $item =~ s/\e([rent])/$Unescape{$1}/g;
+# }
+# $line = [EMAIL PROTECTED];
+# }
+# return $lines;
+#}
+
+sub get_one {
+ my ($self) = @_;
+ my $lines = $self->SUPER::get_one;
+
+ foreach my $line (@{$lines}) {
+ my @f = split("\t", $line);
+
+ foreach my $item (@f) {
+ $item =~ s/\e([rent])/$Unescape{$1}/g;
+ }
+ $line = [EMAIL PROTECTED];
+ }
+ return $lines;
+}
+
+sub put {
+ my ( $self, $arg ) = @_;
+ my @ret;
+ foreach my $msg (@{$arg}) {
+ my @msg;
+ foreach my $item (@$msg) {
+ my $s = $item;
+ if (defined $s) {
+ $s =~ s/([\r\e\n\t])/\e$Escape{$1}/g;
+ } else {
+ $s = '';
+ }
+ push(@msg, $s);
+ }
+ push(@ret, join "\t", @msg);
+ }
+ return $self->SUPER::put([EMAIL PROTECTED]);
+}
+
+1;
+
+
+1;
+__END__
+
+=head1 NAME
+
+POE::Filter::Haver - POE::Filter for the Haver protocol.
+
+=head1 SYNOPSIS
+
+ use POE::Filter::Haver;
+ my $filter = new POE::Filter::Haver; # takes no arguments.
+
+ # See POE::Filter. This is just a standard filter.
+ # it inherits from POE::Filter::Line.
+
+=head1 DESCRIPTION
+
+This POE::Filter translates strings like "MSG\tdylan\tbunnies\xD\xA"
+to and from arrays like ['MSG', 'dylan', 'bunnies'].
+
+=head1 SEE ALSO
+
+L<POE::Filter>, L<POE::Filter::Line>.
+
+L<https://savannah.nongnu.org/projects/haver/>,
L<http://wiki.chani3.com/wiki/ProjectHaver/Protocol>,
+L<http://wiki.chani3.com/wiki/ProjectHaver/ProtocolSyntax>.
+
+=head1 AUTHOR
+
+Bryan Donlan, E<lt>:[EMAIL PROTECTED]<gt>
+with small modifications and documentation by
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2003-2004 by Bryan Donlan.
+Modifications and docs Copyright (C) 2004 Dylan William Hardison.
+
+This library is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+=cut
+
+
+sub new {
+ my ($this) = @_;
+ my $me = bless {}, ref($this) || $this;
+
+ # ...
+
+ return $me;
+}
+
+
+1;
+
Deleted: trunk/main/core/lib/Haver.pm
===================================================================
--- trunk/main/core/lib/Haver.pm 2004-12-28 07:49:53 UTC (rev 434)
+++ trunk/main/core/lib/Haver.pm 2004-12-28 07:58:52 UTC (rev 435)
@@ -1,76 +0,0 @@
-# Haver - Main module of Haver-Common.
-#
-# Copyright (C) 2004 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver;
-use strict;
-use warnings;
-
-our $VERSION = 0.06;
-
-1;
-__END__
-
-=head1 NAME
-
-Haver - Common modules for Haver::Server and Haver::Client.
-
-=head1 SYNOPSIS
-
-There is none. This module contains no code.
-
-=head1 DESCRIPTION
-
-This collection of modules contains
-modules used by both the Haver server and Haver client.
-
-=head2 EXPORT
-
-None by default.
-
-=head1 SEE ALSO
-
-L<Haver::Protocol>, L<Haver::Protocol::Filter>, L<Haver::Base>,
L<Haver::Singleton>,
-L<Haver::Utils::Logger>.
-
-
-L<https://gna.org/projects/haver/>
-
-
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2004 by Dylan William Hardison
-
-This library is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Modified: trunk/main/core/lib/POE/Filter/Haver.pm
===================================================================
--- trunk/main/core/lib/POE/Filter/Haver.pm 2004-12-28 07:49:53 UTC (rev
434)
+++ trunk/main/core/lib/POE/Filter/Haver.pm 2004-12-28 07:58:52 UTC (rev
435)
@@ -21,125 +21,26 @@
package POE::Filter::Haver;
use warnings;
use strict;
-use POE;
-use base qw(POE::Filter::Line);
-use Haver::Protocol qw( $CRLF %Escape %Unescape );
+use Haver::Protocol::Filter;
+use Carp;
our $VERSION = "0.02";
-
-
sub new {
my ($this) = @_;
-
- return $this->SUPER::new(
- OutputLiteral => $CRLF,
- InputRegexp => qr/\r?\n/,
- );
+
+ carp "POE::Filter::Haver is DEPRECATED. use Haver::Protocol::Filter
instead.";
+ return new Haver::Protocol::Filter;
}
-sub get {
- my ( $self, $arg) = @_;
- my $lines = $self->SUPER::get($arg);
-
- foreach my $line (@{$lines}) {
- my @f = split("\t", $line);
-
- foreach my $item (@f) {
- $item =~ s/\e([rent])/$Unescape{$1}/g;
- }
- $line = [EMAIL PROTECTED];
- }
- return $lines;
-}
-
-sub get_one {
- my ($self) = @_;
- my $lines = $self->SUPER::get_one;
-
- foreach my $line (@{$lines}) {
- my @f = split("\t", $line);
-
- foreach my $item (@f) {
- $item =~ s/\e([rent])/$Unescape{$1}/g;
- }
- $line = [EMAIL PROTECTED];
- }
- return $lines;
-}
-
-sub put {
- my ( $self, $arg ) = @_;
- my @ret;
- foreach my $msg (@{$arg}) {
- my @msg;
- foreach my $item (@$msg) {
- my $s = $item;
- if (defined $s) {
- $s =~ s/([\r\e\n\t])/\e$Escape{$1}/g;
- } else {
- $s = '';
- }
- push(@msg, $s);
- }
- push(@ret, join "\t", @msg);
- }
- return $self->SUPER::put([EMAIL PROTECTED]);
-}
-
1;
-
-
-1;
__END__
=head1 NAME
POE::Filter::Haver - POE::Filter for the Haver protocol.
-=head1 SYNOPSIS
-
- use POE::Filter::Haver;
- my $filter = new POE::Filter::Haver; # takes no arguments.
-
- # See POE::Filter. This is just a standard filter.
- # it inherits from POE::Filter::Line.
-
=head1 DESCRIPTION
-This POE::Filter translates strings like "MSG\tdylan\tbunnies\xD\xA"
-to and from arrays like ['MSG', 'dylan', 'bunnies'].
+THIS MODULE IS DEPRECATED. Please use Haver::Protocol::Filter.
-=head1 SEE ALSO
-
-L<POE::Filter>, L<POE::Filter::Line>.
-
-L<https://savannah.nongnu.org/projects/haver/>,
L<http://wiki.chani3.com/wiki/ProjectHaver/Protocol>,
-L<http://wiki.chani3.com/wiki/ProjectHaver/ProtocolSyntax>.
-
-=head1 AUTHOR
-
-Bryan Donlan, E<lt>:[EMAIL PROTECTED]<gt>
-with small modifications and documentation by
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2003-2004 by Bryan Donlan.
-Modifications and docs Copyright (C) 2004 Dylan William Hardison.
-
-This library is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Deleted: trunk/main/core/t/merge_struct.t
===================================================================
--- trunk/main/core/t/merge_struct.t 2004-12-28 07:49:53 UTC (rev 434)
+++ trunk/main/core/t/merge_struct.t 2004-12-28 07:58:52 UTC (rev 435)
@@ -1,103 +0,0 @@
-#!/usr/bin/perl
-# vim: set ft=perl ts=4 sw=4:
-use Test::More tests => 7;
-
-BEGIN {
- use_ok('Haver::Util::Misc', qw(merge_struct));
-};
-
-{
- # Basic hash merging
- my $a = {
- a => 42,
- c => 11,
- };
- my $b = {
- b => 42,
- d => 22,
- };
- my $c = {
- a => 42,
- b => 42,
- c => 11,
- d => 22,
- };
- is_deeply(merge_struct($a, $b), $c, 'Basic hash merging');
-}
-
-{
- # Basic list merging
- my $a = [ 1, 2 ];
- my $b = [ 3, 4 ];
- my $c = [ 1, 2, 3, 4 ];
- is_deeply(merge_struct($a, $b), $c, 'Basic list merging');
-}
-
-{
- # Subhash merging
- my $a = {
- a => {
- a => 42,
- }
- };
- my $b = {
- a => {
- b => 42,
- }
- };
- my $c = {
- a => {
- a => 42,
- b => 42,
- }
- };
- is_deeply(merge_struct($a, $b), $c, 'Subhash merging');
-}
-
-{
- # Sublist merging
- my $a = {
- a => [ 1 ]
- };
- my $b = {
- a => [ 2 ]
- };
- my $c = {
- a => [ 1, 2 ]
- };
- is_deeply(merge_struct($a, $b), $c, 'Sublist merging');
-}
-
-{
- # Precedence
- my $a = {
- a => 1,
- };
- my $b = {
- a => 2,
- };
- my $c = {
- a => 1,
- };
- is_deeply(merge_struct($a, $b), $c, 'Precedence');
-}
-
-{
- # Deep precedence
- my $a = {
- a => {
- a => 1,
- }
- };
- my $b = {
- a => {
- a => 2,
- }
- };
- my $c = {
- a => {
- a => 1,
- }
- };
- is_deeply(merge_struct($a, $b), $c, 'Deep precedence');
-}
Deleted: trunk/main/core/t/protocol-filter.t
===================================================================
--- trunk/main/core/t/protocol-filter.t 2004-12-28 07:49:53 UTC (rev 434)
+++ trunk/main/core/t/protocol-filter.t 2004-12-28 07:58:52 UTC (rev 435)
@@ -1,57 +0,0 @@
-#!/usr/bin/perl
-# vim: set ft=perl:
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl Haver.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-
-use Test::More;
-if (eval "require POE; 2") {
- plan tests => 9;
-} else {
- plan skip_all => 'Test irrelevant without POE';
-}
-
-
-use_ok('POE::Filter::Haver');
-
-#########################
-
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
-my $f = new POE::Filter::Haver;
-my $s = "MSG\tdylan\tbunnies\et\eet\x0D\x0A";
-is($f->put($f->get([$s]))->[0], $s, 'filter input is filter output');
-
-is_deeply($f->get([$s]), [ ['MSG', 'dylan', "bunnies\t\et"] ], "deep sanity");
-
-
-$s = "Tab: \t Esc: \e R: \r N: \n";
-my $o = $f->put([["dummy", $s]]);
-$o = $f->get($o);
-
-is_deeply($o, [['dummy', $s]], "deep sanity 2");
-
-$o = $o->[0]->[1];
-is($o, $s, 'escaping');
-
-my $in = "This is some input: Tab \t Esc: \e CR: \r LF: \n. Happy?";
-my $out = "OUT\tThis is some input: Tab \et Esc: \ee CR: \er LF: \en.
Happy?\r\n";
-is($f->put([['OUT', $in]])->[0], $out, "sanity");
-$o = $f->get([$out]);
-is($o->[0][1], $in, "sanity 2");
-
-$f->get_one_start([$out]);
-$o = $f->get_one;
-is($o->[0][1], $in, "sanity 3");
-
-$o = ['ONE', "\r\e\n\t"];
-$f->put([$o]);
-$f->put([$o]);
-is_deeply($o, ['ONE', "\r\e\n\t"], "no change");
-
-
-