| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | ETL::Pipeline::Input::UnitTest - Input source for unit tests | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use ETL::Pipeline; | ||
| 10 | ETL::Pipeline->new( { | ||
| 11 | input => ['UnitTest'], | ||
| 12 | mapping => {First => 'Header1', Second => 'Header2'}, | ||
| 13 | output => ['UnitTest'] | ||
| 14 | } )->process; | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | B<ETL::Pipeline::Input::UnitTest> is an input source used by the unit tests. | ||
| 19 | It proves that the L<ETL::Pipeline::Input> role works. | ||
| 20 | |||
| 21 | The I<data> is hard coded. | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | package ETL::Pipeline::Input::UnitTest; | ||
| 26 | 3 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | |||
| 28 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 29 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | |||
| 31 | 3 | ▶ | use 5.014; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | |||
| 33 | |||
| 34 | 3 | our $VERSION = '3.00'; | |
| 35 | |||
| 36 | |||
| 37 | =head1 METHODS & ATTRIBUTES | ||
| 38 | |||
| 39 | =head2 Arguments for L<ETL::Pipeline/input> | ||
| 40 | |||
| 41 | None - there's no configuration for this source. It's meant to be quick and | ||
| 42 | light for unit testing. | ||
| 43 | |||
| 44 | =head2 Methods | ||
| 45 | |||
| 46 | =head3 run | ||
| 47 | |||
| 48 | This is the main loop. For unit tests, I use hard coded data. This guarantees | ||
| 49 | consistent behavior. | ||
| 50 | |||
| 51 | L<ETL::Pipeline> automatically calls this method. | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | 24 | ▶ | sub run { |
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||
| 56 | 24 | my ($self, $etl) = @_; | |
| 57 | |||
| 58 | 24 | $etl->aliases( | |
| 59 | {Header1 => 0}, | ||
| 60 | {Header2 => 1}, | ||
| 61 | {Header3 => 2}, | ||
| 62 | {' Header4 ' => 3}, | ||
| 63 | {Header6 => 5}, | ||
| 64 | {Header6 => 6}, | ||
| 65 | ); | ||
| 66 | 24 | $etl->record( [qw/ | |
| 67 | Field1 | ||
| 68 | Field2 | ||
| 69 | Field3 | ||
| 70 | Field4 | ||
| 71 | Field5 | ||
| 72 | Field6 | ||
| 73 | Field7 | ||
| 74 | Field8 | ||
| 75 | Field9 | ||
| 76 | /] ); | ||
| 77 | 24 | $etl->record( [qw/ | |
| 78 | Field11 | ||
| 79 | Field12 | ||
| 80 | Field13 | ||
| 81 | Field14 | ||
| 82 | Field15 | ||
| 83 | Field16 | ||
| 84 | Field17 | ||
| 85 | Field18 | ||
| 86 | Field19 | ||
| 87 | /] ); | ||
| 88 | } | ||
| 89 | |||
| 90 | |||
| 91 | =head1 SEE ALSO | ||
| 92 | |||
| 93 | L<ETL::Pipeline>, L<ETL::Pipeline::Input>, L<ETL::Pipeline::Output::UnitTest> | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | 3 | with 'ETL::Pipeline::Input'; | |
| 98 | |||
| 99 | |||
| 100 | =head1 AUTHOR | ||
| 101 | |||
| 102 | Robert Wohlfarth <robert.j.wohlfarth@vumc.org> | ||
| 103 | |||
| 104 | =head1 LICENSE | ||
| 105 | |||
| 106 | Copyright 2021 (c) Vanderbilt University | ||
| 107 | |||
| 108 | This program is free software; you can redistribute it and/or modify it under | ||
| 109 | the same terms as Perl itself. | ||
| 110 | |||
| 111 | =cut | ||
| 112 | |||
| 113 | 3 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 114 | 3 | __PACKAGE__->meta->make_immutable; | |