| 1 | package MooseX::Role::Tempdir; | ||||||||||
| 2 | 2 | $MooseX::Role::Tempdir::VERSION = '0.101'; | |||||||||
| 3 | 2 | ▶ | use MooseX::Role::Parameterized; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use File::Temp qw//; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | #ABSTRACT: Moose role providing temporary directory attributes | ||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | parameter 'dirs' => ( | ||||||||||
| 10 | isa => 'ArrayRef[Str]|HashRef[HashRef]', | ||||||||||
| 11 | 0 | ▶ | default => sub { [ 'tmpdir' ] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | 2 | ); | |||||||||
| 13 | |||||||||||
| 14 | parameter 'tmpdir_opts' => ( | ||||||||||
| 15 | isa => 'HashRef', | ||||||||||
| 16 | 0 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 17 | 2 | ); | |||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | role { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 20 | 0 | my $self = shift; | |||||||||
| 21 | 0 | my $dirs = $self->dirs; | |||||||||
| 22 | 0 | my $global_opts = $self->tmpdir_opts; | |||||||||
| 23 | 0 | ▶ | if (ref $dirs eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | for my $dir (@$dirs) { | |||||||||
| 25 | has $dir => ( | ||||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | isa => 'File::Temp::Dir', | ||||||||||
| 28 | lazy => 1, | ||||||||||
| 29 | 0 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 30 | 0 | return File::Temp->newdir(%$global_opts); | |||||||||
| 31 | }, | ||||||||||
| 32 | 0 | ); | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | else { | ||||||||||
| 36 | 0 | for my $dir (keys %$dirs) { | |||||||||
| 37 | has $dir => ( | ||||||||||
| 38 | is => 'ro', | ||||||||||
| 39 | isa => 'File::Temp::Dir', | ||||||||||
| 40 | lazy => 1, | ||||||||||
| 41 | 0 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 42 | 0 | return File::Temp->newdir(%$global_opts, %{$dirs->{$dir}}); | |||||||||
| 43 | }, | ||||||||||
| 44 | ) | ||||||||||
| 45 | 0 | } | |||||||||
| 46 | } | ||||||||||
| 47 | 2 | }; | |||||||||
| 48 | |||||||||||
| 49 | 2 | 1; # End of MooseX::Role::Tempdir | |||||||||
| 50 | |||||||||||
| 51 | __END__ | ||||||||||