From: Vincent Pit Date: Sun, 29 Jun 2008 15:12:50 +0000 (+0200) Subject: Importing Bit-MorseSignals-0.03.tar.gz X-Git-Tag: v0.03 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=7012dd0f94f18e74f0a7d92a13c16e2334fd6e4f;p=perl%2Fmodules%2FBit-MorseSignals.git Importing Bit-MorseSignals-0.03.tar.gz --- diff --git a/Changes b/Changes index 9402d8f..1d01650 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Bit-MorseSignals +0.03 2008-03-03 17:30 GMT + + Doc : Clarified synopsises. + + Fix : The receiver could access inexistant demanglers if an error + occurred during the transfer. + 0.02 2008-03-01 12:00 GMT + Add : The samples/jerk.pl example script. + Doc : Typos in POD. diff --git a/META.yml b/META.yml index 9c92978..e8f8bd9 100644 --- a/META.yml +++ b/META.yml @@ -1,11 +1,11 @@ --- #YAML:1.0 name: Bit-MorseSignals -version: 0.02 +version: 0.03 abstract: The MorseSignals protocol. license: perl author: - Vincent Pit -generated_by: ExtUtils::MakeMaker version 6.42 +generated_by: ExtUtils::MakeMaker version 6.44 distribution_type: module requires: Carp: 0 diff --git a/README b/README index 0420536..4d6bd1a 100644 --- a/README +++ b/README @@ -2,7 +2,17 @@ NAME Bit::MorseSignals - The MorseSignals protocol. VERSION - Version 0.02 + Version 0.03 + +SYNOPSIS + use Bit::MorseSignals::Emitter; + use Bit::MorseSignals::Receiver; + + my $deuce = new Bit::MorseSignals::Emitter; + my $pants = new Bit::MorseSignals::Receiver done => sub { print $_[1], "\n" }; + + $deuce->post('HLAGH') for 1 .. 3; + $pants->push while defined ($_ = $deuce->pop); DESCRIPTION In unidirectionnal communication channels (such as networking or IPC), @@ -82,7 +92,7 @@ SEE ALSO Bit::MorseSignals::Emitter, Bit::MorseSignals::Receiver. AUTHOR - Vincent Pit, "" + Vincent Pit, "", . You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). diff --git a/lib/Bit/MorseSignals.pm b/lib/Bit/MorseSignals.pm index a8d13f6..d06a353 100644 --- a/lib/Bit/MorseSignals.pm +++ b/lib/Bit/MorseSignals.pm @@ -9,11 +9,22 @@ Bit::MorseSignals - The MorseSignals protocol. =head1 VERSION -Version 0.02 +Version 0.03 =cut -our $VERSION = '0.02'; +our $VERSION = '0.03'; + +=head1 SYNOPSIS + + use Bit::MorseSignals::Emitter; + use Bit::MorseSignals::Receiver; + + my $deuce = new Bit::MorseSignals::Emitter; + my $pants = new Bit::MorseSignals::Receiver done => sub { print $_[1], "\n" }; + + $deuce->post('HLAGH') for 1 .. 3; + $pants->push while defined ($_ = $deuce->pop); =head1 DESCRIPTION @@ -114,7 +125,7 @@ L, L. =head1 AUTHOR -Vincent Pit, C<< >> +Vincent Pit, C<< >>, L. You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). diff --git a/lib/Bit/MorseSignals/Emitter.pm b/lib/Bit/MorseSignals/Emitter.pm index 9d0273a..34862f0 100644 --- a/lib/Bit/MorseSignals/Emitter.pm +++ b/lib/Bit/MorseSignals/Emitter.pm @@ -15,15 +15,15 @@ Bit::MorseSignals::Emitter - Base class for Bit::MorseSignals emitters. =head1 VERSION -Version 0.02 +Version 0.03 =cut -our $VERSION = '0.02'; +our $VERSION = '0.03'; =head1 SYNOPSIS - use Bit::MorseSignals; + use Bit::MorseSignals::Emitter; my $deuce = new Bit::MorseSignals::Emitter; $deuce->post("hlagh") for 1 .. 3; @@ -241,7 +241,7 @@ L, L. =head1 AUTHOR -Vincent Pit, C<< >> +Vincent Pit, C<< >>, L. You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). diff --git a/lib/Bit/MorseSignals/Receiver.pm b/lib/Bit/MorseSignals/Receiver.pm index 0dd41aa..6c13004 100644 --- a/lib/Bit/MorseSignals/Receiver.pm +++ b/lib/Bit/MorseSignals/Receiver.pm @@ -15,15 +15,15 @@ Bit::MorseSignals::Receiver - Base class for Bit::MorseSignals receivers. =head1 VERSION -Version 0.02 +Version 0.03 =cut -our $VERSION = '0.02'; +our $VERSION = '0.03'; =head1 SYNOPSIS - use Bit::MorseSignals; + use Bit::MorseSignals::Receiver; my $pants = new Bit::MorseSignals::Receiver done => sub { print "received $_[1]!\n" }; while (...) { @@ -98,7 +98,9 @@ sub push { substr $self->{buf}, -$base, $base, ''; my @demanglers = (sub { $_[0] }, \&decode_utf8, \&thaw ); # BM_DATA_{PLAIN, UTF8, STORABLE} - $self->{msg} = $demanglers[$self->{type}]->($self->{buf}); + $self->{msg} = defined $demanglers[$self->{type}] + ? $demanglers[$self->{type}]->($self->{buf}) + : $self->{buf}; $self->reset; $self->{done}->($self, $self->{msg}) if $self->{done}; return; @@ -185,7 +187,7 @@ L, L. =head1 AUTHOR -Vincent Pit, C<< >> +Vincent Pit, C<< >>, L. You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). diff --git a/t/50-chitchat-plain.t b/t/50-chitchat-plain.t index d997925..a419830 100644 --- a/t/50-chitchat-plain.t +++ b/t/50-chitchat-plain.t @@ -12,8 +12,10 @@ my @msgs = qw/hlagh hlaghlaghlagh HLAGH HLAGHLAGHLAGH \x{0dd0}\x{00} h\x{00}la\x{00}gh \x{00}\x{ff}\x{ff}\x{00}\x{00}\x{ff}/; my $deuce = new Bit::MorseSignals::Emitter; -my $pants = new Bit::MorseSignals::Receiver - done => sub { ok($_[1] eq shift @msgs, "got $_[1]") }; +my $pants = new Bit::MorseSignals::Receiver done => sub { + my $cur = shift @msgs; + ok($_[1] eq $cur, 'got ' . $_[1] . ', received ' . $cur) +}; $deuce->post($_) for @msgs; $pants->push while defined ($_ = $deuce->pop); # ))<>(( @@ -21,4 +23,4 @@ $pants->push while defined ($_ = $deuce->pop); # ))<>(( ok(!$deuce->busy, 'emitter is no longer busy after all the messages have been sent'); ok(!$pants->busy, 'receiver is no longer busy after all the messages have been got'); -ok(0, "didn\'t got $_") for @msgs; +ok(0, "didn't got $_") for @msgs; diff --git a/t/52-chitchat-storable.t b/t/52-chitchat-storable.t index c8f5130..7511dae 100644 --- a/t/52-chitchat-storable.t +++ b/t/52-chitchat-storable.t @@ -7,7 +7,6 @@ use utf8; use Test::More tests => 10; -use Bit::MorseSignals qw/BM_DATA_STORABLE/; use Bit::MorseSignals::Emitter; use Bit::MorseSignals::Receiver;