| 1 | package BioSAILs::Utils::Files::CacheDir; | ||
| 2 | |||
| 3 | use Moose::Role; | ||
| 4 | use namespace::autoclean; | ||
| 5 | |||
| 6 | use MooseX::Types::Path::Tiny qw/Path/; | ||
| 7 | use Cwd qw(getcwd); | ||
| 8 | use File::Spec; | ||
| 9 | |||
| 10 | has 'cache_dir' => ( | ||
| 11 | is => 'rw', | ||
| 12 | isa => Path, | ||
| 13 | coerce => 1, | ||
| 14 | default => sub { | ||
| 15 | return File::Spec->catdir( getcwd(), '.biosails' ); | ||
| 16 | }, | ||
| 17 | documentation => 'BioSAILs will cache some information during your runs. ' | ||
| 18 | . 'Delete with caution! ' | ||
| 19 | ); | ||
| 20 | |||
| 21 | has 'cache_file' => ( | ||
| 22 | is => 'rw', | ||
| 23 | required => 0, | ||
| 24 | isa => Path, | ||
| 25 | coerce => 1, | ||
| 26 | documentation => 'BioSAILs caches relevant files.', | ||
| 27 | trigger => sub { | ||
| 28 | my $self = shift; | ||
| 29 | $self->cache_file->touchpath; | ||
| 30 | }, | ||
| 31 | ); | ||
| 32 | |||
| 33 | 1; |