Skip Menu |

This queue is for tickets about the Pipeline CPAN distribution.

Report information
The Basics
Id: 2468
Status: resolved
Priority: 0/
Queue: Pipeline

People
Owner: Nobody in particular
Requestors: spurkis [...] quiup.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 3.01
Fixed in: (no value)



Subject: [PATCH] add/del_segment & init methods return values
The return values of these methods are not documented: $pipe->init $pipe->add_segments $pipe->del_segment I'd argue that init() and add_segments() should return $self so that they can be cascaded. del_segment() returns the deleted segment, it just needs documenting. See attached patch. -Steve
diff -ruN Pipeline-3.01.orig/lib/Pipeline.pm Pipeline-3.01/lib/Pipeline.pm --- Pipeline-3.01.orig/lib/Pipeline.pm Thu Apr 3 09:55:20 2003 +++ Pipeline-3.01/lib/Pipeline.pm Thu May 1 10:55:09 2003 @@ -16,15 +16,16 @@ $self->debug( 0 ); $self->store( Pipeline::Store::Simple->new() ); $self->segments( [] ); - return 1; + return $self; } else { - return 0; + return undef; } } sub add_segment { my $self = shift; push @{ $self->segments }, grep { blessed( $_ ) && $_->isa('Pipeline::Segment') } @_; + return $self; } sub get_segment { @@ -172,15 +173,15 @@ =over 4 -=item init() +=item init( @_ ) Things to do at construction time. If you do override this, its will often be fairly important that you call $self->SUPER::init(@_) to make sure that -the setup is done correctly. +the setup is done correctly. Returns itself on success, undef on failure. =item add_segment( LIST ) -Adds a segment or segments to the pipeline. +Adds a segment or segments to the pipeline. Returns itself. =item get_segment( INTEGER ) @@ -188,7 +189,7 @@ =item del_segment( INTEGER ) -Deletes the segment located at the index specified by INTEGER +Deletes and returns the segment located at the index specified by INTEGER =item dispatch() diff -ruN Pipeline-3.01.orig/t/01simple.t Pipeline-3.01/t/01simple.t --- Pipeline-3.01.orig/t/01simple.t Wed Mar 26 14:35:30 2003 +++ Pipeline-3.01/t/01simple.t Thu May 1 10:56:14 2003 @@ -12,13 +12,13 @@ use MyPipeCleanup; use Pipeline; use Data::Dumper; -use Test::Simple tests => 3; +use Test::More tests => 6; my $pipeline = Pipeline->new(); my $subpipeline = Pipeline->new(); $subpipeline->add_segment( MyPipe->new() ); -$pipeline->add_segment( MyPipe->new(), MyPipe->new(), $subpipeline ); +$pipeline->add_segment( MyPipe->new(), MyPipe->new(), $subpipeline ); print Dumper( $pipeline ); ok($pipeline, "we have a pipeline"); @@ -30,7 +30,11 @@ ); - +my $pipe = Pipeline->new(); +my $seg = MyPipe->new(); +is( $pipe->add_segment( $seg ), $pipe, 'add_segment' ); +is( $pipe->del_segment( 0 ), $seg, 'del_segment' ); +is( $pipe->init, $pipe, 'init' );