Modules

  • ABCDE
  • FGHIL
  • MNOPS
  • TUX

Tools

TAP::Parser::IteratorFactory

Perl 5 version 12.2 documentation
Recently read

TAP::Parser::IteratorFactory

NAME

TAP::Parser::IteratorFactory - Internal TAP::Parser Iterator

VERSION

Version 3.17

SYNOPSIS

  1. use TAP::Parser::IteratorFactory;
  2. my $factory = TAP::Parser::IteratorFactory->new;
  3. my $iter = $factory->make_iterator(\*TEST);
  4. my $iter = $factory->make_iterator(\@array);
  5. my $iter = $factory->make_iterator(\%hash);
  6. my $line = $iter->next;

DESCRIPTION

This is a factory class for simple iterator wrappers for arrays, filehandles, and hashes. Unless you're subclassing, you probably won't need to use this module directly.

METHODS

Class Methods

new

Creates a new factory class. Note: You currently don't need to instantiate a factory in order to use it.

make_iterator

Create an iterator. The type of iterator created depends on the arguments to the constructor:

  1. my $iter = TAP::Parser::Iterator->make_iterator( $filehandle );

Creates a stream iterator (see make_stream_iterator).

  1. my $iter = TAP::Parser::Iterator->make_iterator( $array_reference );

Creates an array iterator (see make_array_iterator).

  1. my $iter = TAP::Parser::Iterator->make_iterator( $hash_reference );

Creates a process iterator (see make_process_iterator).

make_stream_iterator

Make a new stream iterator and return it. Passes through any arguments given. Defaults to a TAP::Parser::Iterator::Stream.

make_array_iterator

Make a new array iterator and return it. Passes through any arguments given. Defaults to a TAP::Parser::Iterator::Array.

make_process_iterator

Make a new process iterator and return it. Passes through any arguments given. Defaults to a TAP::Parser::Iterator::Process.

SUBCLASSING

Please see SUBCLASSING in TAP::Parser for a subclassing overview.

There are a few things to bear in mind when creating your own ResultFactory :

1

The factory itself is never instantiated (this may change in the future). This means that _initialize is never called.

Example

  1. package MyIteratorFactory;
  2. use strict;
  3. use vars '@ISA';
  4. use MyStreamIterator;
  5. use TAP::Parser::IteratorFactory;
  6. @ISA = qw( TAP::Parser::IteratorFactory );
  7. # override stream iterator
  8. sub make_stream_iterator {
  9. my $proto = shift;
  10. MyStreamIterator->new(@_);
  11. }
  12. 1;

ATTRIBUTION

Originally ripped off from Test::Harness.

SEE ALSO

TAP::Object, TAP::Parser, TAP::Parser::Iterator, TAP::Parser::Iterator::Array, TAP::Parser::Iterator::Stream, TAP::Parser::Iterator::Process,