| 1 | # | ||
| 2 | # Test::System::Output::Factory | ||
| 3 | # | ||
| 4 | # Author(s): Pablo Fischer (pfischer@cpan.org) | ||
| 5 | # Created: 11/08/2009 15:20:11 PST 15:20:11 | ||
| 6 | package Test::System::Output::Factory; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Test::System::Output::Factory - Factory class for building TAP formatters | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | This module is part of L<Test::System> and is used as a factory class for | ||
| 15 | the TAP formats. | ||
| 16 | |||
| 17 | Usually this module gets called directly by L<Test::System> but if you want | ||
| 18 | to create the instance, modify it and then pass it to L<Test::System>. | ||
| 19 | |||
| 20 | =head1 SYNOPSIS | ||
| 21 | |||
| 22 | use Test::System::Output::Factory; | ||
| 23 | |||
| 24 | my $formatter = Test::System::Output::Factory->new('html'); | ||
| 25 | $formatter->do_your_stuff(); | ||
| 26 | |||
| 27 | =head1 Available formatters | ||
| 28 | |||
| 29 | =over 4 | ||
| 30 | |||
| 31 | =item * C<html> | ||
| 32 | |||
| 33 | Returns a L<TAP::Formatter::HTML> instance | ||
| 34 | |||
| 35 | =item * C<console> | ||
| 36 | |||
| 37 | Returns a L<TAP::Formatter::Console> instance | ||
| 38 | |||
| 39 | =back | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | use strict; | ||
| 44 | use warnings; | ||
| 45 | use Class::Factory; | ||
| 46 | use base qw(Class::Factory); | ||
| 47 | |||
| 48 | our $VERSION = '0.03'; | ||
| 49 | |||
| 50 | sub new { | ||
| 51 | my ($pkg, $type, @params) = @_; | ||
| 52 | my $class = $pkg->get_factory_class($type); | ||
| 53 | return undef unless ($class); | ||
| 54 | my $self = "$class"->new(@params); | ||
| 55 | return $self; | ||
| 56 | } | ||
| 57 | |||
| 58 | __PACKAGE__->register_factory_type(html => 'TAP::Formatter::HTML'); | ||
| 59 | __PACKAGE__->register_factory_type(console => 'TAP::Formatter::Console'); | ||
| 60 | |||
| 61 | =head1 AUTHOR | ||
| 62 | |||
| 63 | Pablo Fischer, pablo@pablo.com.mx. | ||
| 64 | |||
| 65 | |||
| 66 | =head1 COPYRIGHT | ||
| 67 | |||
| 68 | Copyright (C) 2009 by Pablo Fischer | ||
| 69 | |||
| 70 | This library is free software; you can redistribute it and/or modify | ||
| 71 | it under the same terms as Perl itself. | ||
| 72 | |||
| 73 | =cut | ||
| 74 | |||
| 75 | 1; | ||
| 76 |