1 |
package Frey::File; |
2 |
use Moose::Role; |
3 |
|
4 |
use File::Slurp qw//; |
5 |
|
6 |
=head2 read_file |
7 |
|
8 |
L<File::Slurp/read_file> |
9 |
|
10 |
=cut |
11 |
|
12 |
sub read_file { shift ; File::Slurp::read_file( @_ ) } |
13 |
|
14 |
=head2 write_file |
15 |
|
16 |
L<File::Slurp/write_file> |
17 |
|
18 |
=cut |
19 |
|
20 |
sub write_file { shift ; File::Slurp::write_file( @_ ) } |
21 |
|
22 |
=head2 dir_extension |
23 |
|
24 |
my @files = $self->dir_extension( 'var/directory/', '\.(ya?ml)$' ); |
25 |
|
26 |
=cut |
27 |
|
28 |
sub dir_extension { |
29 |
my ($self,$path,$extension) = @_; |
30 |
|
31 |
opendir(my $dir, $path) || die "can't opendir $path: $!"; |
32 |
my @files = sort grep { m/$extension/ } readdir($dir); |
33 |
closedir $dir; |
34 |
return @files; |
35 |
} |
36 |
|
37 |
1; |