| 1 | package App::CSE::Role::DirIndex; | ||
| 2 | $App::CSE::Role::DirIndex::VERSION = '0.016'; | ||
| 3 | use Moose::Role; | ||
| 4 | # Factorizing dir_index command property. | ||
| 5 | # | ||
| 6 | |||
| 7 | requires 'cse'; | ||
| 8 | |||
| 9 | use Path::Class::Dir; | ||
| 10 | |||
| 11 | has 'dir_index' => ( is => 'ro' , isa => 'Path::Class::Dir' , lazy_build => 1 ); | ||
| 12 | |||
| 13 | |||
| 14 | sub _build_dir_index{ | ||
| 15 | my ($self) = @_; | ||
| 16 | |||
| 17 | if( my $to_index = $self->cse->options()->{dir} ){ | ||
| 18 | return Path::Class::Dir->new($to_index); | ||
| 19 | } | ||
| 20 | |||
| 21 | ## Default to the current directory (in a relative way). | ||
| 22 | return Path::Class::Dir->new(); | ||
| 23 | } | ||
| 24 | |||
| 25 | 1; | ||
| 26 |