| 1 | package XT::Files::Plugin::Files; | ||
| 2 | |||
| 3 | use 5.006; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = '0.001'; | ||
| 8 | |||
| 9 | use parent 'XT::Files::Plugin'; | ||
| 10 | |||
| 11 | sub run { | ||
| 12 | my ( $self, $args ) = @_; | ||
| 13 | |||
| 14 | my @files; | ||
| 15 | |||
| 16 | ARG: | ||
| 17 | for my $arg ( @{$args} ) { | ||
| 18 | my ( $key, $value ) = @{$arg}; | ||
| 19 | |||
| 20 | if ( ( $key eq 'bin' ) || ( $key eq 'module' ) || ( $key eq 'pod' ) || ( $key eq 'test' ) ) { | ||
| 21 | push @files, $arg; | ||
| 22 | next ARG; | ||
| 23 | } | ||
| 24 | |||
| 25 | $self->log_fatal("Invalid configuration option '$key = $value' for plugin 'Files'"); | ||
| 26 | } | ||
| 27 | |||
| 28 | my $xtf = $self->xtf; | ||
| 29 | |||
| 30 | FILE: | ||
| 31 | for my $file (@files) { | ||
| 32 | my ( $type, $name ) = @{$file}; | ||
| 33 | |||
| 34 | next FILE if -l $name || -d _ || !-e _; | ||
| 35 | |||
| 36 | if ( $type eq 'bin' ) { | ||
| 37 | $xtf->bin_file($name); | ||
| 38 | next FILE; | ||
| 39 | } | ||
| 40 | |||
| 41 | if ( $type eq 'module' ) { | ||
| 42 | $xtf->module_file($name); | ||
| 43 | next FILE; | ||
| 44 | } | ||
| 45 | |||
| 46 | if ( $type eq 'pod' ) { | ||
| 47 | $xtf->pod_file($name); | ||
| 48 | next FILE; | ||
| 49 | } | ||
| 50 | |||
| 51 | if ( $type eq 'test' ) { | ||
| 52 | $xtf->test_file($name); | ||
| 53 | next FILE; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | return; | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; | ||
| 61 | |||
| 62 | __END__ |