| 1 | package TaskPipe::Task_SourceFromFile; | ||
| 2 | |||
| 3 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | extends 'TaskPipe::Task'; | |
| 5 | 1 | with 'MooseX::ConfigCascade'; | |
| 6 | |||
| 7 | has path_settings => (is => 'rw', isa => 'TaskPipe::PathSettings', default => sub{ | ||
| 8 | 1 | ▶ | TaskPipe::PathSettings->new; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 9 | 1 | }); | |
| 10 | |||
| 11 | |||
| 12 | sub action{ | ||
| 13 | 0 | ▶ | my $self = shift; |
|
Subroutine
action: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 14 | |||
| 15 | my $filepath = $self->path_settings->path( | ||
| 16 | 'source', | ||
| 17 | $self->param->{filename} | ||
| 18 | 0 | ); | |
| 19 | |||
| 20 | 0 | my $list = $self->cascade_util->parser->( $filepath ); | |
| 21 | 0 | return $list; | |
| 22 | } | ||
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | TaskPipe::Task_SourceFromFile - use a file as a data source | ||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | This is the standard task for reading from a yaml data file (and outputing the records as an arrayref). You can use this task directly. You should make sure the file the task is reading is in a format which will become an array when read by L<YAML::XS>. For example: | ||
| 31 | |||
| 32 | --- | ||
| 33 | - url: https://www.example.com/first_record | ||
| 34 | headers: | ||
| 35 | Referer: https://www.example.com | ||
| 36 | |||
| 37 | - url: https://www.example.com/second_record | ||
| 38 | Referer: https://www.example.com | ||
| 39 | |||
| 40 | # ... | ||
| 41 | |||
| 42 | In your plan, specify the task as follows: | ||
| 43 | |||
| 44 | # (tree format): | ||
| 45 | |||
| 46 | task: | ||
| 47 | |||
| 48 | _name: SourceFromFile | ||
| 49 | filename: mydatafile.yml | ||
| 50 | |||
| 51 | pipe_to: | ||
| 52 | |||
| 53 | # ... | ||
| 54 | |||
| 55 | =head1 AUTHOR | ||
| 56 | |||
| 57 | Tom Gracey <tomgracey@gmail.com> | ||
| 58 | |||
| 59 | =head1 COPYRIGHT AND LICENSE | ||
| 60 | |||
| 61 | Copyright (c) Tom Gracey 2018 | ||
| 62 | |||
| 63 | TaskPipe is free software, licensed under | ||
| 64 | |||
| 65 | The GNU Public License Version 3 | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | 1 | __PACKAGE__->meta->make_immutable; | |
| 70 | 1 | 1; | |
| 71 | __END__ | ||