| 1 | package XT::Files::Plugin::Default; | ||
| 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 $dirs = 1; | ||
| 15 | my $excludes = 1; | ||
| 16 | |||
| 17 | ARG: | ||
| 18 | for my $arg ( @{$args} ) { | ||
| 19 | my ( $key, $value ) = @{$arg}; | ||
| 20 | |||
| 21 | if ( $key eq 'dirs' ) { | ||
| 22 | $dirs = !!$value; | ||
| 23 | next ARG; | ||
| 24 | } | ||
| 25 | |||
| 26 | if ( $key eq 'excludes' ) { | ||
| 27 | $excludes = !!$value; | ||
| 28 | next ARG; | ||
| 29 | } | ||
| 30 | |||
| 31 | $self->log_fatal("Invalid configuration option '$key = $value' for plugin 'Default'"); | ||
| 32 | } | ||
| 33 | |||
| 34 | my $xtf = $self->xtf; | ||
| 35 | |||
| 36 | if ($excludes) { | ||
| 37 | $xtf->plugin( 'Excludes', undef, [ map { [ 'exclude' => $_ ] } (qw([.]swp$ [.]bak$ ~$)) ] ); | ||
| 38 | } | ||
| 39 | |||
| 40 | if ($dirs) { | ||
| 41 | $xtf->plugin( | ||
| 42 | 'Dirs', undef, | ||
| 43 | [ | ||
| 44 | [ bin => 'bin' ], | ||
| 45 | [ bin => 'script' ], | ||
| 46 | [ module => 'lib' ], | ||
| 47 | ], | ||
| 48 | ); | ||
| 49 | } | ||
| 50 | |||
| 51 | return; | ||
| 52 | } | ||
| 53 | |||
| 54 | 1; | ||
| 55 | |||
| 56 | __END__ |